diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-12-16 14:41:46 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-12-16 14:41:46 +0100 |
commit | 59c715475d9099520bc8e3e7412319458f226e95 (patch) | |
tree | 3be9fbe08293a9ce0f34203a930a86ac799a6082 | |
parent | a99ebf38db2dbdd76e3347441a5aa5a3de05b873 (diff) |
fix oversight regarding hotkey joystick buttons. also prevent triggering the lid command a billion times in a row with a joystick button.
-rw-r--r-- | src/Config.cpp | 4 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 20 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/Config.cpp b/src/Config.cpp index c4a81b1..f0c7c4c 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 84bbb94..cd350f7 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 |