Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added official HDR support and Processor Affinity #463

Open
wants to merge 1 commit into
base: netcore
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions unlockfps_nc/Model/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public class Config
public bool UsePowerSave { get; set; }
public bool SuspendLoad { get; set; }
public bool UseMobileUI { get; set; }
public bool UseHDR { get; set; }

public int FPSTarget { get; set; } = 120;
public int CustomResX { get; set; } = 1920;
public int CustomResY { get; set; } = 1080;
public int MonitorNum { get; set; } = 1;
public int Priority { get; set; } = 3;
public int Affinity { get; set; } = 0;

public List<string> DllList { get; set; } = new();
}
Expand Down
15 changes: 14 additions & 1 deletion unlockfps_nc/Service/ProcessService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -115,6 +116,13 @@ private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hWnd, int
Native.GetWindowThreadProcessId(hWnd, out var pid);
_gameInForeground = pid == _gamePid;

if (_config.Affinity != 0)
{
Process proc = Process.GetProcessById((int)pid);
long affinityMask = _config.Affinity;
proc.ProcessorAffinity = (IntPtr)affinityMask;
}

if (!_config.UsePowerSave)
return;

Expand All @@ -139,6 +147,11 @@ private async Task Worker()
uint creationFlag = _config.SuspendLoad ? 4u : 0u;
var gameFolder = Path.GetDirectoryName(_config.GamePath);

if (_config.UseHDR)
{
Registry.SetValue("HKEY_CURRENT_USER\\Software\\miHoYo\\Genshin Impact", "WINDOWS_HDR_ON_h3132281285", 1);
}

if (!Native.CreateProcess(_config.GamePath, BuildCommandLine(), IntPtr.Zero, IntPtr.Zero, false, creationFlag, IntPtr.Zero, gameFolder, ref si, out var pi))
{
MessageBox.Show(
Expand Down
Loading