From 4abf0473c23b3578f788b5d535234fa34f976a2f Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 12 Jun 2019 01:12:49 +0200 Subject: [PATCH] add pause/reset hotkeys --- src/libui_sdl/DlgInputConfig.cpp | 12 ++++++-- src/libui_sdl/PlatformConfig.cpp | 4 +++ src/libui_sdl/PlatformConfig.h | 2 ++ src/libui_sdl/main.cpp | 49 +++++++++++++++++++++----------- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/libui_sdl/DlgInputConfig.cpp b/src/libui_sdl/DlgInputConfig.cpp index 7a8a7687..88822753 100644 --- a/src/libui_sdl/DlgInputConfig.cpp +++ b/src/libui_sdl/DlgInputConfig.cpp @@ -64,7 +64,15 @@ char dskeylabels[12][8] = {"A:", "B:", "Select:", "Start:", "Right:", "Left:", " int identity[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; -char hotkeylabels[HK_MAX][32] = {"Close/open lid:", "Microphone:", "Fast forward:", "Fast forward (toggle):"}; +char hotkeylabels[HK_MAX][32] = +{ + "Close/open lid:", + "Microphone:", + "Pause/resume:", + "Reset:", + "Fast forward:", + "Fast forward (toggle):" +}; int openedmask; InputDlgData inputdlg[2]; @@ -319,7 +327,7 @@ Uint32 JoyPoll(Uint32 interval, void* param) { Sint16 axisval = SDL_JoystickGetAxis(joy, i); int diff = abs(axisval - dlg->axes_rest[i]); -printf("axis%d: val=%d, diff=%d\n", i, axisval, diff); + if (dlg->axes_rest[i] < -16384 && axisval >= 0) { dlg->joymap[id] = (oldmap & 0xFFFF) | 0x10000 | (2 << 20) | (i << 24); diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp index ff0ca704..6a9d4b2f 100644 --- a/src/libui_sdl/PlatformConfig.cpp +++ b/src/libui_sdl/PlatformConfig.cpp @@ -92,11 +92,15 @@ ConfigEntry PlatformConfigFile[] = {"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0D, NULL, 0}, {"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], 0x35, NULL, 0}, + {"HKKey_Pause", 0, &HKKeyMapping[HK_Pause], -1, NULL, 0}, + {"HKKey_Reset", 0, &HKKeyMapping[HK_Reset], -1, NULL, 0}, {"HKKey_FastForward", 0, &HKKeyMapping[HK_FastForward], 0x0F, NULL, 0}, {"HKKey_FastForwardToggle", 0, &HKKeyMapping[HK_FastForwardToggle], -1, NULL, 0}, {"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0}, {"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0}, + {"HKJoy_Pause", 0, &HKJoyMapping[HK_Pause], -1, NULL, 0}, + {"HKJoy_Reset", 0, &HKJoyMapping[HK_Reset], -1, NULL, 0}, {"HKJoy_FastForward", 0, &HKJoyMapping[HK_FastForward], -1, NULL, 0}, {"HKJoy_FastForwardToggle", 0, &HKJoyMapping[HK_FastForwardToggle], -1, NULL, 0}, diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h index aaa56d3b..d6eb1514 100644 --- a/src/libui_sdl/PlatformConfig.h +++ b/src/libui_sdl/PlatformConfig.h @@ -25,6 +25,8 @@ enum { HK_Lid = 0, HK_Mic, + HK_Pause, + HK_Reset, HK_FastForward, HK_FastForwardToggle, HK_MAX diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 9edeefc9..9d145176 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -168,6 +168,11 @@ s16* MicWavBuffer; void SetupScreenRects(int width, int height); +void TogglePause(void* blarg); +void Reset(void* blarg); + +void SetupSRAMPath(); + void SaveState(int slot); void LoadState(int slot); void UndoStateLoad(); @@ -881,6 +886,9 @@ int EmuThreadFunc(void* burp) uiQueueMain(UpdateFPSLimit, NULL); } + if (HotkeyPressed(HK_Pause)) uiQueueMain(TogglePause, NULL); + if (HotkeyPressed(HK_Reset)) uiQueueMain(Reset, NULL); + if (EmuRunning == 1) { EmuStatus = 1; @@ -1535,6 +1543,29 @@ void TogglePause(void* blarg) } } +void Reset(void* blarg) +{ + if (!RunningSomething) return; + + EmuRunning = 2; + while (EmuStatus != 2); + + SavestateLoaded = false; + uiMenuItemDisable(MenuItem_UndoStateLoad); + + if (ROMPath[0] == '\0') + NDS::LoadBIOS(); + else + { + SetupSRAMPath(); + NDS::LoadROM(ROMPath, SRAMPath, Config::DirectBoot); + } + + Run(); + + OSD::AddMessage(0, "Reset"); +} + void Stop(bool internal) { EmuRunning = 2; @@ -1917,23 +1948,7 @@ void OnPause(uiMenuItem* item, uiWindow* window, void* blarg) void OnReset(uiMenuItem* item, uiWindow* window, void* blarg) { - if (!RunningSomething) return; - - EmuRunning = 2; - while (EmuStatus != 2); - - SavestateLoaded = false; - uiMenuItemDisable(MenuItem_UndoStateLoad); - - if (ROMPath[0] == '\0') - NDS::LoadBIOS(); - else - { - SetupSRAMPath(); - NDS::LoadROM(ROMPath, SRAMPath, Config::DirectBoot); - } - - Run(); + Reset(NULL); } void OnStop(uiMenuItem* item, uiWindow* window, void* blarg)