Vita: fix controls on PSTV with opened IME
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c
index 059b879..994655f 100644
--- a/src/joystick/vita/SDL_sysjoystick.c
+++ b/src/joystick/vita/SDL_sysjoystick.c
@@ -45,26 +45,10 @@ static SceCtrlData pad1 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0
static SceCtrlData pad2 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 };
static SceCtrlData pad3 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 };
-static int port_map[4]= { 0, 2, 3, 4 }; //index: SDL joy number, entry: Vita port number
static int ext_port_map[4]= { 1, 2, 3, 4 }; //index: SDL joy number, entry: Vita port number. For external controllers
static int SDL_numjoysticks = 1;
-static const unsigned int button_map[] = {
- SCE_CTRL_TRIANGLE,
- SCE_CTRL_CIRCLE,
- SCE_CTRL_CROSS,
- SCE_CTRL_SQUARE,
- SCE_CTRL_LTRIGGER,
- SCE_CTRL_RTRIGGER,
- SCE_CTRL_DOWN,
- SCE_CTRL_LEFT,
- SCE_CTRL_UP,
- SCE_CTRL_RIGHT,
- SCE_CTRL_SELECT,
- SCE_CTRL_START
-};
-
static const unsigned int ext_button_map[] = {
SCE_CTRL_TRIANGLE,
SCE_CTRL_CIRCLE,
@@ -247,7 +231,6 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick)
static unsigned char old_lt[] = { 0, 0, 0, 0 };
static unsigned char old_rt[] = { 0, 0, 0, 0 };
SceCtrlData *pad = NULL;
- SDL_bool fallback = SDL_FALSE;
int index = (int) SDL_JoystickInstanceID(joystick);
@@ -258,13 +241,12 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick)
else return;
if (index == 0) {
- if (sceCtrlPeekBufferPositiveExt2(ext_port_map[index], pad, 1) < 0) {
+ if (sceCtrlPeekBufferPositive2(ext_port_map[index], pad, 1) < 0) {
// on vita fallback to port 0
- sceCtrlPeekBufferPositive(port_map[index], pad, 1);
- fallback = SDL_TRUE;
+ sceCtrlPeekBufferPositive2(0, pad, 1);
}
} else {
- sceCtrlPeekBufferPositiveExt2(ext_port_map[index], pad, 1);
+ sceCtrlPeekBufferPositive2(ext_port_map[index], pad, 1);
}
buttons = pad->buttons;
@@ -309,23 +291,12 @@ static void VITA_JoystickUpdate(SDL_Joystick *joystick)
old_buttons[index] = buttons;
if (changed) {
- if (fallback) {
- for (i = 0; i < SDL_arraysize(button_map); i++) {
- if (changed & button_map[i]) {
- SDL_PrivateJoystickButton(
- joystick, i,
- (buttons & button_map[i]) ?
- SDL_PRESSED : SDL_RELEASED);
- }
- }
- } else {
- for (i = 0; i < SDL_arraysize(ext_button_map); i++) {
- if (changed & ext_button_map[i]) {
- SDL_PrivateJoystickButton(
- joystick, i,
- (buttons & ext_button_map[i]) ?
- SDL_PRESSED : SDL_RELEASED);
- }
+ for (i = 0; i < SDL_arraysize(ext_button_map); i++) {
+ if (changed & ext_button_map[i]) {
+ SDL_PrivateJoystickButton(
+ joystick, i,
+ (buttons & ext_button_map[i]) ?
+ SDL_PRESSED : SDL_RELEASED);
}
}
}
@@ -357,7 +328,9 @@ VITA_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16
act.small = high_frequency_rumble / 256;
act.large = low_frequency_rumble / 256;
- sceCtrlSetActuator(ext_port_map[index], &act);
+ if (sceCtrlSetActuator(ext_port_map[index], &act) < 0) {
+ return SDL_Unsupported();
+ }
return 0;
}
@@ -379,7 +352,9 @@ static int
VITA_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
int index = (int) SDL_JoystickInstanceID(joystick);
- sceCtrlSetLightBar(ext_port_map[index], red, green, blue);
+ if (sceCtrlSetLightBar(ext_port_map[index], red, green, blue) < 0) {
+ return SDL_Unsupported();
+ }
return 0;
}