[WIP] Working basic adapter detection

Need to begin to put this in the right
places....
This commit is contained in:
Terry MacDonald 2021-06-14 20:37:35 +12:00
parent f3acb9d292
commit a8c0307ace
2 changed files with 24 additions and 4 deletions

View File

@ -244,6 +244,15 @@ namespace ATI.ADL
///<summary> Indicating the display info value.<summary> ///<summary> Indicating the display info value.<summary>
internal int DisplayInfoValue; internal int DisplayInfoValue;
} }
/// <summary> ADLDisplayInfo Array</summary>
[StructLayout(LayoutKind.Sequential)]
internal struct ADLDisplayInfoArray
{
/// <summary> ADLDisplayInfo Array </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)ADL.ADL_MAX_DISPLAYS)]
internal ADLDisplayInfo[] ADLDisplayInfo;
}
#endregion ADLDisplayInfo #endregion ADLDisplayInfo
#region ADLSLS #region ADLSLS

View File

@ -80,14 +80,25 @@ namespace DisplayMagicianShared.AMD
int j = 0; int j = 0;
// Force the display detection and get the Display Info. Use 0 as last parameter to NOT force detection // Force the display detection and get the Display Info. Use 0 as last parameter to NOT force detection
ADLRet = ADL.ADL_Display_DisplayInfo_Get(OSAdapterInfoData.ADLAdapterInfo[i].AdapterIndex, ref NumberOfDisplays, out DisplayBuffer, 1); ADLRet = ADL.ADL_Display_DisplayInfo_Get(OSAdapterInfoData.ADLAdapterInfo[i].AdapterIndex, ref NumberOfDisplays, out DisplayBuffer, 0);
if (ADL.ADL_SUCCESS == ADLRet) if (ADL.ADL_SUCCESS == ADLRet)
{ {
List<ADLDisplayInfo> DisplayInfoData = new List<ADLDisplayInfo>(); List<ADLDisplayInfo> DisplayInfoData = new List<ADLDisplayInfo>();
for (j = 0; j < NumberOfDisplays; j++)
try
{ {
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt32() + j * Marshal.SizeOf(oneDisplayInfo)), oneDisplayInfo.GetType());
DisplayInfoData.Add(oneDisplayInfo); for (j = 0; j < NumberOfDisplays; j++)
{
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt64() + (j * Marshal.SizeOf(oneDisplayInfo))), oneDisplayInfo.GetType());
DisplayInfoData.Add(oneDisplayInfo);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception caused trying to access attached displays");
continue;
} }
Console.WriteLine("\nTotal Number of Displays supported: " + NumberOfDisplays.ToString()); Console.WriteLine("\nTotal Number of Displays supported: " + NumberOfDisplays.ToString());
Console.WriteLine("\nDispID AdpID Type OutType CnctType Connected Mapped InfoValue DisplayName "); Console.WriteLine("\nDispID AdpID Type OutType CnctType Connected Mapped InfoValue DisplayName ");