int SDL_JoystickInit(void) { int status; /* Create the joystick list lock */ if (!SDL_joystick_lock) { SDL_joystick_lock = SDL_CreateMutex(); } /* See if we should allow joystick events while in the background */ SDL_AddHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_JoystickAllowBackgroundEventsChanged, NULL); #if !SDL_EVENTS_DISABLED if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { return -1; } #endif /* !SDL_EVENTS_DISABLED */ status = SDL_SYS_JoystickInit(); if (status >= 0) { status = 0; } return (status); }
/* In case of no mouse available, init a pad ! */ static int PS2_InitPad() { if (SDL_WasInit(SDL_INIT_JOYSTICK)) { return 0; } else { if(SDL_SYS_JoystickInit() > 0) { return 0; } else { return -1; } } }
int SDL_JoystickInit(void) { int arraylen; int status; SDL_numjoysticks = 0; status = SDL_SYS_JoystickInit(); if ( status >= 0 ) { arraylen = (status+1)*sizeof(*SDL_joysticks); SDL_joysticks = (SDL_Joystick **)malloc(arraylen); if ( SDL_joysticks == NULL ) { SDL_numjoysticks = 0; } else { memset(SDL_joysticks, 0, arraylen); SDL_numjoysticks = status; } status = 0; } default_joystick = NULL; return(status); }
int SDL_JoystickInit(void) { int arraylen; int status; SDL_numjoysticks = 0; status = SDL_SYS_JoystickInit(); if ( status >= 0 ) { SDL_allocatedjoysticks = status; arraylen = (SDL_allocatedjoysticks+1)*sizeof(*SDL_joysticks); SDL_joysticks = (SDL_Joystick **)SDL_malloc(arraylen); if ( SDL_joysticks == NULL ) { SDL_numjoysticks = 0; SDL_allocatedjoysticks = 0; } else { SDL_memset(SDL_joysticks, 0, arraylen); SDL_numjoysticks = status; } status = 0; } return(status); }