From 8cf85c522726e52abbf5e3dfcc24d30de13e5790 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sun, 7 Nov 2021 20:49:21 +1300 Subject: [PATCH] Added empty DisplayConfig and CustomDisplays to Display Profiles Added empty DisplayConfig dictionary and CustomDisplays list to the Display Profiles JSON format, as I'm going to need it in a while when I add the integer scaling. --- DisplayMagician/Properties/AssemblyInfo.cs | 4 +- DisplayMagician/UIForms/ShortcutForm.cs | 4 +- DisplayMagicianShared/NVIDIA/NVAPI.cs | 39 +++++++++++++++++++ DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs | 32 ++++++++++++++- 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/DisplayMagician/Properties/AssemblyInfo.cs b/DisplayMagician/Properties/AssemblyInfo.cs index 466bad3..28d77a1 100644 --- a/DisplayMagician/Properties/AssemblyInfo.cs +++ b/DisplayMagician/Properties/AssemblyInfo.cs @@ -26,8 +26,8 @@ using System.Resources; [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] // Version information -[assembly: AssemblyVersion("2.1.0.195")] -[assembly: AssemblyFileVersion("2.1.0.195")] +[assembly: AssemblyVersion("2.1.0.196")] +[assembly: AssemblyFileVersion("2.1.0.196")] [assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: CLSCompliant(true)] diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index e0a8991..305a0ea 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -68,8 +68,8 @@ namespace DisplayMagician.UIForms { InitializeComponent(); Program.AppSplashScreen = new LoadingForm(); - Program.AppSplashScreen.Title = "Preparing game images..."; - Program.AppSplashScreen.Description = "Preparing game images before showing you the Shortcut information. You will be able to swap your shortcut icon to any image you want, or choose one from a list."; + Program.AppSplashScreen.Title = "Preparing images..."; + Program.AppSplashScreen.Description = "Preparing images before showing you the Shortcut information. You will be able to swap your shortcut icon to any image you want, or choose one from a list."; var splashThread = new Thread(new ThreadStart( () => Application.Run(Program.AppSplashScreen))); splashThread.SetApartmentState(ApartmentState.STA); diff --git a/DisplayMagicianShared/NVIDIA/NVAPI.cs b/DisplayMagicianShared/NVIDIA/NVAPI.cs index 0487025..7c4cf7f 100644 --- a/DisplayMagicianShared/NVIDIA/NVAPI.cs +++ b/DisplayMagicianShared/NVIDIA/NVAPI.cs @@ -1964,6 +1964,45 @@ namespace DisplayMagicianShared.NVIDIA public static bool operator !=(NV_COLOR_DATA_V5 lhs, NV_COLOR_DATA_V5 rhs) => !(lhs == rhs); } + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct NV_CUSTOM_DISPLAY_V1 : IEquatable + { + public UInt32 Version; //!< Version of this structure + public UInt32 Width; //!< Source surface(source mode) width + public UInt32 Height; //!< Source surface(source mode) height + public UInt32 Depth; //!< Source surface color depth."0" means all 8/16/32bpp + public NV_FORMAT ColorFormat; //!< Color format (optional) + public NV_VIEWPORTF SourcePartition; //!< For multimon support, should be set to (0,0,1.0,1.0) for now. + public float XRatio; //!< Horizontal scaling ratio + public float YRatio; //!< Vertical scaling ratio + public NV_TIMING Timing; //!< Timing used to program TMDS/DAC/LVDS/HDMI/TVEncoder, etc. + public UInt32 Flags; //!< If set to 1, it means a hardware modeset without OS update + + // Gets a boolean value indicating that a hardware mode-set without OS update should be performed. + public bool IsHardwareModeSetOnly => Flags.GetBit(0); + + public override bool Equals(object obj) => obj is NV_CUSTOM_DISPLAY_V1 other && this.Equals(other); + public bool Equals(NV_CUSTOM_DISPLAY_V1 other) + => Version == other.Version && + Width == other.Width && + Height == other.Height && + Depth == other.Depth && + ColorFormat == other.ColorFormat && + SourcePartition == other.SourcePartition && + XRatio == other.XRatio && + YRatio == other.YRatio && + Timing == other.Timing && + Flags == other.Flags; + + public override Int32 GetHashCode() + { + return (Version, Width, Height, Depth, ColorFormat, SourcePartition, XRatio, YRatio, Timing, Flags).GetHashCode(); + } + public static bool operator ==(NV_CUSTOM_DISPLAY_V1 lhs, NV_CUSTOM_DISPLAY_V1 rhs) => lhs.Equals(rhs); + + public static bool operator !=(NV_CUSTOM_DISPLAY_V1 lhs, NV_CUSTOM_DISPLAY_V1 rhs) => !(lhs == rhs); + } + // ================================== // NVImport Class // ================================== diff --git a/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs b/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs index b294655..8475386 100644 --- a/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs +++ b/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs @@ -88,12 +88,33 @@ namespace DisplayMagicianShared.NVIDIA public static bool operator !=(NVIDIA_COLOR_CONFIG lhs, NVIDIA_COLOR_CONFIG rhs) => !(lhs == rhs); } + [StructLayout(LayoutKind.Sequential)] + public struct NVIDIA_CUSTOM_DISPLAY_CONFIG : IEquatable + { + public List CustomDisplay; + + public override bool Equals(object obj) => obj is NVIDIA_CUSTOM_DISPLAY_CONFIG other && this.Equals(other); + public bool Equals(NVIDIA_CUSTOM_DISPLAY_CONFIG other) + => CustomDisplay.SequenceEqual(other.CustomDisplay); + + public override int GetHashCode() + { + return (CustomDisplay).GetHashCode(); + } + public static bool operator ==(NVIDIA_CUSTOM_DISPLAY_CONFIG lhs, NVIDIA_CUSTOM_DISPLAY_CONFIG rhs) => lhs.Equals(rhs); + + public static bool operator !=(NVIDIA_CUSTOM_DISPLAY_CONFIG lhs, NVIDIA_CUSTOM_DISPLAY_CONFIG rhs) => !(lhs == rhs); + } + + [StructLayout(LayoutKind.Sequential)] public struct NVIDIA_DISPLAY_CONFIG : IEquatable { public NVIDIA_MOSAIC_CONFIG MosaicConfig; public NVIDIA_HDR_CONFIG HdrConfig; public NVIDIA_COLOR_CONFIG ColorConfig; + public Dictionary CustomDisplays; + public List DisplayConfigs; // 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. @@ -106,6 +127,8 @@ namespace DisplayMagicianShared.NVIDIA => MosaicConfig.Equals(other.MosaicConfig) && HdrConfig.Equals(other.HdrConfig) && ColorConfig.Equals(other.ColorConfig) && + //CustomDisplays.SequenceEqual(other.CustomDisplays) && + //DisplayConfigs.SequenceEqual(other.DisplayConfigs) && DisplayIdentifiers.SequenceEqual(other.DisplayIdentifiers); public override int GetHashCode() @@ -254,6 +277,8 @@ namespace DisplayMagicianShared.NVIDIA myDefaultConfig.HdrConfig.HdrCapabilities = new Dictionary(); myDefaultConfig.HdrConfig.HdrColorData = new Dictionary(); myDefaultConfig.ColorConfig.ColorData = new Dictionary(); + myDefaultConfig.CustomDisplays = new Dictionary(); + myDefaultConfig.DisplayConfigs = new List(); myDefaultConfig.DisplayNames = new Dictionary(); myDefaultConfig.DisplayIdentifiers = new List(); @@ -631,6 +656,9 @@ namespace DisplayMagicianShared.NVIDIA Dictionary allHdrCapabilities = new Dictionary(); Dictionary allHdrColorData = new Dictionary(); Dictionary allColorData = new Dictionary(); + Dictionary allCustomDisplays = new Dictionary(); + List allDisplayConfigs = new List(); + for (int displayIndex = 0; displayIndex < displayCount; displayIndex++) { if (allDisplays) @@ -811,11 +839,13 @@ namespace DisplayMagicianShared.NVIDIA } } - // Store the HDR information + // Store the information myDisplayConfig.HdrConfig.IsNvHdrEnabled = isNvHdrEnabled; myDisplayConfig.HdrConfig.HdrCapabilities = allHdrCapabilities; myDisplayConfig.HdrConfig.HdrColorData = allHdrColorData; myDisplayConfig.ColorConfig.ColorData = allColorData; + myDisplayConfig.CustomDisplays = allCustomDisplays; + myDisplayConfig.DisplayConfigs = allDisplayConfigs; } }