Fully-initialise the JOYSTICK_STATUS struct
This matches the vanilla behaviour.
This commit is contained in:
parent
b00e65b90b
commit
0218402222
1 changed files with 8 additions and 1 deletions
|
@ -60,11 +60,14 @@ BOOL GetJoystickStatus(JOYSTICK_STATUS *status)
|
||||||
if (joystick == NULL)
|
if (joystick == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
// The original Input.cpp assumed there were 32 buttons (because of DirectInput's 'DIJOYSTATE' struct)
|
||||||
int numButtons = SDL_JoystickNumButtons(joystick);
|
int numButtons = SDL_JoystickNumButtons(joystick);
|
||||||
if (numButtons > 32)
|
if (numButtons > 32)
|
||||||
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)
|
if (SDL_JoystickGetButton(joystick, i) != 0)
|
||||||
status->bButton[i] = TRUE;
|
status->bButton[i] = TRUE;
|
||||||
|
@ -72,6 +75,10 @@ BOOL GetJoystickStatus(JOYSTICK_STATUS *status)
|
||||||
status->bButton[i] = FALSE;
|
status->bButton[i] = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Blank the buttons that do not
|
||||||
|
for (; i < 32; ++i)
|
||||||
|
status->bButton[i] = FALSE;
|
||||||
|
|
||||||
status->bDown = FALSE;
|
status->bDown = FALSE;
|
||||||
status->bRight = FALSE;
|
status->bRight = FALSE;
|
||||||
status->bUp = FALSE;
|
status->bUp = FALSE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue