mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Attempt to fix the display detection for checking valid profiles
Initial work in progress profile 'IsPossible' logic update.
This commit is contained in:
parent
9d5a5ebd62
commit
466cdc647e
@ -139,284 +139,14 @@ namespace HeliosPlus.Shared
|
||||
get
|
||||
{
|
||||
|
||||
//List<string> DisplayInfo = DisplayIdentifier.GetDisplayIdentification();
|
||||
//DisplayManager displayManager;
|
||||
Console.WriteLine($"*** Physical GPU looping ***");
|
||||
NvAPIWrapper.GPU.PhysicalGPU[] myPhysicalGPUs = NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs();
|
||||
foreach (NvAPIWrapper.GPU.PhysicalGPU myGPU in myPhysicalGPUs)
|
||||
// Check each display in this profile and make sure it's currently available
|
||||
foreach (string profileDisplayIdentifier in ProfileDisplayIdentifiers)
|
||||
{
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.FullName}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.ActiveOutputs}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.ArchitectInformation}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.Board}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.Foundry}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.GPUId}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.GPUType}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.Handle}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.IsQuadro}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.SystemType}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.UsageInformation}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.ActiveOutputs}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU}");
|
||||
|
||||
// get a list of all physical displayDevices attached to the GPUs
|
||||
NvAPIWrapper.Display.DisplayDevice[] connectedDisplayDevices = myGPU.GetDisplayDevices();
|
||||
foreach (NvAPIWrapper.Display.DisplayDevice aConnectedDisplayDevice in connectedDisplayDevices)
|
||||
{
|
||||
Console.WriteLine($"DisplayID: {aConnectedDisplayDevice.DisplayId}");
|
||||
Console.WriteLine($"ConnectionType: {aConnectedDisplayDevice.ConnectionType}");
|
||||
Console.WriteLine($"IsActive: {aConnectedDisplayDevice.IsActive}");
|
||||
Console.WriteLine($"IsAvailble: {aConnectedDisplayDevice.IsAvailable}");
|
||||
Console.WriteLine($"IsCluster: {aConnectedDisplayDevice.IsCluster}");
|
||||
Console.WriteLine($"IsConnected: {aConnectedDisplayDevice.IsConnected}");
|
||||
Console.WriteLine($"IsDynamic: {aConnectedDisplayDevice.IsDynamic}");
|
||||
Console.WriteLine($"IsMultistreamrootnaode: {aConnectedDisplayDevice.IsMultiStreamRootNode}");
|
||||
Console.WriteLine($"IsOSVisible: {aConnectedDisplayDevice.IsOSVisible}");
|
||||
Console.WriteLine($"IsPhysicallyConnected: {aConnectedDisplayDevice.IsPhysicallyConnected}");
|
||||
Console.WriteLine($"IsWFD: {aConnectedDisplayDevice.IsWFD}");
|
||||
Console.WriteLine($"Output: {aConnectedDisplayDevice.Output}");
|
||||
Console.WriteLine($"PhysicalGPU: {aConnectedDisplayDevice.PhysicalGPU}");
|
||||
Console.WriteLine($"ScanOutInformation: {aConnectedDisplayDevice.ScanOutInformation}");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"*** Physical GPU looping using outputs ***");
|
||||
foreach (NvAPIWrapper.GPU.PhysicalGPU myGPU in myPhysicalGPUs)
|
||||
{
|
||||
Console.WriteLine($"PhysicalGPU ToString: {myGPU.ToString()}");
|
||||
Console.WriteLine($"PhysicalGPU Fullname: {myGPU.FullName}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.ArchitectInformation}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.Board}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.Foundry}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.GPUId}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.GPUType}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.Handle}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.IsQuadro}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.SystemType}");
|
||||
Console.WriteLine($"PhysicalGPU: {myGPU.UsageInformation}");
|
||||
|
||||
// get a list of all physical outputs attached to the GPUs
|
||||
NvAPIWrapper.GPU.GPUOutput[] myGPUOutputs = myGPU.ActiveOutputs;
|
||||
foreach (NvAPIWrapper.GPU.GPUOutput aGPUOutput in myGPUOutputs)
|
||||
{
|
||||
Console.WriteLine($"Device DigitalVibrance control: {aGPUOutput.ToString()}");
|
||||
Console.WriteLine($"Device OutputID : {aGPUOutput.OutputId}");
|
||||
Console.WriteLine($"Device OutputType: {aGPUOutput.OutputType}");
|
||||
Console.WriteLine($"Device DigitalVibranceControl: {aGPUOutput.DigitalVibranceControl}");
|
||||
|
||||
// Figure out the displaydevice attached to the output
|
||||
NvAPIWrapper.Display.DisplayDevice aConnectedDisplayDevice = myGPU.GetDisplayDeviceByOutput(aGPUOutput);
|
||||
Console.WriteLine($"DisplayID: {aConnectedDisplayDevice.DisplayId}");
|
||||
Console.WriteLine($"ConnectionType: {aConnectedDisplayDevice.ConnectionType}");
|
||||
Console.WriteLine($"IsActive: {aConnectedDisplayDevice.IsActive}");
|
||||
Console.WriteLine($"IsAvailble: {aConnectedDisplayDevice.IsAvailable}");
|
||||
Console.WriteLine($"IsCluster: {aConnectedDisplayDevice.IsCluster}");
|
||||
Console.WriteLine($"IsConnected: {aConnectedDisplayDevice.IsConnected}");
|
||||
Console.WriteLine($"IsDynamic: {aConnectedDisplayDevice.IsDynamic}");
|
||||
Console.WriteLine($"IsMultistreamrootnaode: {aConnectedDisplayDevice.IsMultiStreamRootNode}");
|
||||
Console.WriteLine($"IsOSVisible: {aConnectedDisplayDevice.IsOSVisible}");
|
||||
Console.WriteLine($"IsPhysicallyConnected: {aConnectedDisplayDevice.IsPhysicallyConnected}");
|
||||
Console.WriteLine($"IsWFD: {aConnectedDisplayDevice.IsWFD}");
|
||||
Console.WriteLine($"Output: {aConnectedDisplayDevice.Output}");
|
||||
Console.WriteLine($"PhysicalGPU: {aConnectedDisplayDevice.PhysicalGPU}");
|
||||
Console.WriteLine($"ScanOutInformation: {aConnectedDisplayDevice.ScanOutInformation}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"*** A giant list of displaydevices ***");
|
||||
List<NvAPIWrapper.Display.Display> allConnectedDisplays = NvAPIWrapper.Display.Display.GetDisplays().ToList();
|
||||
foreach (NvAPIWrapper.Display.Display availableDisplay in allConnectedDisplays)
|
||||
{
|
||||
Console.WriteLine($"DisplayID: {availableDisplay.DisplayDevice.DisplayId}");
|
||||
Console.WriteLine($"ConnectionType: {availableDisplay.DisplayDevice.ConnectionType}");
|
||||
Console.WriteLine($"IsActive: {availableDisplay.DisplayDevice.IsActive}");
|
||||
Console.WriteLine($"IsAvailble: {availableDisplay.DisplayDevice.IsAvailable}");
|
||||
Console.WriteLine($"IsCluster: {availableDisplay.DisplayDevice.IsCluster}");
|
||||
Console.WriteLine($"IsConnected: {availableDisplay.DisplayDevice.IsConnected}");
|
||||
Console.WriteLine($"IsDynamic: {availableDisplay.DisplayDevice.IsDynamic}");
|
||||
Console.WriteLine($"IsMultistreamrootnaode: {availableDisplay.DisplayDevice.IsMultiStreamRootNode}");
|
||||
Console.WriteLine($"IsOSVisible: {availableDisplay.DisplayDevice.IsOSVisible}");
|
||||
Console.WriteLine($"IsPhysicallyConnected: {availableDisplay.DisplayDevice.IsPhysicallyConnected}");
|
||||
Console.WriteLine($"IsWFD: {availableDisplay.DisplayDevice.IsWFD}");
|
||||
Console.WriteLine($"Output: {availableDisplay.DisplayDevice.Output}");
|
||||
Console.WriteLine($"PhysicalGPU: {availableDisplay.DisplayDevice.PhysicalGPU}");
|
||||
Console.WriteLine($"ScanOutInformation: {availableDisplay.DisplayDevice.ScanOutInformation}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* var bytes = display.DisplayDevice.PhysicalGPU.ReadEDIDData(display.DisplayDevice.Output);
|
||||
DisplayName = new EDID(bytes).Descriptors
|
||||
.Where(descriptor => descriptor is StringDescriptor)
|
||||
.Cast<StringDescriptor>()
|
||||
.FirstOrDefault(descriptor => descriptor.Type == StringDescriptorType.MonitorName)?.Value;
|
||||
*/
|
||||
|
||||
Console.WriteLine($"### All Unavailable Displays ###");
|
||||
List<WindowsDisplayAPI.UnAttachedDisplay> allDisconnectedDisplays = WindowsDisplayAPI.UnAttachedDisplay.GetUnAttachedDisplays().ToList();
|
||||
foreach (WindowsDisplayAPI.UnAttachedDisplay unavailableDisplay in allDisconnectedDisplays)
|
||||
{
|
||||
Console.WriteLine($"DevicePath: {unavailableDisplay.DevicePath}");
|
||||
Console.WriteLine($"DeviceKey: {unavailableDisplay.DeviceKey}");
|
||||
Console.WriteLine($"DeviceName: {unavailableDisplay.Adapter.DeviceName}");
|
||||
Console.WriteLine($"DisplayFullName: {unavailableDisplay.DisplayFullName}");
|
||||
Console.WriteLine($"DisplayName: {unavailableDisplay.DisplayName}");
|
||||
Console.WriteLine($"IsAvail: {unavailableDisplay.IsAvailable}");
|
||||
Console.WriteLine($"IsValid: {unavailableDisplay.IsValid}");
|
||||
if (unavailableDisplay.IsAvailable)
|
||||
Console.WriteLine($"");
|
||||
}
|
||||
|
||||
Console.WriteLine($"### All Available Displays ###");
|
||||
List<WindowsDisplayAPI.Display> allWindowsConnectedDisplays = WindowsDisplayAPI.Display.GetDisplays().ToList();
|
||||
foreach (WindowsDisplayAPI.Display availableDisplay in allWindowsConnectedDisplays)
|
||||
{
|
||||
Console.WriteLine($"DevicePath: {availableDisplay.DevicePath}");
|
||||
Console.WriteLine($"DeviceKey: {availableDisplay.DeviceKey}");
|
||||
Console.WriteLine($"DeviceName: {availableDisplay.Adapter.DeviceName}");
|
||||
Console.WriteLine($"DisplayFullName: {availableDisplay.DisplayFullName}");
|
||||
Console.WriteLine($"DisplayName: {availableDisplay.DisplayName}");
|
||||
Console.WriteLine($"IsAvail: {availableDisplay.IsAvailable}");
|
||||
Console.WriteLine($"IsValid: {availableDisplay.IsValid}");
|
||||
if (availableDisplay.IsAvailable)
|
||||
Console.WriteLine($"");
|
||||
}
|
||||
|
||||
|
||||
|
||||
IEnumerable<WindowsDisplayAPI.Display> currentDisplays = WindowsDisplayAPI.Display.GetDisplays();
|
||||
foreach (WindowsDisplayAPI.Display availableDisplay in currentDisplays)
|
||||
{
|
||||
Console.WriteLine($"DsiplayName: {availableDisplay.DisplayName}");
|
||||
if (availableDisplay.IsAvailable)
|
||||
Console.WriteLine($"");
|
||||
}
|
||||
|
||||
// Find the list of TargetDisplays we currently have from the currentprofile
|
||||
List<string> availableDevicePaths = new List<string>();
|
||||
ProfileViewport[] availableViewports = ProfileRepository.CurrentProfile.Viewports;
|
||||
|
||||
foreach (ProfileViewport availableViewport in availableViewports)
|
||||
{
|
||||
WindowsDisplayAPI.DisplayConfig.PathInfo pathInfo = availableViewport.ToPathInfo();
|
||||
//pathInfo.TargetsInfo;
|
||||
foreach (ProfileViewportTargetDisplay realTD in availableViewport.TargetDisplays)
|
||||
{
|
||||
string devicePath = realTD.DevicePath;
|
||||
availableDevicePaths.Add(devicePath);
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no viewports, then return false
|
||||
if (Viewports.Length == 0)
|
||||
return false;
|
||||
|
||||
|
||||
Console.WriteLine($"-----Getting the possible mosiac Grid topologies ");
|
||||
NvAPIWrapper.Mosaic.GridTopology[] possibleMosaicTopologies = NvAPIWrapper.Mosaic.GridTopology.GetGridTopologies();
|
||||
foreach (NvAPIWrapper.Mosaic.GridTopology mosaicTopology in possibleMosaicTopologies)
|
||||
{
|
||||
Console.WriteLine($"Mosaic AcceleratePrimaryDisplay: {mosaicTopology.AcceleratePrimaryDisplay}");
|
||||
Console.WriteLine($"Mosaic ApplyWithBezelCorrectedResolution: {mosaicTopology.ApplyWithBezelCorrectedResolution}");
|
||||
Console.WriteLine($"Mosaic BaseMosaicPanoramic: {mosaicTopology.BaseMosaicPanoramic}");
|
||||
Console.WriteLine($"Mosaic Columns: {mosaicTopology.Columns}");
|
||||
Console.WriteLine($"Mosaic ImmersiveGaming: {mosaicTopology.ImmersiveGaming}");
|
||||
Console.WriteLine($"Mosaic Resolution: {mosaicTopology.Resolution}");
|
||||
Console.WriteLine($"Mosaic Rows: {mosaicTopology.Rows}");
|
||||
|
||||
foreach (NvAPIWrapper.Mosaic.GridTopologyDisplay possibleGridTopologyDisplay in mosaicTopology.Displays)
|
||||
{
|
||||
Console.WriteLine($"Mosaic DisplayId: {possibleGridTopologyDisplay.DisplayDevice.DisplayId}");
|
||||
Console.WriteLine($"Mosaic ConnectionType: {possibleGridTopologyDisplay.DisplayDevice.ConnectionType}");
|
||||
Console.WriteLine($"Mosaic IsActive: {possibleGridTopologyDisplay.DisplayDevice.IsActive}");
|
||||
Console.WriteLine($"Mosaic IsConnected: {possibleGridTopologyDisplay.DisplayDevice.IsConnected}");
|
||||
Console.WriteLine($"Mosaic IsCluster: {possibleGridTopologyDisplay.DisplayDevice.IsCluster}");
|
||||
Console.WriteLine($"Mosaic IsDynamic: {possibleGridTopologyDisplay.DisplayDevice.IsDynamic}");
|
||||
Console.WriteLine($"Mosaic IsOSVisible: {possibleGridTopologyDisplay.DisplayDevice.IsOSVisible}");
|
||||
Console.WriteLine($"Mosaic IsMultiStreamRootNode: {possibleGridTopologyDisplay.DisplayDevice.IsMultiStreamRootNode}");
|
||||
Console.WriteLine($"Mosaic IsPhysicallyConnected: {possibleGridTopologyDisplay.DisplayDevice.IsPhysicallyConnected}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.CloneImportance}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.IsDisplayWarped}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.IsIntensityModified}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.SourceDesktopRectangle}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.SourceToTargetRotation}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.SourceViewPortRectangle}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.TargetDisplayHeight}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.TargetDisplayWidth}");
|
||||
Console.WriteLine($"Mosaic ScanOutInformation CloneImportance: {possibleGridTopologyDisplay.DisplayDevice.ScanOutInformation.TargetViewPortRectangle}");
|
||||
}
|
||||
}
|
||||
|
||||
// Then go through the displays in the profile and check they are made of displays
|
||||
// that currently are available.
|
||||
foreach (ProfileViewport profileViewport in Viewports)
|
||||
{
|
||||
// If there are no TargetDisplays in a viewport, then return false
|
||||
// cause thats invalid
|
||||
if (profileViewport.TargetDisplays.Length == 0)
|
||||
// If this profile has a display that isn't currently available then we need to say it's a no!
|
||||
if (!ProfileRepository.CurrentProfile.ProfileDisplayIdentifiers.Contains(profileDisplayIdentifier))
|
||||
return false;
|
||||
|
||||
// For each profile, we want to make sure all TargetDisplays.DevicePath are in the list of
|
||||
// availableDevicePaths
|
||||
foreach (ProfileViewportTargetDisplay profileViewportTargetDisplay in profileViewport.TargetDisplays)
|
||||
{
|
||||
|
||||
// Check if the profiles are NVIDIA Mosaic Surround profiles
|
||||
if (profileViewportTargetDisplay.SurroundTopology != null)
|
||||
{
|
||||
Console.WriteLine($"ProfileViewportTargetDisplay {profileViewportTargetDisplay.DisplayName} within Profile {Name} is a Mosaic profile");
|
||||
|
||||
bool validMosaicTopology = false;
|
||||
// Ask Nvidia driver if the Mosaic SurroundTopology is possible
|
||||
foreach (NvAPIWrapper.Mosaic.GridTopology mosaicTopology in possibleMosaicTopologies)
|
||||
{
|
||||
// we loop through the list of possible mosaic grid topologies to see if this profile
|
||||
// is in there
|
||||
if (mosaicTopology.Equals(profileViewportTargetDisplay.SurroundTopology.ToGridTopology()))
|
||||
{
|
||||
validMosaicTopology = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (!validMosaicTopology)
|
||||
{
|
||||
Console.WriteLine($"ProfileViewportTargetDisplay {profileViewportTargetDisplay.DisplayName} is NOT a VALID mosaic display");
|
||||
Console.WriteLine($"Profile {Name} is NOT a VALID profile and can be used! It IS NOT possible.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine($"ProfileViewportTargetDisplay {profileViewportTargetDisplay.DisplayName} is a VALID mosaic profile");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"ProfileViewportTargetDisplay {profileViewportTargetDisplay.DisplayName} within Profile {Name} is a normal windows profile");
|
||||
|
||||
// Check this DevicePath is in the list of availableTargetDisplays
|
||||
if (!availableDevicePaths.Contains(profileViewportTargetDisplay.DevicePath))
|
||||
{
|
||||
// profileViewportTargetDisplay is a display that isn't available right now
|
||||
// This means that this profile is currently now possible
|
||||
// So we return that fact to the calling function.
|
||||
Console.WriteLine($"ProfileViewportTargetDisplay {profileViewportTargetDisplay.DisplayName} is NOT a VALID windows display");
|
||||
Console.WriteLine($"Profile {Name} is NOT a VALID profile and can be used! It IS NOT possible.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine($"ProfileViewportTargetDisplay {profileViewportTargetDisplay.DisplayName} is a VALID windows display");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Profile {Name} is a VALID profile and can be used! It IS possible.");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ namespace HeliosPlus.Shared
|
||||
private static string _profileStorageJsonFileName = Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{Version.ToString(2)}.json");
|
||||
private static uint _lastProfileId;
|
||||
private static ProfileItem _currentProfile;
|
||||
private static List<Display> _availableDisplays;
|
||||
private static List<UnAttachedDisplay> _unavailableDisplays;
|
||||
//private static List<Display> _availableDisplays;
|
||||
//private static List<UnAttachedDisplay> _unavailableDisplays;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -403,6 +403,25 @@ namespace HeliosPlus.Shared
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsPossibleProfile(ProfileItem profile)
|
||||
{
|
||||
if (!(_currentProfile is ProfileItem))
|
||||
return false;
|
||||
|
||||
if (!(profile is ProfileItem))
|
||||
return false;
|
||||
|
||||
// Check each display in this profile and make sure it's currently available
|
||||
foreach (string profileDisplayIdentifier in profile.ProfileDisplayIdentifiers)
|
||||
{
|
||||
// If this profile has a display that isn't currently available then we need to say it's a no!
|
||||
if (!_currentProfile.ProfileDisplayIdentifiers.Contains(profileDisplayIdentifier))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool LoadProfiles()
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user