Source/ThirdParty/SDL/src/joystick/SDL_gamecontroller.c
/*
 * Event filter to transform joystick events into appropriate game controller ones
 */
Event filter to transform joystick events into appropriate game controller ones
Event filter to transform joystick events into appropriate game controller ones
int
SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state)
{
    int posted;
#if !SDL_EVENTS_DISABLED
    SDL_Event event;
    if (button == SDL_CONTROLLER_BUTTON_INVALID)
        return (0);
    switch (state) {
    case SDL_PRESSED:
        event.type = SDL_CONTROLLERBUTTONDOWN;
        break;
    case SDL_RELEASED:
        event.type = SDL_CONTROLLERBUTTONUP;
        break;
    default:
        return (0);
    }
#endif 
    posted = 0;
#if !SDL_EVENTS_DISABLED
    if (SDL_GetEventState(event.type) == SDL_ENABLE) {
        event.cbutton.which = gamecontroller->joystick->instance_id;
        event.cbutton.button = button;
        event.cbutton.state = state;
        posted = SDL_PushEvent(&event) == 1;
    }
#endif 
    return (posted);
}
int SDL_PrivateGameControllerButton ( SDL_GameController * gamecontroller , SDL_GameControllerButton button , Uint8 state ) { int posted ; #if ! SDL_EVENTS_DISABLED SDL_Event event ; if ( button == SDL_CONTROLLER_BUTTON_INVALID ) return ( 0 ) ; switch ( state ) { case SDL_PRESSED : event . type = SDL_CONTROLLERBUTTONDOWN ; break ; case SDL_RELEASED : event . type = SDL_CONTROLLERBUTTONUP ; break ; default : return ( 0 ) ; } #endif posted = 0 ; #if ! SDL_EVENTS_DISABLED if ( SDL_GetEventState ( event . type ) == SDL_ENABLE ) { event . cbutton . which = gamecontroller -> joystick -> instance_id ; event . cbutton . button = button ; event . cbutton . state = state ; posted = SDL_PushEvent ( & event ) == 1 ; } #endif return ( posted ) ; }
Event filter to transform joystick events into appropriate game controller ones
Event filter to transform joystick events into appropriate game controller ones
/* Invalid state -- bail */ /* !SDL_EVENTS_DISABLED */ /* translate the event, if desired */ /* !SDL_EVENTS_DISABLED */