Source/ThirdParty/SDL/src/joystick/SDL_gamecontroller.c
/**
 * Get the SDL joystick layer binding for this controller button mapping
 */
Get the SDL joystick layer binding for this controller button mapping
Get the SDL joystick layer binding for this controller button mapping
SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
{
    SDL_GameControllerButtonBind bind;
    SDL_memset(&bind, 0x0, sizeof(bind));
    if (!gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID)
        return bind;
    if (gamecontroller->mapping.buttons[button] >= 0) {
        bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON;
        bind.value.button = gamecontroller->mapping.buttons[button];
    } else if (gamecontroller->mapping.axesasbutton[button] >= 0) {
        bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS;
        bind.value.axis = gamecontroller->mapping.axesasbutton[button];
    } else if (gamecontroller->mapping.hatasbutton[button].hat >= 0) {
        bind.bindType = SDL_CONTROLLER_BINDTYPE_HAT;
        bind.value.hat.hat = gamecontroller->mapping.hatasbutton[button].hat;
        bind.value.hat.hat_mask = gamecontroller->mapping.hatasbutton[button].mask;
    }
    return bind;
}
SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton ( SDL_GameController * gamecontroller , SDL_GameControllerButton button ) { SDL_GameControllerButtonBind bind ; SDL_memset ( & bind , 0x0 , sizeof ( bind ) ) ; if ( ! gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID ) return bind ; if ( gamecontroller -> mapping . buttons [ button ] >= 0 ) { bind . bindType = SDL_CONTROLLER_BINDTYPE_BUTTON ; bind . value . button = gamecontroller -> mapping . buttons [ button ] ; } else if ( gamecontroller -> mapping . axesasbutton [ button ] >= 0 ) { bind . bindType = SDL_CONTROLLER_BINDTYPE_AXIS ; bind . value . axis = gamecontroller -> mapping . axesasbutton [ button ] ; } else if ( gamecontroller -> mapping . hatasbutton [ button ] . hat >= 0 ) { bind . bindType = SDL_CONTROLLER_BINDTYPE_HAT ; bind . value . hat . hat = gamecontroller -> mapping . hatasbutton [ button ] . hat ; bind . value . hat . hat_mask = gamecontroller -> mapping . hatasbutton [ button ] . mask ; } return bind ; }
Get the SDL joystick layer binding for this controller button mapping
Get the SDL joystick layer binding for this controller button mapping