/* * 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 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; }
/* * Helper function to determine pre-calculated offset to certain joystick mappings */ ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) { #if SDL_JOYSTICK_XINPUT if (SDL_SYS_IsXInputGamepad_DeviceIndex(device_index) && s_pXInputMapping) { return s_pXInputMapping; } else #endif /* SDL_JOYSTICK_XINPUT */ { SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index); return SDL_PrivateGetControllerMappingForGUID(&jGUID); } }
/* * Helper function to determine pre-calculated offset to certain joystick mappings */ ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) { #if SDL_JOYSTICK_XINPUT if (SDL_SYS_IsXInputGamepad_DeviceIndex(device_index) && s_pXInputMapping) { return s_pXInputMapping; } else #endif #if defined(SDL_JOYSTICK_EMSCRIPTEN) if (s_pEmscriptenMapping) { return s_pEmscriptenMapping; } else #endif { SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index); return SDL_PrivateGetControllerMappingForGUID(&jGUID); } }
/* * Helper function to determine pre-calculated offset to certain joystick mappings */ static 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")) { /* The Linux driver xpad.c maps the wireless dpad to buttons */ 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, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); } } } #endif /* __LINUX__ */ 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; }