From 59c715475d9099520bc8e3e7412319458f226e95 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Sun, 16 Dec 2018 14:41:46 +0100 Subject: [PATCH] fix oversight regarding hotkey joystick buttons. also prevent triggering the lid command a billion times in a row with a joystick button. --- src/Config.cpp | 4 ++-- src/libui_sdl/main.cpp | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index c4a81b16..f0c7c4c3 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -126,10 +126,10 @@ ConfigEntry ConfigFile[] = {"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 1, NULL, 0}, - {"AudioVolume", 0, &AudioVolume, 255, NULL, 0}, + {"AudioVolume", 0, &AudioVolume, 256, NULL, 0}, {"MicInputType", 0, &MicInputType, 1, NULL, 0}, {"MicWavPath", 1, MicWavPath, 0, "", 511}, - + {"LastROMFolder", 1, LastROMFolder, 0, "", 511}, {"", -1, NULL, 0, NULL, 0} diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 84bbb942..cd350f74 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -299,6 +299,8 @@ void MicCallback(void* data, Uint8* stream, int len) bool JoyButtonPressed(int btnid, int njoybuttons, Uint8* joybuttons, Uint32 hat) { + if (btnid < 0) return false; + bool pressed; if (btnid == 0x101) // up pressed = (hat & SDL_HAT_UP); @@ -393,6 +395,8 @@ int EmuThreadFunc(void* burp) LidStatus = false; MicCommand = 0; + bool lastlidcmd = false; + Uint8* joybuttons = NULL; int njoybuttons = 0; if (Joystick) { @@ -430,10 +434,7 @@ int EmuThreadFunc(void* burp) for (int i = 0; i < 12; i++) { - int btnid = Config::JoyMapping[i]; - if (btnid < 0) continue; - - bool pressed = JoyButtonPressed(btnid, njoybuttons, joybuttons, hat); + bool pressed = JoyButtonPressed(Config::JoyMapping[i], njoybuttons, joybuttons, hat); if (i == 4) // right pressed = pressed || (axisX >= 16384); @@ -449,9 +450,16 @@ int EmuThreadFunc(void* burp) if (JoyButtonPressed(Config::HKJoyMapping[HK_Lid], njoybuttons, joybuttons, hat)) { - LidStatus = !LidStatus; - LidCommand = true; + if (!lastlidcmd) + { + LidStatus = !LidStatus; + LidCommand = true; + lastlidcmd = true; + } } + else + lastlidcmd = false; + if (JoyButtonPressed(Config::HKJoyMapping[HK_Mic], njoybuttons, joybuttons, hat)) MicCommand |= 2; else