Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed building joystick code on Android

  • Loading branch information
slouken committed Nov 27, 2012
1 parent 195db31 commit 74a2079db49322284bc216dee2a78fb63b0c5ba7
Showing with 48 additions and 5 deletions.
  1. +48 −5 src/joystick/android/SDL_sysjoystick.c
@@ -43,14 +43,12 @@ static const char *accelerometerName = "Android accelerometer";
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 @@ SDL_SYS_JoystickName(int index)
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 @@ SDL_SYS_JoystickQuit(void)
{
}

/* 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: */

0 comments on commit 74a2079

Please sign in to comment.