fix oversight regarding hotkey joystick buttons. also prevent triggering the lid command a billion times in a row with a joystick button.

This commit is contained in:
StapleButter
2018-12-16 14:41:46 +01:00
parent a99ebf38db
commit 59c715475d
2 changed files with 16 additions and 8 deletions

View File

@ -126,7 +126,7 @@ ConfigEntry ConfigFile[] =
{"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 1, NULL, 0}, {"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 1, NULL, 0},
{"AudioVolume", 0, &AudioVolume, 255, NULL, 0}, {"AudioVolume", 0, &AudioVolume, 256, NULL, 0},
{"MicInputType", 0, &MicInputType, 1, NULL, 0}, {"MicInputType", 0, &MicInputType, 1, NULL, 0},
{"MicWavPath", 1, MicWavPath, 0, "", 511}, {"MicWavPath", 1, MicWavPath, 0, "", 511},

View File

@ -299,6 +299,8 @@ void MicCallback(void* data, Uint8* stream, int len)
bool JoyButtonPressed(int btnid, int njoybuttons, Uint8* joybuttons, Uint32 hat) bool JoyButtonPressed(int btnid, int njoybuttons, Uint8* joybuttons, Uint32 hat)
{ {
if (btnid < 0) return false;
bool pressed; bool pressed;
if (btnid == 0x101) // up if (btnid == 0x101) // up
pressed = (hat & SDL_HAT_UP); pressed = (hat & SDL_HAT_UP);
@ -393,6 +395,8 @@ int EmuThreadFunc(void* burp)
LidStatus = false; LidStatus = false;
MicCommand = 0; MicCommand = 0;
bool lastlidcmd = false;
Uint8* joybuttons = NULL; int njoybuttons = 0; Uint8* joybuttons = NULL; int njoybuttons = 0;
if (Joystick) if (Joystick)
{ {
@ -430,10 +434,7 @@ int EmuThreadFunc(void* burp)
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
int btnid = Config::JoyMapping[i]; bool pressed = JoyButtonPressed(Config::JoyMapping[i], njoybuttons, joybuttons, hat);
if (btnid < 0) continue;
bool pressed = JoyButtonPressed(btnid, njoybuttons, joybuttons, hat);
if (i == 4) // right if (i == 4) // right
pressed = pressed || (axisX >= 16384); pressed = pressed || (axisX >= 16384);
@ -449,9 +450,16 @@ int EmuThreadFunc(void* burp)
if (JoyButtonPressed(Config::HKJoyMapping[HK_Lid], njoybuttons, joybuttons, hat)) if (JoyButtonPressed(Config::HKJoyMapping[HK_Lid], njoybuttons, joybuttons, hat))
{ {
LidStatus = !LidStatus; if (!lastlidcmd)
LidCommand = true; {
LidStatus = !LidStatus;
LidCommand = true;
lastlidcmd = true;
}
} }
else
lastlidcmd = false;
if (JoyButtonPressed(Config::HKJoyMapping[HK_Mic], njoybuttons, joybuttons, hat)) if (JoyButtonPressed(Config::HKJoyMapping[HK_Mic], njoybuttons, joybuttons, hat))
MicCommand |= 2; MicCommand |= 2;
else else