Engine/lib/sdl/src/joystick/SDL_gamecontroller.c
/*
 * Helper function to determine pre-calculated offset to certain joystick mappings
 */
Helper function to determine pre-calculated offset to certain joystick mappings
Helper function to determine pre - calculated offset to certain joystick mappings
ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
{
    SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
    ControllerMapping_t *mapping;
    mapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
#if SDL_JOYSTICK_XINPUT
    if (!mapping && SDL_SYS_IsXInputGamepad_DeviceIndex(device_index)) {
        mapping = s_pXInputMapping;
    }
#endif
#if defined(SDL_JOYSTICK_EMSCRIPTEN)
    if (!mapping && s_pEmscriptenMapping) {
        mapping = s_pEmscriptenMapping;
    }
#endif
#ifdef __LINUX__
    if (!mapping) {
        const char *name = SDL_JoystickNameForIndex(device_index);
        if (name) {
            if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
                SDL_bool existing;
                mapping = SDL_PrivateAddMappingForGUID(jGUID,
"none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
                              &existing);
            }
        }
    }
#endif 
    if (!mapping) {
        const char *name = SDL_JoystickNameForIndex(device_index);
        if (name) {
            if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box")) {
                mapping = s_pXInputMapping;
            }
        }
    }
    return mapping;
}
ControllerMapping_t * SDL_PrivateGetControllerMapping ( int device_index ) { SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID ( device_index ) ; ControllerMapping_t * mapping ; mapping = SDL_PrivateGetControllerMappingForGUID ( & jGUID ) ; #if SDL_JOYSTICK_XINPUT if ( ! mapping && SDL_SYS_IsXInputGamepad_DeviceIndex ( device_index ) ) { mapping = s_pXInputMapping ; } #endif #if defined ( SDL_JOYSTICK_EMSCRIPTEN ) if ( ! mapping && s_pEmscriptenMapping ) { mapping = s_pEmscriptenMapping ; } #endif #ifdef __LINUX__ if ( ! mapping ) { const char * name = SDL_JoystickNameForIndex ( device_index ) ; if ( name ) { if ( SDL_strstr ( name , " " ) ) { SDL_bool existing ; mapping = SDL_PrivateAddMappingForGUID ( jGUID , " " , & existing ) ; } } } #endif if ( ! mapping ) { const char * name = SDL_JoystickNameForIndex ( device_index ) ; if ( name ) { if ( SDL_strstr ( name , " " ) || SDL_strstr ( name , " " ) ) { mapping = s_pXInputMapping ; } } } return mapping ; }
Helper function to determine pre-calculated offset to certain joystick mappings
Helper function to determine pre - calculated offset to certain joystick mappings
/* The Linux driver xpad.c maps the wireless dpad to buttons */ /* __LINUX__ */