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,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}

View File

@ -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