Fix WiiU builds with LTO enabled
For some reason, LTO affects how `ReadVPAD` handles failure, causing it to spam gamepad button inputs. With proper error-checking, this is fixed.
This commit is contained in:
parent
38ea875e11
commit
470a51219e
1 changed files with 44 additions and 45 deletions
|
@ -18,16 +18,18 @@ void ControllerBackend_Deinit(void)
|
|||
|
||||
bool ControllerBackend_GetJoystickStatus(bool **buttons, unsigned int *button_count, short **axes, unsigned int *axis_count)
|
||||
{
|
||||
VPADReadError vpad_error;
|
||||
VPADStatus vpad_status;
|
||||
VPADRead(VPAD_CHAN_0, &vpad_status, 1, &vpad_error);
|
||||
|
||||
static bool button_buffer[27];
|
||||
static short axis_buffer[4];
|
||||
|
||||
*buttons = button_buffer;
|
||||
*axes = axis_buffer;
|
||||
|
||||
*button_count = sizeof(button_buffer) / sizeof(button_buffer[0]);
|
||||
*axis_count = sizeof(axis_buffer) / sizeof(axis_buffer[0]);
|
||||
|
||||
VPADStatus vpad_status;
|
||||
if (VPADRead(VPAD_CHAN_0, &vpad_status, 1, NULL) == 1)
|
||||
{
|
||||
//////////////////////////
|
||||
// Handle button inputs //
|
||||
//////////////////////////
|
||||
|
@ -60,8 +62,6 @@ bool ControllerBackend_GetJoystickStatus(bool **buttons, unsigned int *button_co
|
|||
button_buffer[25] = vpad_status.hold & VPAD_STICK_L_EMULATION_UP;
|
||||
button_buffer[26] = vpad_status.hold & VPAD_STICK_L_EMULATION_DOWN;
|
||||
|
||||
*buttons = button_buffer;
|
||||
|
||||
////////////////////////
|
||||
// Handle axis inputs //
|
||||
////////////////////////
|
||||
|
@ -70,8 +70,7 @@ bool ControllerBackend_GetJoystickStatus(bool **buttons, unsigned int *button_co
|
|||
axis_buffer[1] = (short)(vpad_status.leftStick.y * -0x7FFF);
|
||||
axis_buffer[2] = (short)(vpad_status.rightStick.x * 0x7FFF);
|
||||
axis_buffer[3] = (short)(vpad_status.rightStick.y * -0x7FFF);
|
||||
|
||||
*axes = axis_buffer;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue