Fixed building joystick code on Android
authorSam Lantinga <slouken@libsdl.org>
Mon, 26 Nov 2012 22:02:01 -0800
changeset 6695 ec21e81c62aa
parent 6694 6b277a4ae26a
child 6696 73e2ad636f6e
Fixed building joystick code on Android
src/joystick/android/SDL_sysjoystick.c
--- a/src/joystick/android/SDL_sysjoystick.c	Mon Nov 26 21:55:59 2012 -0800
+++ b/src/joystick/android/SDL_sysjoystick.c	Mon Nov 26 22:02:01 2012 -0800
@@ -43,14 +43,12 @@
 int
 SDL_SYS_JoystickInit(void)
 {
-    SDL_numjoysticks = 1;
-    
     return (1);
 }
 
 /* Function to get the device-dependent name of a joystick */
 const char *
-SDL_SYS_JoystickName(int index)
+SDL_SYS_JoystickNameForIndex(int index)
 {
     if (index == 0) {
         return accelerometerName;
@@ -66,13 +64,12 @@
    It returns 0, or -1 if there is an error.
  */
 int
-SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
+SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int index)
 {
     joystick->nbuttons = 0;
     joystick->nhats = 0;
     joystick->nballs = 0;
     joystick->naxes = 3;
-    joystick->name = accelerometerName;
     return 0;
 }
 
@@ -109,6 +106,52 @@
 {
 }
 
+/* Function to perform the mapping from device index to the instance id for this index */
+SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
+{
+    return index;
+}
+
+/* Function to determine is this joystick is attached to the system right now */
+int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
+{
+    return 1;
+}
+
+int SDL_SYS_NumJoysticks()
+{
+    return 1;
+}
+
+int SDL_SYS_JoystickNeedsPolling()
+{
+    return 0;
+}
+
+void SDL_SYS_JoystickDetect()
+{
+}
+
+JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
+{
+    JoystickGUID guid;
+    // the GUID is just the first 16 chars of the name for now
+    const char *name = SDL_SYS_JoystickNameForIndex( device_index );
+    SDL_zero( guid );
+    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
+    return guid;
+}
+
+JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
+{
+    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;
+}
+
 #endif /* SDL_JOYSTICK_NDS */
 
 /* vi: set ts=4 sw=4 expandtab: */