Replaced SDL_GetJoystickCaps() with joystick properties

Fixes https://github.com/libsdl-org/SDL/issues/8927
This commit is contained in:
Sam Lantinga 2024-01-27 14:37:30 -08:00
parent 019dc53764
commit f66fe7e221
37 changed files with 176 additions and 341 deletions

View file

@ -1431,6 +1431,21 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
if (ctx->is_xinput) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
}
#endif
#ifdef SDL_JOYSTICK_RAWINPUT_WGI
if (ctx->is_xinput) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
if (ctx->is_xboxone) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
}
}
#endif
return 0;
}
@ -1506,31 +1521,6 @@ static int RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_r
#endif
}
static Uint32 RAWINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
Uint32 result = 0;
#if defined(SDL_JOYSTICK_RAWINPUT_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT_WGI)
RAWINPUT_DeviceContext *ctx = joystick->hwdata;
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
if (ctx->is_xinput) {
result |= SDL_JOYSTICK_CAP_RUMBLE;
}
#endif
#ifdef SDL_JOYSTICK_RAWINPUT_WGI
if (ctx->is_xinput) {
result |= SDL_JOYSTICK_CAP_RUMBLE;
if (ctx->is_xboxone) {
result |= SDL_JOYSTICK_CAP_TRIGGER_RUMBLE;
}
}
#endif
#endif /**/
return result;
}
static int RAWINPUT_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@ -2226,7 +2216,6 @@ SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver = {
RAWINPUT_JoystickOpen,
RAWINPUT_JoystickRumble,
RAWINPUT_JoystickRumbleTriggers,
RAWINPUT_JoystickGetCapabilities,
RAWINPUT_JoystickSetLED,
RAWINPUT_JoystickSendEffect,
RAWINPUT_JoystickSetSensorsEnabled,