From 155ea338b85ae04dabddd14c71bfe0901de90b1a Mon Sep 17 00:00:00 2001 From: esuo1198 <54134.es@gmail.com> Date: Sat, 21 Oct 2023 22:10:52 +0900 Subject: [PATCH] Add wait_period to config.toml and delete keyconfig class --- dist/config.toml | 5 ++- meson.build | 1 - src/bnusio.cpp | 78 +++++++++++++++++++++++++++---------- src/keyconfig.cpp | 58 --------------------------- src/keyconfig.h | 3 -- src/patches/jp_nov_2020.cpp | 2 +- 6 files changed, 63 insertions(+), 84 deletions(-) delete mode 100644 src/keyconfig.cpp delete mode 100644 src/keyconfig.h diff --git a/dist/config.toml b/dist/config.toml index 1e36054..d102d16 100644 --- a/dist/config.toml +++ b/dist/config.toml @@ -9,4 +9,7 @@ vsync = false [qr] card = "" -data = { serial = "", type = 0, song_no = [] } \ No newline at end of file +data = { serial = "", type = 0, song_no = [] } + +[drum] +wait_period = 4 \ No newline at end of file diff --git a/meson.build b/meson.build index c6fee5a..e9ab937 100644 --- a/meson.build +++ b/meson.build @@ -51,7 +51,6 @@ library( 'src/dllmain.cpp', 'src/helpers.cpp', 'src/poll.cpp', - 'src/keyconfig.cpp', 'src/bnusio.cpp', 'src/patches/jp_nov_2020.cpp', 'src/patches/cn_jun_2023.cpp', diff --git a/src/bnusio.cpp b/src/bnusio.cpp index 10d6238..ec879b4 100644 --- a/src/bnusio.cpp +++ b/src/bnusio.cpp @@ -1,7 +1,6 @@ #include "helpers.h" #include "poll.h" #include "patches/patches.h" -#include "keyconfig.h" #include "constants.h" extern std::vector plugins; @@ -21,6 +20,26 @@ u64 touchData; callbackAttach attachCallback; i32 *attachData; +Keybindings EXIT = {.keycodes = {VK_ESCAPE}}; +Keybindings TEST = {.keycodes = {VK_F1}}; +Keybindings SERVICE = {.keycodes = {VK_F2}}; +Keybindings DEBUG_UP = {.keycodes = {VK_UP}}; +Keybindings DEBUG_DOWN = {.keycodes = {VK_DOWN}}; +Keybindings DEBUG_ENTER = {.keycodes = {VK_RETURN}}; +Keybindings COIN_ADD = {.keycodes = {VK_RETURN}, .buttons = {SDL_CONTROLLER_BUTTON_START}}; +Keybindings CARD_INSERT_1 = {}; +Keybindings CARD_INSERT_2 = {}; +Keybindings QR_CARD_READ = {}; +Keybindings QR_DATA_READ = {.keycodes = {'Q'}}; +Keybindings P1_LEFT_BLUE = {.keycodes = {'D'}, .axis = {SDL_AXIS_LTRIGGER_DOWN}}; +Keybindings P1_LEFT_RED = {.keycodes = {'F'}, .buttons = {SDL_CONTROLLER_BUTTON_LEFTSTICK}}; +Keybindings P1_RIGHT_RED = {.keycodes = {'J'}, .buttons = {SDL_CONTROLLER_BUTTON_RIGHTSTICK}}; +Keybindings P1_RIGHT_BLUE = {.keycodes = {'K'}, .axis = {SDL_AXIS_RTRIGGER_DOWN}}; +Keybindings P2_LEFT_BLUE = {}; +Keybindings P2_LEFT_RED = {}; +Keybindings P2_RIGHT_RED = {}; +Keybindings P2_RIGHT_BLUE = {}; + namespace bnusio { #define RETURN_FALSE(returnType, functionName, ...) \ returnType functionName (__VA_ARGS__) { return 0; } @@ -71,24 +90,6 @@ bnusio_GetFirmwareVersion () { return 126; } -extern Keybindings EXIT; -extern Keybindings TEST; -extern Keybindings SERVICE; -extern Keybindings DEBUG_UP; -extern Keybindings DEBUG_DOWN; -extern Keybindings DEBUG_ENTER; -extern Keybindings COIN_ADD; -extern Keybindings CARD_INSERT_1; -extern Keybindings CARD_INSERT_2; -extern Keybindings P1_LEFT_BLUE; -extern Keybindings P1_LEFT_RED; -extern Keybindings P1_RIGHT_RED; -extern Keybindings P1_RIGHT_BLUE; -extern Keybindings P2_LEFT_BLUE; -extern Keybindings P2_LEFT_RED; -extern Keybindings P2_RIGHT_RED; -extern Keybindings P2_RIGHT_BLUE; - u16 drumMin = 10000; u16 drumMax = 20000; u16 drumWaitPeriod = 4; @@ -309,6 +310,43 @@ Init () { INSTALL_HOOK (bngrw_attach); INSTALL_HOOK (bngrw_reqWaitTouch); - KeyConfig::Init(); + auto configPath = std::filesystem::current_path () / "config.toml"; + toml_table_t *config = openConfig (configPath); + if (config) { + auto drum = openConfigSection (config, "drum"); + if (drum) { + drumWaitPeriod = readConfigInt (drum, "wait_period", drumWaitPeriod); + } + toml_free (config); + } + + auto keyconfigPath = std::filesystem::current_path () / "keyconfig.toml"; + toml_table_t *keyconfig = openConfig (keyconfigPath); + if (keyconfig) { + SetConfigValue (keyconfig, "EXIT", &EXIT); + + SetConfigValue (keyconfig, "TEST", &TEST); + SetConfigValue (keyconfig, "SERVICE", &SERVICE); + SetConfigValue (keyconfig, "DEBUG_UP", &DEBUG_UP); + SetConfigValue (keyconfig, "DEBUG_DOWN", &DEBUG_DOWN); + SetConfigValue (keyconfig, "DEBUG_ENTER", &DEBUG_ENTER); + + SetConfigValue (keyconfig, "COIN_ADD", &COIN_ADD); + SetConfigValue (keyconfig, "CARD_INSERT_1", &CARD_INSERT_1); + SetConfigValue (keyconfig, "CARD_INSERT_2", &CARD_INSERT_2); + SetConfigValue (keyconfig, "QR_CARD_READ", &QR_CARD_READ); + SetConfigValue (keyconfig, "QR_DATA_READ", &QR_DATA_READ); + + SetConfigValue (keyconfig, "P1_LEFT_BLUE", &P1_LEFT_BLUE); + SetConfigValue (keyconfig, "P1_LEFT_RED", &P1_LEFT_RED); + SetConfigValue (keyconfig, "P1_RIGHT_RED", &P1_RIGHT_RED); + SetConfigValue (keyconfig, "P1_RIGHT_BLUE", &P1_RIGHT_BLUE); + SetConfigValue (keyconfig, "P2_LEFT_BLUE", &P2_LEFT_BLUE); + SetConfigValue (keyconfig, "P2_LEFT_RED", &P2_LEFT_RED); + SetConfigValue (keyconfig, "P2_RIGHT_RED", &P2_RIGHT_RED); + SetConfigValue (keyconfig, "P2_RIGHT_BLUE", &P2_RIGHT_BLUE); + + toml_free (keyconfig); + } } } // namespace bnusio diff --git a/src/keyconfig.cpp b/src/keyconfig.cpp deleted file mode 100644 index 4c2cb59..0000000 --- a/src/keyconfig.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "keyconfig.h" -#include "helpers.h" -#include "poll.h" - -Keybindings EXIT = {.keycodes = {VK_ESCAPE}}; -Keybindings TEST = {.keycodes = {VK_F1}}; -Keybindings SERVICE = {.keycodes = {VK_F2}}; -Keybindings DEBUG_UP = {.keycodes = {VK_UP}}; -Keybindings DEBUG_DOWN = {.keycodes = {VK_DOWN}}; -Keybindings DEBUG_ENTER = {.keycodes = {VK_RETURN}}; -Keybindings COIN_ADD = {.keycodes = {VK_RETURN}, .buttons = {SDL_CONTROLLER_BUTTON_START}}; -Keybindings CARD_INSERT_1 = {}; -Keybindings CARD_INSERT_2 = {}; -Keybindings QR_CARD_READ = {}; -Keybindings QR_DATA_READ = {.keycodes = {'Q'}}; -Keybindings P1_LEFT_BLUE = {.keycodes = {'D'}, .axis = {SDL_AXIS_LTRIGGER_DOWN}}; -Keybindings P1_LEFT_RED = {.keycodes = {'F'}, .buttons = {SDL_CONTROLLER_BUTTON_LEFTSTICK}}; -Keybindings P1_RIGHT_RED = {.keycodes = {'J'}, .buttons = {SDL_CONTROLLER_BUTTON_RIGHTSTICK}}; -Keybindings P1_RIGHT_BLUE = {.keycodes = {'K'}, .axis = {SDL_AXIS_RTRIGGER_DOWN}}; -Keybindings P2_LEFT_BLUE = {}; -Keybindings P2_LEFT_RED = {}; -Keybindings P2_RIGHT_RED = {}; -Keybindings P2_RIGHT_BLUE = {}; - -namespace KeyConfig { - -void -Init() { - auto configPath = std::filesystem::current_path () / "keyconfig.toml"; - toml_table_t *config = openConfig (configPath); - if (config) { - SetConfigValue (config, "EXIT", &EXIT); - - SetConfigValue (config, "TEST", &TEST); - SetConfigValue (config, "SERVICE", &SERVICE); - SetConfigValue (config, "DEBUG_UP", &DEBUG_UP); - SetConfigValue (config, "DEBUG_DOWN", &DEBUG_DOWN); - SetConfigValue (config, "DEBUG_ENTER", &DEBUG_ENTER); - - SetConfigValue (config, "COIN_ADD", &COIN_ADD); - SetConfigValue (config, "CARD_INSERT_1", &CARD_INSERT_1); - SetConfigValue (config, "CARD_INSERT_2", &CARD_INSERT_2); - SetConfigValue (config, "QR_CARD_READ", &QR_CARD_READ); - SetConfigValue (config, "QR_DATA_READ", &QR_DATA_READ); - - SetConfigValue (config, "P1_LEFT_BLUE", &P1_LEFT_BLUE); - SetConfigValue (config, "P1_LEFT_RED", &P1_LEFT_RED); - SetConfigValue (config, "P1_RIGHT_RED", &P1_RIGHT_RED); - SetConfigValue (config, "P1_RIGHT_BLUE", &P1_RIGHT_BLUE); - SetConfigValue (config, "P2_LEFT_BLUE", &P2_LEFT_BLUE); - SetConfigValue (config, "P2_LEFT_RED", &P2_LEFT_RED); - SetConfigValue (config, "P2_RIGHT_RED", &P2_RIGHT_RED); - SetConfigValue (config, "P2_RIGHT_BLUE", &P2_RIGHT_BLUE); - - toml_free (config); - } -} -} \ No newline at end of file diff --git a/src/keyconfig.h b/src/keyconfig.h deleted file mode 100644 index b1a0ac4..0000000 --- a/src/keyconfig.h +++ /dev/null @@ -1,3 +0,0 @@ -namespace KeyConfig { - void Init(); -} \ No newline at end of file diff --git a/src/patches/jp_nov_2020.cpp b/src/patches/jp_nov_2020.cpp index cbd8010..df603ac 100644 --- a/src/patches/jp_nov_2020.cpp +++ b/src/patches/jp_nov_2020.cpp @@ -119,7 +119,7 @@ Init () { } // Move various files to current directory - auto amHandle = reinterpret_cast (GetModuleHandle ("AMFrameWork.dll")); + auto amHandle = (u64) (GetModuleHandle ("AMFrameWork.dll")); WRITE_MEMORY (amHandle + 0x33EF7, u8, 0xEB); WRITE_MEMORY (amHandle + 0x3404A, u8, 0xEB); WRITE_MEMORY (amHandle + 0x34429, u8, 0xEB);