Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
418 changes: 211 additions & 207 deletions .gitignore

Large diffs are not rendered by default.

89 changes: 86 additions & 3 deletions vibrance.GUI/AMD/AmdDynamicVibranceProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,88 @@ public void SetNeverChangeColorSettings(bool neverChangeColorSettings)
_vibranceInfo.neverChangeColorSettings = neverChangeColorSettings;
}

public void SetProfileToggleEnabled(bool profileToggleEnabled)
{
_vibranceInfo.isProfileToggleEnabled = profileToggleEnabled;
_vibranceInfo.isProfileToggleOn = true;
}

public void SetProfileToggleState(bool isProfileToggleOn)
{
_vibranceInfo.isProfileToggleOn = isProfileToggleOn;
}

public bool IsProfileToggleEnabled()
{
return _vibranceInfo.isProfileToggleEnabled;
}

public bool IsProfileToggleOn()
{
return _vibranceInfo.isProfileToggleOn;
}

public void ApplyProfileToggle(IntPtr windowHandle, string processName, bool isProfileToggleOn)
{
if (_applicationSettings.Count == 0)
{
return;
}

ApplicationSetting applicationSetting = _applicationSettings.FirstOrDefault(x => string.Equals(x.Name, processName, StringComparison.OrdinalIgnoreCase));
if (applicationSetting == null)
{
return;
}

Screen screen = Screen.FromHandle(windowHandle);
if (screen == null)
{
return;
}

_gameScreen = screen;

if (isProfileToggleOn)
{
if (_vibranceInfo.userVibranceSettingDefault != applicationSetting.IngameLevel)
{
if (_vibranceInfo.affectPrimaryMonitorOnly)
{
_amdAdapter.SetSaturationOnDisplay(applicationSetting.IngameLevel, screen.DeviceName);
}
else
{
_amdAdapter.SetSaturationOnAllDisplays(applicationSetting.IngameLevel);
}
}

if (_vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == false &&
DeviceGammaRampHelper.IsGammaRampEqualToWindowsValues(_vibranceInfo, applicationSetting) == false)
{
DeviceGammaRampHelper.SetGammaRamp(screen, applicationSetting.Gamma, applicationSetting.Brightness, applicationSetting.Contrast);
_vibranceInfo.isColorSettingApplied = true;
}
}
else
{
_amdAdapter.SetSaturationOnAllDisplays(_vibranceInfo.userVibranceSettingDefault);

if (_vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == true)
{
if (_vibranceInfo.affectPrimaryMonitorOnly && _gameScreen != null && _gameScreen.DeviceName.Equals(screen.DeviceName))
{
DeviceGammaRampHelper.SetGammaRamp(_gameScreen, _vibranceInfo.userColorSettings.brightness, _vibranceInfo.userColorSettings.contrast, _vibranceInfo.userColorSettings.gamma);
}
else
{
Screen.AllScreens.ToList().ForEach(currentScreen => DeviceGammaRampHelper.SetGammaRamp(currentScreen, _vibranceInfo.userColorSettings.brightness, _vibranceInfo.userColorSettings.contrast, _vibranceInfo.userColorSettings.gamma));
}
_vibranceInfo.isColorSettingApplied = false;
}
}
}

public void SetWindowsColorSettings(int brightness, int contrast, int gamma)
{
_vibranceInfo.userColorSettings.brightness = brightness;
Expand Down Expand Up @@ -158,14 +240,15 @@ private void OnWinEventHook(object sender, WinEventHookEventArgs e)
{
if (_applicationSettings.Count > 0)
{
bool shouldApplyProfileSettings = !_vibranceInfo.isProfileToggleEnabled || _vibranceInfo.isProfileToggleOn;
ApplicationSetting applicationSetting = _applicationSettings.FirstOrDefault(x => string.Equals(x.Name, e.ProcessName, StringComparison.OrdinalIgnoreCase));
if (applicationSetting != null)
{
Screen screen = Screen.FromHandle(e.Handle);
_gameScreen = screen;

//apply application specific saturation
if (_vibranceInfo.userVibranceSettingDefault != applicationSetting.IngameLevel)
if (shouldApplyProfileSettings && _vibranceInfo.userVibranceSettingDefault != applicationSetting.IngameLevel)
{
if (_vibranceInfo.affectPrimaryMonitorOnly)
{
Expand All @@ -188,7 +271,7 @@ private void OnWinEventHook(object sender, WinEventHookEventArgs e)
}

//test if color settings change is needed
if (_vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == false &&
if (shouldApplyProfileSettings && _vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == false &&
DeviceGammaRampHelper.IsGammaRampEqualToWindowsValues(_vibranceInfo, applicationSetting) == false)
{
DeviceGammaRampHelper.SetGammaRamp(screen, applicationSetting.Gamma, applicationSetting.Brightness, applicationSetting.Contrast);
Expand Down Expand Up @@ -247,4 +330,4 @@ private static void PerformResolutionChange(Screen screen, ResolutionModeWrapper
ResolutionHelper.ChangeResolutionEx(resolutionSettings, screen.DeviceName);
}
}
}
}
2 changes: 1 addition & 1 deletion vibrance.GUI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<configuration>
<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup>
</configuration>
73 changes: 69 additions & 4 deletions vibrance.GUI/FodyWeavers.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,39 @@
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX86Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinArm64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
Expand All @@ -43,6 +68,16 @@
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
Expand All @@ -53,6 +88,11 @@
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableEventSubscription" type="xs:boolean">
<xs:annotation>
<xs:documentation>The attach method no longer subscribes to the `AppDomain.AssemblyResolve` (.NET 4.x) and `AssemblyLoadContext.Resolving` (.NET 6.0+) events.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
Expand All @@ -73,14 +113,39 @@
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinX86Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinX64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinArm64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
Expand Down
98 changes: 96 additions & 2 deletions vibrance.GUI/NVIDIA/NvidiaDynamicVibranceProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ private static void OnWinEventHook(object sender, WinEventHookEventArgs e)
{
if (_applicationSettings.Count > 0)
{
bool shouldApplyProfileSettings = !_vibranceInfo.isProfileToggleEnabled || _vibranceInfo.isProfileToggleOn;
ApplicationSetting applicationSetting = _applicationSettings.FirstOrDefault(x => string.Equals(x.Name, e.ProcessName, StringComparison.OrdinalIgnoreCase));
if (applicationSetting != null)
{
Expand All @@ -206,7 +207,7 @@ private static void OnWinEventHook(object sender, WinEventHookEventArgs e)
_gameScreen = screen;

//test if digital vibrance change is needed
if (!equalsDVCLevel(displayHandle, applicationSetting.IngameLevel))
if (shouldApplyProfileSettings && !equalsDVCLevel(displayHandle, applicationSetting.IngameLevel))
{
_vibranceInfo.defaultHandle = displayHandle;
setDVCLevel(_vibranceInfo.defaultHandle, applicationSetting.IngameLevel);
Expand All @@ -223,7 +224,7 @@ private static void OnWinEventHook(object sender, WinEventHookEventArgs e)
}

//test if color settings change is needed
if (_vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == false &&
if (shouldApplyProfileSettings && _vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == false &&
DeviceGammaRampHelper.IsGammaRampEqualToWindowsValues(_vibranceInfo, applicationSetting) == false)
{
DeviceGammaRampHelper.SetGammaRamp(screen, applicationSetting.Gamma, applicationSetting.Brightness, applicationSetting.Contrast);
Expand Down Expand Up @@ -345,6 +346,99 @@ public void SetNeverChangeColorSettings(bool neverChangeColorSettings)
_vibranceInfo.neverChangeColorSettings = neverChangeColorSettings;
}

public void SetProfileToggleEnabled(bool profileToggleEnabled)
{
_vibranceInfo.isProfileToggleEnabled = profileToggleEnabled;
_vibranceInfo.isProfileToggleOn = true;
}

public void SetProfileToggleState(bool isProfileToggleOn)
{
_vibranceInfo.isProfileToggleOn = isProfileToggleOn;
}

public bool IsProfileToggleEnabled()
{
return _vibranceInfo.isProfileToggleEnabled;
}

public bool IsProfileToggleOn()
{
return _vibranceInfo.isProfileToggleOn;
}

public void ApplyProfileToggle(IntPtr windowHandle, string processName, bool isProfileToggleOn)
{
if (_applicationSettings.Count == 0)
{
return;
}

ApplicationSetting applicationSetting = _applicationSettings.FirstOrDefault(x => string.Equals(x.Name, processName, StringComparison.OrdinalIgnoreCase));
if (applicationSetting == null)
{
return;
}

int displayHandle = GetApplicationDisplayHandle(windowHandle);
if (displayHandle == -1)
{
return;
}

Screen screen = Screen.FromHandle(windowHandle);
if (screen == null)
{
return;
}

_gameScreen = screen;

if (isProfileToggleOn)
{
if (!equalsDVCLevel(displayHandle, applicationSetting.IngameLevel))
{
_vibranceInfo.defaultHandle = displayHandle;
setDVCLevel(_vibranceInfo.defaultHandle, applicationSetting.IngameLevel);
}

if (_vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == false &&
DeviceGammaRampHelper.IsGammaRampEqualToWindowsValues(_vibranceInfo, applicationSetting) == false)
{
DeviceGammaRampHelper.SetGammaRamp(screen, applicationSetting.Gamma, applicationSetting.Brightness, applicationSetting.Contrast);
_vibranceInfo.isColorSettingApplied = true;
}
}
else
{
if (_vibranceInfo.affectPrimaryMonitorOnly && !equalsDVCLevel(_vibranceInfo.defaultHandle, _vibranceInfo.userVibranceSettingDefault))
{
if (_gameScreen != null && !_gameScreen.DeviceName.Equals(screen.DeviceName))
{
return;
}
setDVCLevel(_vibranceInfo.defaultHandle, _vibranceInfo.userVibranceSettingDefault);
}
else if (!_vibranceInfo.affectPrimaryMonitorOnly && !_vibranceInfo.displayHandles.TrueForAll(handle => equalsDVCLevel(handle, _vibranceInfo.userVibranceSettingDefault)))
{
_vibranceInfo.displayHandles.ForEach(handle => setDVCLevel(handle, _vibranceInfo.userVibranceSettingDefault));
}

if (_vibranceInfo.neverChangeColorSettings == false && _vibranceInfo.isColorSettingApplied == true)
{
if (_vibranceInfo.affectPrimaryMonitorOnly && _gameScreen != null && _gameScreen.DeviceName.Equals(screen.DeviceName))
{
DeviceGammaRampHelper.SetGammaRamp(_gameScreen, _vibranceInfo.userColorSettings.brightness, _vibranceInfo.userColorSettings.contrast, _vibranceInfo.userColorSettings.gamma);
}
else
{
Screen.AllScreens.ToList().ForEach(currentScreen => DeviceGammaRampHelper.SetGammaRamp(currentScreen, _vibranceInfo.userColorSettings.brightness, _vibranceInfo.userColorSettings.contrast, _vibranceInfo.userColorSettings.gamma));
}
_vibranceInfo.isColorSettingApplied = false;
}
}
}

public void SetWindowsColorSettings(int brightness, int contrast, int gamma)
{
_vibranceInfo.userColorSettings.brightness = brightness;
Expand Down
Loading