Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed building joystick code on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 27, 2012
1 parent 195db31 commit 74a2079
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions src/joystick/android/SDL_sysjoystick.c
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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.