Fix joystick support
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 5a84b95..60c9c04 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -95,6 +95,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = {
#ifdef SDL_JOYSTICK_VIRTUAL
&SDL_VIRTUAL_JoystickDriver,
#endif
+#ifdef SDL_JOYSTICK_VITA
+ &SDL_VITA_JoystickDriver
+#endif
#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
&SDL_DUMMY_JoystickDriver
#endif
diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h
index 1ba6775..b8af118 100644
--- a/src/joystick/SDL_sysjoystick.h
+++ b/src/joystick/SDL_sysjoystick.h
@@ -206,6 +206,7 @@ extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver;
extern SDL_JoystickDriver SDL_WINMM_JoystickDriver;
extern SDL_JoystickDriver SDL_OS2_JoystickDriver;
extern SDL_JoystickDriver SDL_PSP_JoystickDriver;
+extern SDL_JoystickDriver SDL_VITA_JoystickDriver;
#endif /* SDL_sysjoystick_h_ */
diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c
index 151e3f8..2ce1090 100644
--- a/src/joystick/vita/SDL_sysjoystick.c
+++ b/src/joystick/vita/SDL_sysjoystick.c
@@ -90,7 +90,7 @@ static int calc_bezier_y(float t)
* Joystick 0 should be the system default joystick.
* It should return number of joysticks, or -1 on an unrecoverable fatal error.
*/
-int SDL_SYS_JoystickInit(void)
+int VITA_JoystickInit(void)
{
int i;
@@ -129,61 +129,58 @@ int SDL_SYS_JoystickInit(void)
return SDL_numjoysticks;
}
-int SDL_SYS_NumJoysticks()
+int VITA_JoystickGetCount()
{
return SDL_numjoysticks;
}
-void SDL_SYS_JoystickDetect()
+void VITA_JoystickDetect()
{
}
-/* Function to get the device-dependent name of a joystick */
-const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index)
-{
- if (device_index == 1)
- return "PSVita Controller";
-
- if (device_index == 2)
- return "PSVita Controller";
-
- if (device_index == 3)
- return "PSVita Controller";
-
- return "PSVita Controller";
-}
-
/* Function to perform the mapping from device index to the instance id for this index */
-SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
+SDL_JoystickID VITA_JoystickGetDeviceInstanceID(int device_index)
{
return device_index;
}
/* Function to get the device-dependent name of a joystick */
-const char *SDL_SYS_JoystickName(int index)
+const char *VITA_JoystickGetDeviceName(int index)
{
- if (index == 0)
- return "PSVita Controller";
+ if (index == 0)
+ return "PSVita Controller";
- if (index == 1)
- return "PSVita Controller";
+ if (index == 1)
+ return "PSVita Controller";
- if (index == 2)
- return "PSVita Controller";
+ if (index == 2)
+ return "PSVita Controller";
- if (index == 3)
- return "PSVita Controller";
+ if (index == 3)
+ return "PSVita Controller";
SDL_SetError("No joystick available with that index");
return(NULL);
}
+static int
+VITA_JoystickGetDevicePlayerIndex(int device_index)
+{
+ return -1;
+}
+
+static void
+VITA_JoystickSetDevicePlayerIndex(int device_index, int player_index)
+{
+}
+
+
/* Function to open a joystick for use.
The joystick to open is specified by the device index.
This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error.
*/
-int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
+int VITA_JoystickOpen(SDL_Joystick *joystick, int device_index)
{
joystick->nbuttons = sizeof(button_map)/sizeof(*button_map);
joystick->naxes = 4;
@@ -193,18 +190,12 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
return 0;
}
-/* Function to determine if this joystick is attached to the system right now */
-SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
-{
- return SDL_TRUE;
-}
-
/* Function to update the state of a joystick - called as a device poll.
* This function shouldn't update the joystick structure directly,
* but instead should call SDL_PrivateJoystick*() to deliver events
* and update joystick device state.
*/
-void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
+void VITA_JoystickUpdate(SDL_Joystick *joystick)
{
int i;
unsigned int buttons;
@@ -217,11 +208,11 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
static unsigned char old_ry[] = { 0, 0, 0, 0 };
SceCtrlData *pad = NULL;
- int index = (int) SDL_JoystickInstanceID(joystick);
+ int index = (int) SDL_JoystickInstanceID(joystick);
if (index == 0) pad = &pad0;
else if (index == 1) pad = &pad1;
- else if (index == 2) pad = &pad2;
+ else if (index == 2) pad = &pad2;
else if (index == 3) pad = &pad3;
else return;
@@ -275,35 +266,51 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
}
/* Function to close a joystick after use */
-void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+void VITA_JoystickClose(SDL_Joystick *joystick)
{
}
/* Function to perform any system-specific joystick related cleanup */
-void SDL_SYS_JoystickQuit(void)
+void VITA_JoystickQuit(void)
{
}
-SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
+SDL_JoystickGUID VITA_JoystickGetDeviceGUID( int device_index )
{
SDL_JoystickGUID guid;
/* the GUID is just the first 16 chars of the name for now */
- const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
+ const char *name = VITA_JoystickGetDeviceName( device_index );
SDL_zero( guid );
SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
return guid;
}
-SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
+static int
+VITA_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
- SDL_JoystickGUID guid;
- /* the GUID is just the first 16 chars of the name for now */
- const char *name = joystick->name;
- SDL_zero( guid );
- SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
- return guid;
+ return SDL_Unsupported();
}
+
+SDL_JoystickDriver SDL_VITA_JoystickDriver =
+{
+ VITA_JoystickInit,
+ VITA_JoystickGetCount,
+ VITA_JoystickDetect,
+ VITA_JoystickGetDeviceName,
+ VITA_JoystickGetDevicePlayerIndex,
+ VITA_JoystickSetDevicePlayerIndex,
+ VITA_JoystickGetDeviceGUID,
+ VITA_JoystickGetDeviceInstanceID,
+
+ VITA_JoystickOpen,
+ VITA_JoystickRumble,
+ VITA_JoystickUpdate,
+ VITA_JoystickClose,
+ VITA_JoystickQuit,
+};
+
+
#endif /* SDL_JOYSTICK_VITA */
/* vim: ts=4 sw=4