1
1
mirror of synced 2025-01-23 15:02:13 +01:00

Add wait_period to config.toml

and delete keyconfig class
This commit is contained in:
esuo1198 2023-10-21 22:10:52 +09:00
parent e21c9992f9
commit 155ea338b8
6 changed files with 63 additions and 84 deletions

5
dist/config.toml vendored
View File

@ -9,4 +9,7 @@ vsync = false
[qr]
card = ""
data = { serial = "", type = 0, song_no = [] }
data = { serial = "", type = 0, song_no = [] }
[drum]
wait_period = 4

View File

@ -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',

View File

@ -1,7 +1,6 @@
#include "helpers.h"
#include "poll.h"
#include "patches/patches.h"
#include "keyconfig.h"
#include "constants.h"
extern std::vector<HMODULE> 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

View File

@ -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);
}
}
}

View File

@ -1,3 +0,0 @@
namespace KeyConfig {
void Init();
}

View File

@ -119,7 +119,7 @@ Init () {
}
// Move various files to current directory
auto amHandle = reinterpret_cast<uintptr_t> (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);