joystick: Convert HasLED() into a generic GetCapabilities() function

main
Cameron Gutman 2021-11-11 11:13:08 -06:00 committed by Sam Lantinga
parent 1ba695dc94
commit 1ccfbf963e
34 changed files with 156 additions and 114 deletions

View File

@ -944,7 +944,7 @@ SDL_JoystickHasLED(SDL_Joystick *joystick)
SDL_LockJoysticks(); SDL_LockJoysticks();
result = joystick->driver->HasLED(joystick); result = (joystick->driver->GetCapabilities(joystick) & SDL_JOYCAP_LED) != 0;
SDL_UnlockJoysticks(); SDL_UnlockJoysticks();

View File

@ -121,6 +121,9 @@ struct _SDL_Joystick
#define SDL_HARDWARE_BUS_USB 0x03 #define SDL_HARDWARE_BUS_USB 0x03
#define SDL_HARDWARE_BUS_BLUETOOTH 0x05 #define SDL_HARDWARE_BUS_BLUETOOTH 0x05
/* Joystick capability flags for GetCapabilities() */
#define SDL_JOYCAP_LED 0x01
/* Macro to combine a USB vendor ID and product ID into a single Uint32 value */ /* Macro to combine a USB vendor ID and product ID into a single Uint32 value */
#define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID)) #define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID))
@ -164,8 +167,10 @@ typedef struct _SDL_JoystickDriver
int (*Rumble)(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); int (*Rumble)(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble);
int (*RumbleTriggers)(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble); int (*RumbleTriggers)(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble);
/* Capability detection */
Uint32 (*GetCapabilities)(SDL_Joystick *joystick);
/* LED functionality */ /* LED functionality */
SDL_bool (*HasLED)(SDL_Joystick *joystick);
int (*SetLED)(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); int (*SetLED)(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
/* General effects */ /* General effects */

View File

@ -616,10 +616,10 @@ ANDROID_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
ANDROID_JoystickHasLED(SDL_Joystick *joystick) ANDROID_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -719,7 +719,7 @@ SDL_JoystickDriver SDL_ANDROID_JoystickDriver =
ANDROID_JoystickOpen, ANDROID_JoystickOpen,
ANDROID_JoystickRumble, ANDROID_JoystickRumble,
ANDROID_JoystickRumbleTriggers, ANDROID_JoystickRumbleTriggers,
ANDROID_JoystickHasLED, ANDROID_JoystickGetCapabilities,
ANDROID_JoystickSetLED, ANDROID_JoystickSetLED,
ANDROID_JoystickSendEffect, ANDROID_JoystickSendEffect,
ANDROID_JoystickSetSensorsEnabled, ANDROID_JoystickSetSensorsEnabled,

View File

@ -777,10 +777,10 @@ BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
return SDL_FALSE; return SDL_FALSE;
} }
static SDL_bool static Uint32
BSD_JoystickHasLED(SDL_Joystick *joystick) BSD_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -814,7 +814,7 @@ SDL_JoystickDriver SDL_BSD_JoystickDriver =
BSD_JoystickOpen, BSD_JoystickOpen,
BSD_JoystickRumble, BSD_JoystickRumble,
BSD_JoystickRumbleTriggers, BSD_JoystickRumbleTriggers,
BSD_JoystickHasLED, BSD_JoystickGetCapabilities,
BSD_JoystickSetLED, BSD_JoystickSetLED,
BSD_JoystickSendEffect, BSD_JoystickSendEffect,
BSD_JoystickSetSensorsEnabled, BSD_JoystickSetSensorsEnabled,

View File

@ -939,10 +939,10 @@ DARWIN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
DARWIN_JoystickHasLED(SDL_Joystick *joystick) DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -1111,7 +1111,7 @@ SDL_JoystickDriver SDL_DARWIN_JoystickDriver =
DARWIN_JoystickOpen, DARWIN_JoystickOpen,
DARWIN_JoystickRumble, DARWIN_JoystickRumble,
DARWIN_JoystickRumbleTriggers, DARWIN_JoystickRumbleTriggers,
DARWIN_JoystickHasLED, DARWIN_JoystickGetCapabilities,
DARWIN_JoystickSetLED, DARWIN_JoystickSetLED,
DARWIN_JoystickSendEffect, DARWIN_JoystickSendEffect,
DARWIN_JoystickSetSensorsEnabled, DARWIN_JoystickSetSensorsEnabled,

View File

@ -95,10 +95,10 @@ DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
DUMMY_JoystickHasLED(SDL_Joystick *joystick) DUMMY_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -153,7 +153,7 @@ SDL_JoystickDriver SDL_DUMMY_JoystickDriver =
DUMMY_JoystickOpen, DUMMY_JoystickOpen,
DUMMY_JoystickRumble, DUMMY_JoystickRumble,
DUMMY_JoystickRumbleTriggers, DUMMY_JoystickRumbleTriggers,
DUMMY_JoystickHasLED, DUMMY_JoystickGetCapabilities,
DUMMY_JoystickSetLED, DUMMY_JoystickSetLED,
DUMMY_JoystickSendEffect, DUMMY_JoystickSendEffect,
DUMMY_JoystickSetSensorsEnabled, DUMMY_JoystickSetSensorsEnabled,

View File

@ -414,10 +414,10 @@ EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
return SDL_FALSE; return SDL_FALSE;
} }
static SDL_bool static Uint32
EMSCRIPTEN_JoystickHasLED(SDL_Joystick *joystick) EMSCRIPTEN_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -451,7 +451,7 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver =
EMSCRIPTEN_JoystickOpen, EMSCRIPTEN_JoystickOpen,
EMSCRIPTEN_JoystickRumble, EMSCRIPTEN_JoystickRumble,
EMSCRIPTEN_JoystickRumbleTriggers, EMSCRIPTEN_JoystickRumbleTriggers,
EMSCRIPTEN_JoystickHasLED, EMSCRIPTEN_JoystickGetCapabilities,
EMSCRIPTEN_JoystickSetLED, EMSCRIPTEN_JoystickSetLED,
EMSCRIPTEN_JoystickSendEffect, EMSCRIPTEN_JoystickSendEffect,
EMSCRIPTEN_JoystickSetSensorsEnabled, EMSCRIPTEN_JoystickSetSensorsEnabled,

View File

@ -271,9 +271,9 @@ extern "C"
return SDL_FALSE; return SDL_FALSE;
} }
static SDL_bool HAIKU_JoystickHasLED(SDL_Joystick *joystick) static Uint32 HAIKU_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int HAIKU_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) static int HAIKU_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
@ -305,7 +305,7 @@ extern "C"
HAIKU_JoystickOpen, HAIKU_JoystickOpen,
HAIKU_JoystickRumble, HAIKU_JoystickRumble,
HAIKU_JoystickRumbleTriggers, HAIKU_JoystickRumbleTriggers,
HAIKU_JoystickHasLED, HAIKU_JoystickGetCapabilities,
HAIKU_JoystickSetLED, HAIKU_JoystickSetLED,
HAIKU_JoystickSendEffect, HAIKU_JoystickSendEffect,
HAIKU_JoystickSetSensorsEnabled, HAIKU_JoystickSetSensorsEnabled,

View File

@ -464,10 +464,10 @@ HIDAPI_DriverGameCube_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joys
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverGameCube_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverGameCube_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -532,7 +532,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube =
HIDAPI_DriverGameCube_OpenJoystick, HIDAPI_DriverGameCube_OpenJoystick,
HIDAPI_DriverGameCube_RumbleJoystick, HIDAPI_DriverGameCube_RumbleJoystick,
HIDAPI_DriverGameCube_RumbleJoystickTriggers, HIDAPI_DriverGameCube_RumbleJoystickTriggers,
HIDAPI_DriverGameCube_HasJoystickLED, HIDAPI_DriverGameCube_GetJoystickCapabilities,
HIDAPI_DriverGameCube_SetJoystickLED, HIDAPI_DriverGameCube_SetJoystickLED,
HIDAPI_DriverGameCube_SendJoystickEffect, HIDAPI_DriverGameCube_SendJoystickEffect,
HIDAPI_DriverGameCube_SetJoystickSensorsEnabled, HIDAPI_DriverGameCube_SetJoystickSensorsEnabled,

View File

@ -132,10 +132,10 @@ HIDAPI_DriverLuna_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverLuna_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -441,7 +441,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverLuna =
HIDAPI_DriverLuna_OpenJoystick, HIDAPI_DriverLuna_OpenJoystick,
HIDAPI_DriverLuna_RumbleJoystick, HIDAPI_DriverLuna_RumbleJoystick,
HIDAPI_DriverLuna_RumbleJoystickTriggers, HIDAPI_DriverLuna_RumbleJoystickTriggers,
HIDAPI_DriverLuna_HasJoystickLED, HIDAPI_DriverLuna_GetJoystickCapabilities,
HIDAPI_DriverLuna_SetJoystickLED, HIDAPI_DriverLuna_SetJoystickLED,
HIDAPI_DriverLuna_SendJoystickEffect, HIDAPI_DriverLuna_SendJoystickEffect,
HIDAPI_DriverLuna_SetJoystickSensorsEnabled, HIDAPI_DriverLuna_SetJoystickSensorsEnabled,

View File

@ -598,10 +598,10 @@ HIDAPI_DriverPS4_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverPS4_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverPS4_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
return SDL_TRUE; return SDL_JOYCAP_LED;
} }
static int static int
@ -935,7 +935,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 =
HIDAPI_DriverPS4_OpenJoystick, HIDAPI_DriverPS4_OpenJoystick,
HIDAPI_DriverPS4_RumbleJoystick, HIDAPI_DriverPS4_RumbleJoystick,
HIDAPI_DriverPS4_RumbleJoystickTriggers, HIDAPI_DriverPS4_RumbleJoystickTriggers,
HIDAPI_DriverPS4_HasJoystickLED, HIDAPI_DriverPS4_GetJoystickCapabilities,
HIDAPI_DriverPS4_SetJoystickLED, HIDAPI_DriverPS4_SetJoystickLED,
HIDAPI_DriverPS4_SendJoystickEffect, HIDAPI_DriverPS4_SendJoystickEffect,
HIDAPI_DriverPS4_SetJoystickSensorsEnabled, HIDAPI_DriverPS4_SetJoystickSensorsEnabled,

View File

@ -663,10 +663,10 @@ HIDAPI_DriverPS5_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverPS5_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverPS5_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
return SDL_TRUE; return SDL_JOYCAP_LED;
} }
static int static int
@ -1098,7 +1098,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5 =
HIDAPI_DriverPS5_OpenJoystick, HIDAPI_DriverPS5_OpenJoystick,
HIDAPI_DriverPS5_RumbleJoystick, HIDAPI_DriverPS5_RumbleJoystick,
HIDAPI_DriverPS5_RumbleJoystickTriggers, HIDAPI_DriverPS5_RumbleJoystickTriggers,
HIDAPI_DriverPS5_HasJoystickLED, HIDAPI_DriverPS5_GetJoystickCapabilities,
HIDAPI_DriverPS5_SetJoystickLED, HIDAPI_DriverPS5_SetJoystickLED,
HIDAPI_DriverPS5_SendJoystickEffect, HIDAPI_DriverPS5_SendJoystickEffect,
HIDAPI_DriverPS5_SetJoystickSensorsEnabled, HIDAPI_DriverPS5_SetJoystickSensorsEnabled,

View File

@ -126,10 +126,10 @@ HIDAPI_DriverStadia_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joysti
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverStadia_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverStadia_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -315,7 +315,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia =
HIDAPI_DriverStadia_OpenJoystick, HIDAPI_DriverStadia_OpenJoystick,
HIDAPI_DriverStadia_RumbleJoystick, HIDAPI_DriverStadia_RumbleJoystick,
HIDAPI_DriverStadia_RumbleJoystickTriggers, HIDAPI_DriverStadia_RumbleJoystickTriggers,
HIDAPI_DriverStadia_HasJoystickLED, HIDAPI_DriverStadia_GetJoystickCapabilities,
HIDAPI_DriverStadia_SetJoystickLED, HIDAPI_DriverStadia_SetJoystickLED,
HIDAPI_DriverStadia_SendJoystickEffect, HIDAPI_DriverStadia_SendJoystickEffect,
HIDAPI_DriverStadia_SetJoystickSensorsEnabled, HIDAPI_DriverStadia_SetJoystickSensorsEnabled,

View File

@ -1095,11 +1095,11 @@ HIDAPI_DriverSteam_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystic
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverSteam_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverSteam_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
/* You should use the full Steam Input API for LED support */ /* You should use the full Steam Input API for LED support */
return SDL_FALSE; return 0;
} }
static int static int
@ -1293,7 +1293,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam =
HIDAPI_DriverSteam_OpenJoystick, HIDAPI_DriverSteam_OpenJoystick,
HIDAPI_DriverSteam_RumbleJoystick, HIDAPI_DriverSteam_RumbleJoystick,
HIDAPI_DriverSteam_RumbleJoystickTriggers, HIDAPI_DriverSteam_RumbleJoystickTriggers,
HIDAPI_DriverSteam_HasJoystickLED, HIDAPI_DriverSteam_GetJoystickCapabilities,
HIDAPI_DriverSteam_SetJoystickLED, HIDAPI_DriverSteam_SetJoystickLED,
HIDAPI_DriverSteam_SendJoystickEffect, HIDAPI_DriverSteam_SendJoystickEffect,
HIDAPI_DriverSteam_SetSensorsEnabled, HIDAPI_DriverSteam_SetSensorsEnabled,

View File

@ -1106,11 +1106,11 @@ HIDAPI_DriverSwitch_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joysti
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverSwitch_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
/* Doesn't have an RGB LED, so don't return true here */ /* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
return SDL_FALSE; return 0;
} }
static int static int
@ -1557,7 +1557,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch =
HIDAPI_DriverSwitch_OpenJoystick, HIDAPI_DriverSwitch_OpenJoystick,
HIDAPI_DriverSwitch_RumbleJoystick, HIDAPI_DriverSwitch_RumbleJoystick,
HIDAPI_DriverSwitch_RumbleJoystickTriggers, HIDAPI_DriverSwitch_RumbleJoystickTriggers,
HIDAPI_DriverSwitch_HasJoystickLED, HIDAPI_DriverSwitch_GetJoystickCapabilities,
HIDAPI_DriverSwitch_SetJoystickLED, HIDAPI_DriverSwitch_SetJoystickLED,
HIDAPI_DriverSwitch_SendJoystickEffect, HIDAPI_DriverSwitch_SendJoystickEffect,
HIDAPI_DriverSwitch_SetJoystickSensorsEnabled, HIDAPI_DriverSwitch_SetJoystickSensorsEnabled,

View File

@ -203,11 +203,11 @@ HIDAPI_DriverXbox360_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joyst
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverXbox360_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverXbox360_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
/* Doesn't have an RGB LED, so don't return true here */ /* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
return SDL_FALSE; return 0;
} }
static int static int
@ -346,7 +346,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 =
HIDAPI_DriverXbox360_OpenJoystick, HIDAPI_DriverXbox360_OpenJoystick,
HIDAPI_DriverXbox360_RumbleJoystick, HIDAPI_DriverXbox360_RumbleJoystick,
HIDAPI_DriverXbox360_RumbleJoystickTriggers, HIDAPI_DriverXbox360_RumbleJoystickTriggers,
HIDAPI_DriverXbox360_HasJoystickLED, HIDAPI_DriverXbox360_GetJoystickCapabilities,
HIDAPI_DriverXbox360_SetJoystickLED, HIDAPI_DriverXbox360_SetJoystickLED,
HIDAPI_DriverXbox360_SendJoystickEffect, HIDAPI_DriverXbox360_SendJoystickEffect,
HIDAPI_DriverXbox360_SetJoystickSensorsEnabled, HIDAPI_DriverXbox360_SetJoystickSensorsEnabled,

View File

@ -173,11 +173,11 @@ HIDAPI_DriverXbox360W_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joys
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
HIDAPI_DriverXbox360W_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverXbox360W_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
/* Doesn't have an RGB LED, so don't return true here */ /* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
return SDL_FALSE; return 0;
} }
static int static int
@ -343,7 +343,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W =
HIDAPI_DriverXbox360W_OpenJoystick, HIDAPI_DriverXbox360W_OpenJoystick,
HIDAPI_DriverXbox360W_RumbleJoystick, HIDAPI_DriverXbox360W_RumbleJoystick,
HIDAPI_DriverXbox360W_RumbleJoystickTriggers, HIDAPI_DriverXbox360W_RumbleJoystickTriggers,
HIDAPI_DriverXbox360W_HasJoystickLED, HIDAPI_DriverXbox360W_GetJoystickCapabilities,
HIDAPI_DriverXbox360W_SetJoystickLED, HIDAPI_DriverXbox360W_SetJoystickLED,
HIDAPI_DriverXbox360W_SendJoystickEffect, HIDAPI_DriverXbox360W_SendJoystickEffect,
HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled, HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled,

View File

@ -422,12 +422,17 @@ HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joyst
return HIDAPI_DriverXboxOne_UpdateRumble(device); return HIDAPI_DriverXboxOne_UpdateRumble(device);
} }
static SDL_bool static Uint32
HIDAPI_DriverXboxOne_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) HIDAPI_DriverXboxOne_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{ {
SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context;
Uint32 result = 0;
return ctx->has_color_led; if (ctx->has_color_led) {
result |= SDL_JOYCAP_LED;
}
return result;
} }
static int static int
@ -1126,7 +1131,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne =
HIDAPI_DriverXboxOne_OpenJoystick, HIDAPI_DriverXboxOne_OpenJoystick,
HIDAPI_DriverXboxOne_RumbleJoystick, HIDAPI_DriverXboxOne_RumbleJoystick,
HIDAPI_DriverXboxOne_RumbleJoystickTriggers, HIDAPI_DriverXboxOne_RumbleJoystickTriggers,
HIDAPI_DriverXboxOne_HasJoystickLED, HIDAPI_DriverXboxOne_GetJoystickCapabilities,
HIDAPI_DriverXboxOne_SetJoystickLED, HIDAPI_DriverXboxOne_SetJoystickLED,
HIDAPI_DriverXboxOne_SendJoystickEffect, HIDAPI_DriverXboxOne_SendJoystickEffect,
HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled, HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled,

View File

@ -894,15 +894,15 @@ HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
return result; return result;
} }
static SDL_bool static Uint32
HIDAPI_JoystickHasLED(SDL_Joystick *joystick) HIDAPI_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
SDL_bool result = SDL_FALSE; Uint32 result = 0;
if (joystick->hwdata) { if (joystick->hwdata) {
SDL_HIDAPI_Device *device = joystick->hwdata->device; SDL_HIDAPI_Device *device = joystick->hwdata->device;
result = device->driver->HasJoystickLED(device, joystick); result = device->driver->GetJoystickCapabilities(device, joystick);
} }
return result; return result;
@ -1042,7 +1042,7 @@ SDL_JoystickDriver SDL_HIDAPI_JoystickDriver =
HIDAPI_JoystickOpen, HIDAPI_JoystickOpen,
HIDAPI_JoystickRumble, HIDAPI_JoystickRumble,
HIDAPI_JoystickRumbleTriggers, HIDAPI_JoystickRumbleTriggers,
HIDAPI_JoystickHasLED, HIDAPI_JoystickGetCapabilities,
HIDAPI_JoystickSetLED, HIDAPI_JoystickSetLED,
HIDAPI_JoystickSendEffect, HIDAPI_JoystickSendEffect,
HIDAPI_JoystickSetSensorsEnabled, HIDAPI_JoystickSetSensorsEnabled,

View File

@ -97,7 +97,7 @@ typedef struct _SDL_HIDAPI_DeviceDriver
SDL_bool (*OpenJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick); SDL_bool (*OpenJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick);
int (*RumbleJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); int (*RumbleJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble);
int (*RumbleJoystickTriggers)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble); int (*RumbleJoystickTriggers)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble);
SDL_bool (*HasJoystickLED)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick); Uint32 (*GetJoystickCapabilities)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick);
int (*SetJoystickLED)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); int (*SetJoystickLED)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
int (*SendJoystickEffect)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size); int (*SendJoystickEffect)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size);
int (*SetJoystickSensorsEnabled)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled); int (*SetJoystickSensorsEnabled)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled);

View File

@ -1326,28 +1326,30 @@ IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri
#endif #endif
} }
static SDL_bool static Uint32
IOS_JoystickHasLED(SDL_Joystick *joystick) IOS_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
Uint32 result = 0;
#ifdef ENABLE_MFI_LIGHT #ifdef ENABLE_MFI_LIGHT
@autoreleasepool { @autoreleasepool {
SDL_JoystickDeviceItem *device = joystick->hwdata; SDL_JoystickDeviceItem *device = joystick->hwdata;
if (device == NULL) { if (device == NULL) {
return SDL_FALSE; return 0;
} }
if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) { if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
GCController *controller = device->controller; GCController *controller = device->controller;
GCDeviceLight *light = controller.light; GCDeviceLight *light = controller.light;
if (light) { if (light) {
return SDL_TRUE; result |= SDL_JOYCAP_LED;
} }
} }
} }
#endif /* ENABLE_MFI_LIGHT */ #endif /* ENABLE_MFI_LIGHT */
return SDL_FALSE; return result;
} }
static int static int
@ -1751,7 +1753,7 @@ SDL_JoystickDriver SDL_IOS_JoystickDriver =
IOS_JoystickOpen, IOS_JoystickOpen,
IOS_JoystickRumble, IOS_JoystickRumble,
IOS_JoystickRumbleTriggers, IOS_JoystickRumbleTriggers,
IOS_JoystickHasLED, IOS_JoystickGetCapabilities,
IOS_JoystickSetLED, IOS_JoystickSetLED,
IOS_JoystickSendEffect, IOS_JoystickSendEffect,
IOS_JoystickSetSensorsEnabled, IOS_JoystickSetSensorsEnabled,

View File

@ -1190,10 +1190,10 @@ LINUX_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
LINUX_JoystickHasLED(SDL_Joystick *joystick) LINUX_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -1790,7 +1790,7 @@ SDL_JoystickDriver SDL_LINUX_JoystickDriver =
LINUX_JoystickOpen, LINUX_JoystickOpen,
LINUX_JoystickRumble, LINUX_JoystickRumble,
LINUX_JoystickRumbleTriggers, LINUX_JoystickRumbleTriggers,
LINUX_JoystickHasLED, LINUX_JoystickGetCapabilities,
LINUX_JoystickSetLED, LINUX_JoystickSetLED,
LINUX_JoystickSendEffect, LINUX_JoystickSendEffect,
LINUX_JoystickSetSensorsEnabled, LINUX_JoystickSetSensorsEnabled,

View File

@ -472,9 +472,9 @@ static int OS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool OS2_JoystickHasLED(SDL_Joystick *joystick) static Uint32 OS2_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int OS2_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) static int OS2_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
@ -777,7 +777,7 @@ SDL_JoystickDriver SDL_OS2_JoystickDriver =
OS2_JoystickOpen, OS2_JoystickOpen,
OS2_JoystickRumble, OS2_JoystickRumble,
OS2_JoystickRumbleTriggers, OS2_JoystickRumbleTriggers,
OS2_JoystickHasLED, OS2_JoystickGetCapabilities,
OS2_JoystickSetLED, OS2_JoystickSetLED,
OS2_JoystickSendEffect, OS2_JoystickSendEffect,
OS2_JoystickSetSensorsEnabled, OS2_JoystickSetSensorsEnabled,

View File

@ -209,9 +209,9 @@ PSP_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool PSP_JoystickHasLED(SDL_Joystick *joystick) static Uint32 PSP_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -311,7 +311,7 @@ SDL_JoystickDriver SDL_PSP_JoystickDriver =
PSP_JoystickOpen, PSP_JoystickOpen,
PSP_JoystickRumble, PSP_JoystickRumble,
PSP_JoystickRumbleTriggers, PSP_JoystickRumbleTriggers,
PSP_JoystickHasLED, PSP_JoystickGetCapabilities,
PSP_JoystickSetLED, PSP_JoystickSetLED,
PSP_JoystickSendEffect, PSP_JoystickSendEffect,
PSP_JoystickSetSensorsEnabled, PSP_JoystickSetSensorsEnabled,

View File

@ -345,10 +345,10 @@ VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
} }
static SDL_bool static Uint32
VIRTUAL_JoystickHasLED(SDL_Joystick *joystick) VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
@ -442,7 +442,7 @@ SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver =
VIRTUAL_JoystickOpen, VIRTUAL_JoystickOpen,
VIRTUAL_JoystickRumble, VIRTUAL_JoystickRumble,
VIRTUAL_JoystickRumbleTriggers, VIRTUAL_JoystickRumbleTriggers,
VIRTUAL_JoystickHasLED, VIRTUAL_JoystickGetCapabilities,
VIRTUAL_JoystickSetLED, VIRTUAL_JoystickSetLED,
VIRTUAL_JoystickSendEffect, VIRTUAL_JoystickSendEffect,
VIRTUAL_JoystickSetSensorsEnabled, VIRTUAL_JoystickSetSensorsEnabled,

View File

@ -365,11 +365,11 @@ VITA_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right)
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
VITA_JoystickHasLED(SDL_Joystick *joystick) VITA_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
// always return true for now // always return LED supported for now
return SDL_TRUE; return SDL_JOYCAP_LED;
} }
@ -409,7 +409,7 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver =
VITA_JoystickRumble, VITA_JoystickRumble,
VITA_JoystickRumbleTriggers, VITA_JoystickRumbleTriggers,
VITA_JoystickHasLED, VITA_JoystickGetCapabilities,
VITA_JoystickSetLED, VITA_JoystickSetLED,
VITA_JoystickSendEffect, VITA_JoystickSendEffect,
VITA_JoystickSetSensorsEnabled, VITA_JoystickSetSensorsEnabled,

View File

@ -924,6 +924,12 @@ SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
return 0; return 0;
} }
Uint32
SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
{
return 0;
}
static Uint8 static Uint8
TranslatePOV(DWORD value) TranslatePOV(DWORD value)
{ {
@ -1168,6 +1174,12 @@ SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
return SDL_Unsupported(); return SDL_Unsupported();
} }
Uint32
SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
{
return 0;
}
void void
SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick) SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick)
{ {

View File

@ -25,6 +25,7 @@ extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext);
extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version);
extern int SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice); extern int SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice);
extern int SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); extern int SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble);
extern Uint32 SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick);
extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick); extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick);
extern void SDL_DINPUT_JoystickClose(SDL_Joystick * joystick); extern void SDL_DINPUT_JoystickClose(SDL_Joystick * joystick);
extern void SDL_DINPUT_JoystickQuit(void); extern void SDL_DINPUT_JoystickQuit(void);

View File

@ -334,9 +334,9 @@ WINMM_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool WINMM_JoystickHasLED(SDL_Joystick *joystick) static Uint32 WINMM_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -500,7 +500,7 @@ SDL_JoystickDriver SDL_WINMM_JoystickDriver =
WINMM_JoystickOpen, WINMM_JoystickOpen,
WINMM_JoystickRumble, WINMM_JoystickRumble,
WINMM_JoystickRumbleTriggers, WINMM_JoystickRumbleTriggers,
WINMM_JoystickHasLED, WINMM_JoystickGetCapabilities,
WINMM_JoystickSetLED, WINMM_JoystickSetLED,
WINMM_JoystickSendEffect, WINMM_JoystickSendEffect,
WINMM_JoystickSetSensorsEnabled, WINMM_JoystickSetSensorsEnabled,

View File

@ -1277,10 +1277,10 @@ RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint
#endif #endif
} }
static SDL_bool static Uint32
RAWINPUT_JoystickHasLED(SDL_Joystick *joystick) RAWINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -1928,7 +1928,7 @@ SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver =
RAWINPUT_JoystickOpen, RAWINPUT_JoystickOpen,
RAWINPUT_JoystickRumble, RAWINPUT_JoystickRumble,
RAWINPUT_JoystickRumbleTriggers, RAWINPUT_JoystickRumbleTriggers,
RAWINPUT_JoystickHasLED, RAWINPUT_JoystickGetCapabilities,
RAWINPUT_JoystickSetLED, RAWINPUT_JoystickSetLED,
RAWINPUT_JoystickSendEffect, RAWINPUT_JoystickSendEffect,
RAWINPUT_JoystickSetSensorsEnabled, RAWINPUT_JoystickSetSensorsEnabled,

View File

@ -665,10 +665,10 @@ WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri
} }
} }
static SDL_bool static Uint32
WGI_JoystickHasLED(SDL_Joystick *joystick) WGI_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; return 0;
} }
static int static int
@ -876,7 +876,7 @@ SDL_JoystickDriver SDL_WGI_JoystickDriver =
WGI_JoystickOpen, WGI_JoystickOpen,
WGI_JoystickRumble, WGI_JoystickRumble,
WGI_JoystickRumbleTriggers, WGI_JoystickRumbleTriggers,
WGI_JoystickHasLED, WGI_JoystickGetCapabilities,
WGI_JoystickSetLED, WGI_JoystickSetLED,
WGI_JoystickSendEffect, WGI_JoystickSendEffect,
WGI_JoystickSetSensorsEnabled, WGI_JoystickSetSensorsEnabled,

View File

@ -658,10 +658,14 @@ WINDOWS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
return SDL_Unsupported(); return SDL_Unsupported();
} }
static SDL_bool static Uint32
WINDOWS_JoystickHasLED(SDL_Joystick *joystick) WINDOWS_JoystickGetCapabilities(SDL_Joystick *joystick)
{ {
return SDL_FALSE; if (joystick->hwdata->bXInputDevice) {
return SDL_XINPUT_JoystickGetCapabilities(joystick);
} else {
return SDL_DINPUT_JoystickGetCapabilities(joystick);
}
} }
static int static int
@ -758,7 +762,7 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver =
WINDOWS_JoystickOpen, WINDOWS_JoystickOpen,
WINDOWS_JoystickRumble, WINDOWS_JoystickRumble,
WINDOWS_JoystickRumbleTriggers, WINDOWS_JoystickRumbleTriggers,
WINDOWS_JoystickHasLED, WINDOWS_JoystickGetCapabilities,
WINDOWS_JoystickSetLED, WINDOWS_JoystickSetLED,
WINDOWS_JoystickSendEffect, WINDOWS_JoystickSendEffect,
WINDOWS_JoystickSetSensorsEnabled, WINDOWS_JoystickSetSensorsEnabled,

View File

@ -503,6 +503,12 @@ SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
return 0; return 0;
} }
Uint32
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
{
return 0;
}
void void
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
{ {
@ -579,6 +585,12 @@ SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
return SDL_Unsupported(); return SDL_Unsupported();
} }
Uint32
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
{
return 0;
}
void void
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick) SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
{ {

View File

@ -27,6 +27,7 @@ extern int SDL_XINPUT_JoystickInit(void);
extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext); extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext);
extern int SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice); extern int SDL_XINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice);
extern int SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); extern int SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble);
extern Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick);
extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick); extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick);
extern void SDL_XINPUT_JoystickClose(SDL_Joystick * joystick); extern void SDL_XINPUT_JoystickClose(SDL_Joystick * joystick);
extern void SDL_XINPUT_JoystickQuit(void); extern void SDL_XINPUT_JoystickQuit(void);