diff --git a/README.md b/README.md index 8dbb673..7fbd57d 100644 --- a/README.md +++ b/README.md @@ -36,17 +36,11 @@ res = { x = 1920, y = 1080 } windowed = false # vertical sync vsync = false +# auto change to english ime mode +auto_ime = false # unlock all songs unlock_songs = true - [patches.audio] - # wasapi shared mode - wasapi_shared = true - # use asio - asio = false - # asio driver name - asio_driver = "" - [patches.cn_jun_2023] # sync test mode language to attract etc. fix_language = false @@ -56,7 +50,15 @@ unlock_songs = true mode_collabo025 = false # enable ai soshina mode mode_collabo026 = false - + +[audio] +# wasapi shared mode +wasapi_shared = true +# use asio +asio = false +# asio driver name +asio_driver = "" + [card_reader] # enable card reader emulation enabled = true diff --git a/dist/config.toml b/dist/config.toml index 34b379a..a5040e8 100644 --- a/dist/config.toml +++ b/dist/config.toml @@ -11,19 +11,20 @@ version = "auto" res = { x = 1920, y = 1080 } windowed = false vsync = false +auto_ime = false unlock_songs = true - [patches.audio] - wasapi_shared = true - asio = false - asio_driver = "" - [patches.cn_jun_2023] fix_language = false demo_movie = true mode_collabo025 = false mode_collabo026 = false +[audio] +wasapi_shared = true +asio = false +asio_driver = "" + [card_reader] enabled = true diff --git a/src/bnusio.cpp b/src/bnusio.cpp index a6d2fd2..e535c96 100644 --- a/src/bnusio.cpp +++ b/src/bnusio.cpp @@ -3,12 +3,13 @@ #include "patches/patches.h" #include "poll.h" +extern GameVersion version; extern std::vector plugins; extern char accessCode1[21]; -extern char chipId1[33]; extern char accessCode2[21]; +extern char chipId1[33]; extern char chipId2[33]; -extern GameVersion version; +extern bool autoIME; typedef i32 (*callbackAttach) (i32, i32, i32 *); typedef void (*callbackTouch) (i32, i32, u8[168], u64); @@ -162,14 +163,20 @@ bnusio_GetAnalogIn (u8 which) { bool testEnabled = false; int coin_count = 0; bool inited = false; -HWND windowHandle = 0; +HWND windowHandle = nullptr; +HKL currentLayout; u16 __fastcall bnusio_GetCoin (i32 a1) { if (a1 != 1) return coin_count; if (!inited) { - windowHandle = FindWindowA ("nuFoundation.Window", 0); + windowHandle = FindWindowA ("nuFoundation.Window", nullptr); InitializePoll (windowHandle); + if (autoIME) { + currentLayout = GetKeyboardLayout (0); + auto engLayout = LoadKeyboardLayout (TEXT ("00000409"), KLF_ACTIVATE); + ActivateKeyboardLayout (engLayout, KLF_SETFORPROCESS); + } for (auto plugin : plugins) { auto initEvent = GetProcAddress (plugin, "Init"); @@ -253,6 +260,7 @@ bnusio_GetSwIn () { i64 bnusio_Close () { + if (autoIME) ActivateKeyboardLayout (currentLayout, KLF_SETFORPROCESS); for (auto plugin : plugins) { FARPROC exitEvent = GetProcAddress (plugin, "Exit"); if (exitEvent) ((event *)exitEvent) (); diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 738fa17..fd788e8 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -19,6 +19,7 @@ char accessCode1[21] = "00000000000000000001"; char accessCode2[21] = "00000000000000000002"; char chipId1[33] = "00000000000000000000000000000001"; char chipId2[33] = "00000000000000000000000000000002"; +bool autoIME = false; HOOK (i32, ShowMouse, PROC_ADDRESS ("user32.dll", "ShowCursor"), bool) { return originalShowMouse (true); } HOOK (i32, ExitWindows, PROC_ADDRESS ("user32.dll", "ExitWindowsEx")) { ExitProcess (0); } @@ -121,7 +122,10 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) { std::strcat (placeId, "0FF0"); } auto patches = openConfigSection (config, "patches"); - if (patches) version = readConfigString (patches, "version", version); + if (patches) { + version = readConfigString (patches, "version", version); + autoIME = readConfigBool (patches, "auto_ime", autoIME); + } } if (version == "auto") { diff --git a/src/patches/audio.cpp b/src/patches/audio.cpp index 7e3a1bf..73d2a6b 100644 --- a/src/patches/audio.cpp +++ b/src/patches/audio.cpp @@ -42,14 +42,11 @@ Init () { auto configPath = std::filesystem::current_path () / "config.toml"; std::unique_ptr config_ptr (openConfig (configPath), toml_free); if (config_ptr) { - auto patches = openConfigSection (config_ptr.get (), "patches"); - if (patches) { - auto audio = openConfigSection (patches, "audio"); - if (audio) { - wasapiShared = readConfigBool (audio, "wasapi_shared", wasapiShared); - asio = readConfigBool (audio, "asio", asio); - asioDriver = readConfigString (audio, "asio_driver", asioDriver); - } + auto audio = openConfigSection (config_ptr.get (), "audio"); + if (audio) { + wasapiShared = readConfigBool (audio, "wasapi_shared", wasapiShared); + asio = readConfigBool (audio, "asio", asio); + asioDriver = readConfigString (audio, "asio_driver", asioDriver); } }