wiiu/input: Use raw for touchscreen and check for VPADRead errors

This commit is contained in:
rw-r-r-0644 2018-09-18 21:12:43 +02:00 committed by Ash Logan
parent cbefaaa74a
commit bbb8f558cc

View File

@ -136,37 +136,33 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
static int16_t x2_old = 0; static int16_t x2_old = 0;
static int16_t y2_old = 0; static int16_t y2_old = 0;
static uint32_t hold_old = 0;
uint32_t changed;
VPADStatus vpad; VPADStatus vpad;
VPADReadError error; VPADReadError error;
VPADTouchData tpdata;
VPADRead(VPAD_CHAN_0, &vpad, 1, &error); VPADRead(VPAD_CHAN_0, &vpad, 1, &error);
if (error != VPAD_READ_SUCCESS)
return;
// touchscreen // touchscreen
VPADGetTPCalibratedPoint(0, &tpdata, &vpad.tpFiltered1); if (vpad.tpFiltered1.touched) {
if (tpdata.touched) {
// Send an initial touch // Send an initial touch
SDL_SendTouch(0, 0, SDL_TRUE, SDL_SendTouch(0, 0, SDL_TRUE,
(float) tpdata.x / 1280.0f, (float) vpad.tpFiltered1.x / 4096.0f,
(float) tpdata.y / 720.0f, 1); (float) (4096 - vpad.tpFiltered1.y) / 4096.0f, 1);
// Always send the motion // Always send the motion
SDL_SendTouchMotion(0, 0, SDL_SendTouchMotion(0, 0,
(float) tpdata.x / 1280.0f, (float) vpad.tpFiltered1.x / 4096.0f,
(float) tpdata.y / 720.0f, 1); (float) (4096 - vpad.tpFiltered1.y) / 4096.0f, 1);
// Update old values // Update old values
last_touch_x = tpdata.x; last_touch_x = vpad.tpFiltered1.x;
last_touch_y = tpdata.y; last_touch_y = vpad.tpFiltered1.y;
last_touched = 1; last_touched = 1;
} else if (last_touched) { } else if (last_touched) {
// Finger released from screen // Finger released from screen
SDL_SendTouch(0, 0, SDL_FALSE, SDL_SendTouch(0, 0, SDL_FALSE,
(float) last_touch_x / 1280.0f, (float) last_touch_x / 4096.0f,
(float) last_touch_y / 720.0f, 1); (float) (4096 - last_touch_y) / 4096.0f, 1);
} }
// axys // axys
@ -193,19 +189,12 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
} }
// buttons // buttons
changed = vpad.hold ^ hold_old; for(int i = 0; i < joystick->nbuttons; i++)
hold_old = vpad.hold; if (vpad.trigger & vpad_button_map[i])
if (!changed) { SDL_PrivateJoystickButton(joystick, (Uint8)i, SDL_PRESSED);
return; for(int i = 0; i < joystick->nbuttons; i++)
} if (vpad.release & vpad_button_map[i])
for(int i = 0; i < joystick->nbuttons; i++) { SDL_PrivateJoystickButton(joystick, (Uint8)i, SDL_RELEASED);
if (changed & vpad_button_map[i]) {
SDL_PrivateJoystickButton(
joystick, (Uint8) i,
(Uint8) ((vpad.hold & vpad_button_map[i]) ? SDL_PRESSED : SDL_RELEASED)
);
}
}
} }
} }