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.
This commit is contained in:
Terry MacDonald 2021-11-07 20:49:21 +13:00
parent a1f9bb5e2f
commit 8cf85c5227
4 changed files with 74 additions and 5 deletions

View File

@ -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)]

View File

@ -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);

View File

@ -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<NV_CUSTOM_DISPLAY_V1>
{
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
// ==================================

View File

@ -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<NVIDIA_CUSTOM_DISPLAY_CONFIG>
{
public List<NV_CUSTOM_DISPLAY_V1> 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<NVIDIA_DISPLAY_CONFIG>
{
public NVIDIA_MOSAIC_CONFIG MosaicConfig;
public NVIDIA_HDR_CONFIG HdrConfig;
public NVIDIA_COLOR_CONFIG ColorConfig;
public Dictionary<UInt32, NVIDIA_CUSTOM_DISPLAY_CONFIG> CustomDisplays;
public List<NV_DISPLAYCONFIG_PATH_INFO_V2> 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<uint, NV_HDR_CAPABILITIES_V2>();
myDefaultConfig.HdrConfig.HdrColorData = new Dictionary<uint, NV_HDR_COLOR_DATA_V2>();
myDefaultConfig.ColorConfig.ColorData = new Dictionary<uint, NV_COLOR_DATA_V5>();
myDefaultConfig.CustomDisplays = new Dictionary<uint, NVIDIA_CUSTOM_DISPLAY_CONFIG>();
myDefaultConfig.DisplayConfigs = new List<NV_DISPLAYCONFIG_PATH_INFO_V2>();
myDefaultConfig.DisplayNames = new Dictionary<uint, string>();
myDefaultConfig.DisplayIdentifiers = new List<string>();
@ -631,6 +656,9 @@ namespace DisplayMagicianShared.NVIDIA
Dictionary<UInt32, NV_HDR_CAPABILITIES_V2> allHdrCapabilities = new Dictionary<UInt32, NV_HDR_CAPABILITIES_V2>();
Dictionary<UInt32, NV_HDR_COLOR_DATA_V2> allHdrColorData = new Dictionary<UInt32, NV_HDR_COLOR_DATA_V2>();
Dictionary<UInt32, NV_COLOR_DATA_V5> allColorData = new Dictionary<UInt32, NV_COLOR_DATA_V5>();
Dictionary<UInt32, NVIDIA_CUSTOM_DISPLAY_CONFIG> allCustomDisplays = new Dictionary<UInt32, NVIDIA_CUSTOM_DISPLAY_CONFIG>();
List<NV_DISPLAYCONFIG_PATH_INFO_V2> allDisplayConfigs = new List<NV_DISPLAYCONFIG_PATH_INFO_V2>();
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;
}
}