mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Added in partial DRS Setting support
This DRS Support is just reserving a space for the future addition of DRS Settings pulled from the driver. This will allow the recording of settings listed in the 3D Settings within the NVIDIA Control panel.
This commit is contained in:
parent
9a745ea3e7
commit
f8a9ca8e1e
@ -26,8 +26,8 @@ using System.Resources;
|
||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("2.3.1.56")]
|
||||
[assembly: AssemblyFileVersion("2.3.1.56")]
|
||||
[assembly: AssemblyVersion("2.3.1.60")]
|
||||
[assembly: AssemblyFileVersion("2.3.1.60")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
|
@ -479,18 +479,18 @@ namespace DisplayMagician
|
||||
// If there is a error in the JSON format
|
||||
if (ex.HResult == -2146233088)
|
||||
{
|
||||
MessageBox.Show($"The Game Shortcuts file {_shortcutStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.", "Error loading the Game Shortcuts", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
SharedLogger.logger.Error(ex, $"ShortcutRepository/LoadShortcuts: JSONReaderException - The Shortcuts file {_shortcutStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Error(ex, $"ShortcutRepository/LoadShortcuts: JSONReaderException while trying to process the Shortcuts json data file {_shortcutStorageJsonFileName} but JsonConvert threw an exception.");
|
||||
}
|
||||
|
||||
MessageBox.Show($"The Game Shortcuts file {_shortcutStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.", "Error loading the Game Shortcuts", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"ShortcutRepository/LoadShortcuts: Tried to parse the JSON in the {_shortcutStorageJsonFileName} but the JsonConvert threw an exception. There is an error in the Shortcut JSON file!");
|
||||
MessageBox.Show($"The Game Shortcuts file {_shortcutStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.", "Error loading the Game Shortcuts", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
throw new Exception("ShortcutRepository/LoadShortcuts: Tried to parse the JSON in the {_shortcutStorageJsonFileName} but the JsonConvert threw an exception. There is an error in the Shortcut JSON file!");
|
||||
}
|
||||
|
||||
|
@ -685,6 +685,22 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
NV_DESKTOP_COLOR_DEPTH_MAX_VALUE = NV_DESKTOP_COLOR_DEPTH_16BPC_FLOAT_HDR, // must be set to highest enum value
|
||||
}
|
||||
|
||||
public enum NVDRS_SETTING_TYPE
|
||||
{
|
||||
NVDRS_DWORD_TYPE = 0x0,
|
||||
NVDRS_BINARY_TYPE = 0x1,
|
||||
NVDRS_STRING_TYPE = 0x2,
|
||||
NVDRS_WSTRING_TYPE = 0x3,
|
||||
}
|
||||
|
||||
public enum NVDRS_SETTING_LOCATION
|
||||
{
|
||||
NVDRS_CURRENT_PROFILE_LOCATION = 0x0,
|
||||
NVDRS_GLOBAL_PROFILE_LOCATION = 0x1,
|
||||
NVDRS_BASE_PROFILE_LOCATION = 0x2,
|
||||
NVDRS_DEFAULT_PROFILE_LOCATION = 0x3,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum NV_HDR_CAPABILITIES_V2_FLAGS : UInt32
|
||||
{
|
||||
@ -750,6 +766,15 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
ALLOW_INVALID = 0x8,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum NVDRS_GPU_SUPPORT : UInt32
|
||||
{
|
||||
NONE = 0x0,
|
||||
GEFORCE = 0x1,
|
||||
QUADRO = 0x2,
|
||||
NVS = 0x4,
|
||||
}
|
||||
|
||||
// ==================================
|
||||
// STRUCTS
|
||||
// ==================================
|
||||
@ -857,6 +882,81 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NVDRS_PROFILE_V1 : IEquatable<NVDRS_PROFILE_V1>, ICloneable // Note: Version 3 of NV_EDID_V3 structure
|
||||
{
|
||||
public UInt32 Version; //!< Structure version
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (Int32)NVImport.NVAPI_UNICODE_STRING_MAX)]
|
||||
public string ProfileName; // EDID_Data[NV_EDID_DATA_SIZE];
|
||||
public NVDRS_GPU_SUPPORT GpuSupport;
|
||||
public UInt32 IsPredefined;
|
||||
public UInt32 NumofApps;
|
||||
public UInt32 NumofSettings;
|
||||
|
||||
public override bool Equals(object obj) => obj is NVDRS_PROFILE_V1 other && this.Equals(other);
|
||||
|
||||
public bool Equals(NVDRS_PROFILE_V1 other)
|
||||
=> Version == other.Version &&
|
||||
ProfileName == other.ProfileName &&
|
||||
GpuSupport == other.GpuSupport &&
|
||||
IsPredefined == other.IsPredefined &&
|
||||
NumofApps == other.NumofApps &&
|
||||
NumofSettings == other.NumofSettings;
|
||||
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return (Version, ProfileName, GpuSupport, IsPredefined, NumofApps, NumofSettings).GetHashCode();
|
||||
}
|
||||
public static bool operator ==(NVDRS_PROFILE_V1 lhs, NVDRS_PROFILE_V1 rhs) => lhs.Equals(rhs);
|
||||
|
||||
public static bool operator !=(NVDRS_PROFILE_V1 lhs, NVDRS_PROFILE_V1 rhs) => !(lhs == rhs);
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
NVDRS_PROFILE_V1 other = (NVDRS_PROFILE_V1)MemberwiseClone();
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NVDRS_SETTING_V1 : IEquatable<NVDRS_SETTING_V1>, ICloneable // Note: Version 1 of NVDRS_SETTING_V1 structure
|
||||
{
|
||||
public UInt32 Version; //!< Structure version
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (Int32)NVImport.NVAPI_UNICODE_STRING_MAX)]
|
||||
public string SettingName; // EDID_Data[NV_EDID_DATA_SIZE];
|
||||
public UInt32 SettingId;
|
||||
public NVDRS_SETTING_TYPE SettingType;
|
||||
public NVDRS_SETTING_LOCATION SettingLocation;
|
||||
public UInt32 IsCurrentPredefined;
|
||||
public UInt32 IsPredefinedValid;
|
||||
|
||||
public override bool Equals(object obj) => obj is NVDRS_SETTING_V1 other && this.Equals(other);
|
||||
|
||||
public bool Equals(NVDRS_SETTING_V1 other)
|
||||
=> Version == other.Version &&
|
||||
SettingName == other.SettingName &&
|
||||
SettingId == other.SettingId &&
|
||||
SettingType == other.SettingType &&
|
||||
SettingLocation == other.SettingLocation &&
|
||||
IsCurrentPredefined == other.IsCurrentPredefined &&
|
||||
IsPredefinedValid == other.IsPredefinedValid;
|
||||
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return (Version, SettingName, SettingId, SettingType, SettingLocation, IsCurrentPredefined, IsPredefinedValid).GetHashCode();
|
||||
}
|
||||
public static bool operator ==(NVDRS_SETTING_V1 lhs, NVDRS_SETTING_V1 rhs) => lhs.Equals(rhs);
|
||||
|
||||
public static bool operator !=(NVDRS_SETTING_V1 lhs, NVDRS_SETTING_V1 rhs) => !(lhs == rhs);
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
NVDRS_SETTING_V1 other = (NVDRS_SETTING_V1)MemberwiseClone();
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NV_LOGICAL_GPU_DATA_V1 : IEquatable<NV_LOGICAL_GPU_DATA_V1>, ICloneable // Note: Version 1 of NV_BOARD_INFO_V1 structure
|
||||
{
|
||||
|
@ -103,6 +103,27 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
public static bool operator !=(NVIDIA_CUSTOM_DISPLAY_CONFIG lhs, NVIDIA_CUSTOM_DISPLAY_CONFIG rhs) => !(lhs == rhs);
|
||||
}*/
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NVIDIA_DRS_CONFIG : IEquatable<NVIDIA_DRS_CONFIG>
|
||||
{
|
||||
public bool HasDRSSettings;
|
||||
public NVDRS_PROFILE_V1 ProfileInfo;
|
||||
public List<NVDRS_SETTING_V1> DriverSettings;
|
||||
public override bool Equals(object obj) => obj is NVIDIA_DRS_CONFIG other && this.Equals(other);
|
||||
public bool Equals(NVIDIA_DRS_CONFIG other)
|
||||
=> HasDRSSettings == other.HasDRSSettings &&
|
||||
ProfileInfo == other.ProfileInfo &&
|
||||
DriverSettings.SequenceEqual(other.DriverSettings);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (HasDRSSettings, ProfileInfo, DriverSettings).GetHashCode();
|
||||
}
|
||||
public static bool operator ==(NVIDIA_DRS_CONFIG lhs, NVIDIA_DRS_CONFIG rhs) => lhs.Equals(rhs);
|
||||
|
||||
public static bool operator !=(NVIDIA_DRS_CONFIG lhs, NVIDIA_DRS_CONFIG rhs) => !(lhs == rhs);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NVIDIA_PER_ADAPTER_CONFIG : IEquatable<NVIDIA_PER_ADAPTER_CONFIG>
|
||||
{
|
||||
@ -136,6 +157,7 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
public NVIDIA_MOSAIC_CONFIG MosaicConfig;
|
||||
public Dictionary<UInt32, NVIDIA_PER_ADAPTER_CONFIG> PhysicalAdapters;
|
||||
public List<NV_DISPLAYCONFIG_PATH_INFO_V2> DisplayConfigs;
|
||||
public List<NVIDIA_DRS_CONFIG> DRSSettings;
|
||||
// Note: We purposely have left out the DisplayNames from the Equals as it's order keeps changing after each reboot and after each profile swap
|
||||
// and it is informational only and doesn't contribute to the configuration (it's used for generating the Screens structure, and therefore for
|
||||
// generating the profile icon.
|
||||
@ -149,12 +171,13 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
PhysicalAdapters.SequenceEqual(other.PhysicalAdapters) &&
|
||||
MosaicConfig.Equals(other.MosaicConfig) &&
|
||||
DisplayConfigs.SequenceEqual(other.DisplayConfigs) &&
|
||||
DRSSettings.SequenceEqual(other.DRSSettings) &&
|
||||
DisplayIdentifiers.SequenceEqual(other.DisplayIdentifiers);
|
||||
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (IsCloned, MosaicConfig, PhysicalAdapters, DisplayConfigs, DisplayIdentifiers, DisplayNames).GetHashCode();
|
||||
return (IsCloned, MosaicConfig, PhysicalAdapters, DisplayConfigs, DisplayIdentifiers, DRSSettings).GetHashCode();
|
||||
}
|
||||
public static bool operator ==(NVIDIA_DISPLAY_CONFIG lhs, NVIDIA_DISPLAY_CONFIG rhs) => lhs.Equals(rhs);
|
||||
|
||||
@ -308,6 +331,7 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
myDefaultConfig.MosaicConfig.MosaicViewports = new List<NV_RECT[]>();
|
||||
myDefaultConfig.PhysicalAdapters = new Dictionary<UInt32, NVIDIA_PER_ADAPTER_CONFIG>();
|
||||
myDefaultConfig.DisplayConfigs = new List<NV_DISPLAYCONFIG_PATH_INFO_V2>();
|
||||
myDefaultConfig.DRSSettings = new List<NVIDIA_DRS_CONFIG>();
|
||||
myDefaultConfig.DisplayNames = new Dictionary<string, string>();
|
||||
myDefaultConfig.DisplayIdentifiers = new List<string>();
|
||||
myDefaultConfig.IsCloned = false;
|
||||
@ -1003,7 +1027,7 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
|
||||
|
||||
// Time to get the color settings, HDR capabilities and settings for each display
|
||||
bool isNvHdrEnabled = false;
|
||||
//bool isNvHdrEnabled = false;
|
||||
for (int displayIndex = 0; displayIndex < displayCount; displayIndex++)
|
||||
{
|
||||
if (allDisplays)
|
||||
@ -1173,7 +1197,7 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/GetNVIDIADisplayConfig: NvAPI_Disp_HdrColorControl returned OK. HDR mode is set to {hdrColorData.HdrMode.ToString("G")}.");
|
||||
if (hdrColorData.HdrMode != NV_HDR_MODE.OFF)
|
||||
{
|
||||
isNvHdrEnabled = true;
|
||||
//isNvHdrEnabled = true;
|
||||
myDisplay.HasNvHdrEnabled = true;
|
||||
}
|
||||
myDisplay.HdrColorData = hdrColorData;
|
||||
|
@ -747,18 +747,19 @@ namespace DisplayMagicianShared
|
||||
// If there is a error in the JSON format
|
||||
if (ex.HResult == -2146233088)
|
||||
{
|
||||
MessageBox.Show($"The Display Profiles file {_profileStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.", "Error loading the Display Profiles", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
SharedLogger.logger.Error(ex, $"ProfileRepository/LoadProfiles: JSONReaderException - The Display Profiles file {_profileStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Error(ex, $"ProfileRepository/LoadProfiles: JSONReaderException while trying to process the Profiles json data file {_profileStorageJsonFileName} but JsonConvert threw an exception.");
|
||||
}
|
||||
MessageBox.Show($"The Display Profiles file {_profileStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.", "Error loading the Display Profiles", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, $"ProfileRepository/LoadProfiles: Tried to parse the JSON in the {_profileStorageJsonFileName} but the JsonConvert threw an exception.");
|
||||
MessageBox.Show($"The Display Profiles file {_profileStorageJsonFileName} contains a syntax error. Please check the file for correctness with a JSON validator.", "Error loading the Display Profiles", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
// If we have any JSON.net errors, then we need to records them in the logs
|
||||
|
Loading…
Reference in New Issue
Block a user