fullscreen & enhance auto_ime & language & several clean up & remove dxgi (seems will cause strange behavior only if you included it)

This commit is contained in:
ptmaster
2024-12-30 23:21:12 +08:00
parent 899445a09c
commit 6a4814b931
11 changed files with 137 additions and 101 deletions
+49 -2
View File
@@ -24,13 +24,17 @@ char accessCode2[21] = "00000000000000000002";
char chipId1[33] = "00000000000000000000000000000001";
char chipId2[33] = "00000000000000000000000000000002";
bool windowed = false;
bool autoIme = false;
bool autoIme = true;
bool jpLayout = false;
bool cursor = true;
bool emulateUsio = true;
bool emulateCardReader = true;
bool emulateQr = true;
bool acceptInvalidCards = false;
HKL currentLayout = nullptr;
i32 xRes = 1920;
i32 yRes = 1080;
bool vsync = false;
std::string logLevelStr = "INFO";
bool logToFile = true;
@@ -189,6 +193,11 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
if (const auto graphics = openConfigSection (config, "graphics")) {
windowed = readConfigBool (graphics, "windowed", windowed);
cursor = readConfigBool (graphics, "cursor", cursor);
if (auto res = openConfigSection (graphics, "res")) {
xRes = static_cast<i32> (readConfigInt (res, "x", xRes));
yRes = static_cast<i32> (readConfigInt (res, "y", yRes));
}
vsync = readConfigBool (graphics, "vsync", vsync);
}
if (const auto keyboard = openConfigSection (config, "keyboard")) {
autoIme = readConfigBool (keyboard, "auto_ime", autoIme);
@@ -201,6 +210,43 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
}
}
auto activeWindow = GetActiveWindow();
HMONITOR monitor = MonitorFromWindow(activeWindow, MONITOR_DEFAULTTONEAREST);
// Get the logical width and height of the monitor
MONITORINFOEX monitorInfoEx;
monitorInfoEx.cbSize = sizeof(monitorInfoEx);
GetMonitorInfo(monitor, &monitorInfoEx);
auto cxLogical = monitorInfoEx.rcMonitor.right - monitorInfoEx.rcMonitor.left;
auto cyLogical = monitorInfoEx.rcMonitor.bottom - monitorInfoEx.rcMonitor.top;
// Get the physical width and height of the monitor
DEVMODE devMode;
devMode.dmSize = sizeof(devMode);
devMode.dmDriverExtra = 0;
EnumDisplaySettings(monitorInfoEx.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
auto cxPhysical = devMode.dmPelsWidth;
auto cyPhysical = devMode.dmPelsHeight;
// Calculate the scaling factor
auto horizontalScale = (static_cast<double> (cxPhysical) / static_cast<double> (cxLogical));
auto verticalScale = (static_cast<double> (cyPhysical) / static_cast<double> (cyLogical));
if (windowed) {
xRes = (int)(xRes / horizontalScale);
yRes = (int)(yRes / verticalScale);
} else {
xRes = cxLogical;
yRes = cyLogical;
}
LogMessage (LogLevel::INFO, "Boot with {} mode ({}x{})", windowed ? "window" : "fullscreen", xRes, yRes);
if (autoIme) {
currentLayout = GetKeyboardLayout (0);
auto engLayout = LoadKeyboardLayout (TEXT ("00000409"), KLF_ACTIVATE);
ActivateKeyboardLayout (engLayout, KLF_SETFORPROCESS);
LogMessage (LogLevel::DEBUG, "Initial change KeyboardLayout {}", LOWORD(engLayout));
}
// Update the logger with the level read from config file.
InitializeLogger (GetLogLevel (logLevelStr), logToFile);
LogMessage (LogLevel::INFO, "Application started.");
@@ -264,11 +310,12 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
patches::Scanner::Init ();
patches::Audio::Init ();
patches::Dxgi::Init ();
// patches::Dxgi::Init ();
patches::AmAuth::Init ();
patches::Language::Init ();
patches::TestMode::Init ();
patches::LayeredFs::Init ();
// patches::UnlimitSong::Init ();
std::chrono::duration<double> duration = std::chrono::high_resolution_clock::now() - start;
LogMessage (LogLevel::INFO, "==== Finished Loading patches! using: {:.2f}ms", duration.count () * 1000);