ref: 0218402222a912b1f0ed036436727e4efa95db1f
parent: b00e65b90beebc47b463582f48b52431f8bf5bb6
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Jan 4 14:41:04 EST 2020
Fully-initialise the JOYSTICK_STATUS struct This matches the vanilla behaviour.
--- a/src/Input.cpp
+++ b/src/Input.cpp
@@ -60,11 +60,14 @@
if (joystick == NULL)
return FALSE;
+ // The original Input.cpp assumed there were 32 buttons (because of DirectInput's 'DIJOYSTATE' struct)
int numButtons = SDL_JoystickNumButtons(joystick);
if (numButtons > 32)
numButtons = 32;
- for (int i = 0; i < numButtons; ++i)
+ // Read whatever buttons actually exist
+ int i;
+ for (i = 0; i < numButtons; ++i)
{
if (SDL_JoystickGetButton(joystick, i) != 0)
status->bButton[i] = TRUE;
@@ -71,6 +74,10 @@
else
status->bButton[i] = FALSE;
}
+
+ // Blank the buttons that do not
+ for (; i < 32; ++i)
+ status->bButton[i] = FALSE;
status->bDown = FALSE;
status->bRight = FALSE;
--
⑨