minor joystick corrections

This commit is contained in:
dborth 2009-06-30 06:14:45 +00:00
parent 1268f79f9e
commit 6478c23656

View file

@ -86,7 +86,7 @@ typedef struct joystick_hwdata_t
joystick_paddata gamecube; joystick_paddata gamecube;
joystick_wpaddata wiimote; joystick_wpaddata wiimote;
}; };
}joystick_hwdata; } joystick_hwdata;
static const u32 sdl_buttons_wii[] = static const u32 sdl_buttons_wii[] =
{ {
@ -190,7 +190,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
return(-1); return(-1);
} }
SDL_memset(joystick->hwdata, 0, sizeof(joystick_hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(joystick_hwdata));
if((joystick->index < 4) && (__jspad_enabled)) if((joystick->index < 4) && (__jswpad_enabled))
{ {
if(joystick->index < __numwiijoysticks) if(joystick->index < __numwiijoysticks)
{ {
@ -477,8 +477,9 @@ static void _HandleGCJoystickUpdate(SDL_Joystick* joystick)
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{ {
if(!joystick) if(!joystick || !joystick->hwdata)
return; return;
switch(((joystick_hwdata*)(joystick->hwdata))->type) switch(((joystick_hwdata*)(joystick->hwdata))->type)
{ {
case 0: case 0:
@ -497,7 +498,9 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
/* Function to close a joystick after use */ /* Function to close a joystick after use */
void SDL_SYS_JoystickClose(SDL_Joystick *joystick) void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{ {
if (joystick->hwdata != NULL) if(!joystick || !joystick->hwdata) // joystick already closed
return;
SDL_free(joystick->hwdata); SDL_free(joystick->hwdata);
/* Clear callback again */ /* Clear callback again */