From 1847ab85d83674e67afa377dc41416d423b6ca83 Mon Sep 17 00:00:00 2001 From: BroGamer <64546358+BroGamer4256@users.noreply.github.com> Date: Mon, 20 Jun 2022 06:57:31 +1200 Subject: [PATCH] Add exit keybind --- dist/keyconfig.toml | 2 ++ src/dllmain.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/keyconfig.toml b/dist/keyconfig.toml index f8ed4c4..17b4a01 100644 --- a/dist/keyconfig.toml +++ b/dist/keyconfig.toml @@ -1,3 +1,5 @@ +EXIT = [ "ESCAPE" ] + TEST = [ "F1" ] SERVICE = [ "F2" ] DEBUG_UP = [ "UPARROW" ] diff --git a/src/dllmain.c b/src/dllmain.c index d6e38a4..bf544da 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -21,6 +21,7 @@ HOOK_DYNAMIC (i32, __stdcall, ShowMouse, i32 show) { return originalShowMouse (t #define DRUM_HIT 20000 #define IF_HIT(bind) return IsButtonTapped (bind) ? DRUM_HIT : 0 +struct Keybindings EXIT = { .keycodes = { VK_ESCAPE } }; struct Keybindings COIN_ADD = { .keycodes = { VK_RETURN }, .buttons = { SDL_CONTROLLER_BUTTON_START } }; struct Keybindings TEST = { .keycodes = { VK_F1 } }; struct Keybindings SERVICE = { .keycodes = { VK_F2 } }; @@ -76,6 +77,8 @@ HOOK_DYNAMIC (u16, __fastcall, GetCoin, i32 a1) { toml_table_t *config = openConfig (configPath ("keyconfig.toml")); if (config) { + SetConfigValue (config, "EXIT", &EXIT); + SetConfigValue (config, "TEST", &TEST); SetConfigValue (config, "SERVICE", &SERVICE); SetConfigValue (config, "DEBUG_UP", &DEBUG_UP); @@ -100,11 +103,12 @@ HOOK_DYNAMIC (u16, __fastcall, GetCoin, i32 a1) { } UpdatePoll (windowHandle); - if (IsButtonTapped (COIN_ADD)) { + if (IsButtonTapped (COIN_ADD)) coin_count++; - } if (IsButtonTapped (TEST)) testEnabled = !testEnabled; + if (IsButtonTapped(EXIT)) + ExitProcess(0); } return coin_count; }