src/joystick/android/SDL_sysjoystick.c
changeset 6707 70eeb7e3ec2f
parent 6696 73e2ad636f6e
child 6744 4ac2bb6dc80c
equal deleted inserted replaced
6706:b9f5fb1e78b5 6707:70eeb7e3ec2f
    44 SDL_SYS_JoystickInit(void)
    44 SDL_SYS_JoystickInit(void)
    45 {
    45 {
    46     return (1);
    46     return (1);
    47 }
    47 }
    48 
    48 
       
    49 int SDL_SYS_NumJoysticks()
       
    50 {
       
    51     return 1;
       
    52 }
       
    53 
       
    54 void SDL_SYS_JoystickDetect()
       
    55 {
       
    56 }
       
    57 
       
    58 SDL_bool SDL_SYS_JoystickNeedsPolling()
       
    59 {
       
    60     return SDL_FALSE;
       
    61 }
       
    62 
    49 /* Function to get the device-dependent name of a joystick */
    63 /* Function to get the device-dependent name of a joystick */
    50 const char *
    64 const char *
    51 SDL_SYS_JoystickNameForIndex(int index)
    65 SDL_SYS_JoystickNameForDeviceIndex(int device_index)
    52 {
    66 {
    53     if (index == 0) {
    67     return accelerometerName;
    54         return accelerometerName;
    68 }
    55     } else {
    69 
    56         SDL_SetError("No joystick available with that index");
    70 /* Function to perform the mapping from device index to the instance id for this index */
    57         return (NULL);
    71 SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
    58     }
    72 {
       
    73     return device_index;
    59 }
    74 }
    60 
    75 
    61 /* Function to open a joystick for use.
    76 /* Function to open a joystick for use.
    62    The joystick to open is specified by the index field of the joystick.
    77    The joystick to open is specified by the index field of the joystick.
    63    This should fill the nbuttons and naxes fields of the joystick structure.
    78    This should fill the nbuttons and naxes fields of the joystick structure.
    76 		SDL_SetError("No joystick available with that index");
    91 		SDL_SetError("No joystick available with that index");
    77 		return (-1);
    92 		return (-1);
    78 	}
    93 	}
    79 }
    94 }
    80 
    95 
       
    96 /* Function to determine is this joystick is attached to the system right now */
       
    97 SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
       
    98 {
       
    99     return SDL_TRUE;
       
   100 }
    81 
   101 
    82 /* Function to update the state of a joystick - called as a device poll.
   102 /* Function to update the state of a joystick - called as a device poll.
    83  * This function shouldn't update the joystick structure directly,
   103  * This function shouldn't update the joystick structure directly,
    84  * but instead should call SDL_PrivateJoystick*() to deliver events
   104  * but instead should call SDL_PrivateJoystick*() to deliver events
    85  * and update joystick device state.
   105  * and update joystick device state.
   109 void
   129 void
   110 SDL_SYS_JoystickQuit(void)
   130 SDL_SYS_JoystickQuit(void)
   111 {
   131 {
   112 }
   132 }
   113 
   133 
   114 /* Function to perform the mapping from device index to the instance id for this index */
   134 JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
   115 SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int index)
       
   116 {
       
   117     return index;
       
   118 }
       
   119 
       
   120 /* Function to determine is this joystick is attached to the system right now */
       
   121 int SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
       
   122 {
       
   123     return 1;
       
   124 }
       
   125 
       
   126 int SDL_SYS_NumJoysticks()
       
   127 {
       
   128     return 1;
       
   129 }
       
   130 
       
   131 int SDL_SYS_JoystickNeedsPolling()
       
   132 {
       
   133     return 0;
       
   134 }
       
   135 
       
   136 void SDL_SYS_JoystickDetect()
       
   137 {
       
   138 }
       
   139 
       
   140 JoystickGUID SDL_SYS_PrivateJoystickGetDeviceGUID( int device_index )
       
   141 {
   135 {
   142     JoystickGUID guid;
   136     JoystickGUID guid;
   143     // the GUID is just the first 16 chars of the name for now
   137     // the GUID is just the first 16 chars of the name for now
   144     const char *name = SDL_SYS_JoystickNameForIndex( device_index );
   138     const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
   145     SDL_zero( guid );
   139     SDL_zero( guid );
   146     SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   140     SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   147     return guid;
   141     return guid;
   148 }
   142 }
   149 
   143 
   150 JoystickGUID SDL_SYS_PrivateJoystickGetGUID(SDL_Joystick * joystick)
   144 JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
   151 {
   145 {
   152     JoystickGUID guid;
   146     JoystickGUID guid;
   153     // the GUID is just the first 16 chars of the name for now
   147     // the GUID is just the first 16 chars of the name for now
   154     const char *name = joystick->name;
   148     const char *name = joystick->name;
   155     SDL_zero( guid );
   149     SDL_zero( guid );
   156     SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   150     SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
   157     return guid;
   151     return guid;
   158 }
   152 }
   159 
   153 
   160 #endif /* SDL_JOYSTICK_NDS */
   154 #endif /* SDL_JOYSTICK_ANDROID */
   161 
   155 
   162 /* vi: set ts=4 sw=4 expandtab: */
   156 /* vi: set ts=4 sw=4 expandtab: */