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

@@ -959,8 +959,6 @@ SDL3_0.0.0 {
SDL_GetHapticName;
SDL_ReadSurfacePixel;
SDL_FlipSurface;
SDL_GetGamepadCaps;
SDL_GetJoystickCaps;
# extra symbols go here (don't modify this line)
local: *;
};

View File

@@ -984,5 +984,3 @@
#define SDL_GetHapticName SDL_GetHapticName_REAL
#define SDL_ReadSurfacePixel SDL_ReadSurfacePixel_REAL
#define SDL_FlipSurface SDL_FlipSurface_REAL
#define SDL_GetGamepadCaps SDL_GetGamepadCaps_REAL
#define SDL_GetJoystickCaps SDL_GetJoystickCaps_REAL

View File

@@ -1009,5 +1009,3 @@ SDL_DYNAPI_PROC(SDL_HapticID,SDL_GetHapticInstanceID,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetHapticName,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_ReadSurfacePixel,(SDL_Surface *a, int b, int c, Uint8 *d, Uint8 *e, Uint8 *f, Uint8 *g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(int,SDL_FlipSurface,(SDL_Surface *a, SDL_FlipMode b),(a,b),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetGamepadCaps,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetJoystickCaps,(SDL_Joystick *a),(a),return)

View File

@@ -3485,16 +3485,6 @@ int SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 r
return SDL_RumbleJoystickTriggers(joystick, left_rumble, right_rumble, duration_ms);
}
Uint32 SDL_GetGamepadCaps(SDL_Gamepad *gamepad)
{
SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad);
if (!joystick) {
return 0;
}
return SDL_GetJoystickCaps(joystick);
}
int SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue)
{
SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad);

View File

@@ -1655,21 +1655,6 @@ int SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
return retval;
}
Uint32 SDL_GetJoystickCaps(SDL_Joystick *joystick)
{
Uint32 retval;
SDL_LockJoysticks();
{
CHECK_JOYSTICK_MAGIC(joystick, 0);
retval = joystick->driver->GetCapabilities(joystick);
}
SDL_UnlockJoysticks();
return retval;
}
int SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
int retval;

View File

@@ -190,9 +190,6 @@ typedef struct SDL_JoystickDriver
int (*Rumble)(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble);
int (*RumbleTriggers)(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble);
/* Capability detection */
Uint32 (*GetCapabilities)(SDL_Joystick *joystick);
/* LED functionality */
int (*SetLED)(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);

View File

@@ -597,11 +597,6 @@ static int ANDROID_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_ru
return SDL_Unsupported();
}
static Uint32 ANDROID_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int ANDROID_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -694,7 +689,6 @@ SDL_JoystickDriver SDL_ANDROID_JoystickDriver = {
ANDROID_JoystickOpen,
ANDROID_JoystickRumble,
ANDROID_JoystickRumbleTriggers,
ANDROID_JoystickGetCapabilities,
ANDROID_JoystickSetLED,
ANDROID_JoystickSendEffect,
ANDROID_JoystickSetSensorsEnabled,

View File

@@ -1012,6 +1012,26 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
}
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
GCController *controller = device->controller;
#ifdef ENABLE_MFI_LIGHT
if (controller.light) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE);
}
#endif
#ifdef ENABLE_MFI_RUMBLE
if (controller.haptics) {
for (GCHapticsLocality locality in controller.haptics.supportedLocalities) {
if ([locality isEqualToString:GCHapticsLocalityHandles]) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
} else if ([locality isEqualToString:GCHapticsLocalityTriggers]) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
}
}
}
#endif
}
#endif /* SDL_JOYSTICK_MFI */
}
}
@@ -1625,44 +1645,6 @@ static int IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble
#endif
}
static Uint32 IOS_JoystickGetCapabilities(SDL_Joystick *joystick)
{
Uint32 result = 0;
#if defined(ENABLE_MFI_LIGHT) || defined(ENABLE_MFI_RUMBLE)
@autoreleasepool {
SDL_JoystickDeviceItem *device = joystick->hwdata;
if (device == NULL) {
return 0;
}
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
GCController *controller = device->controller;
#ifdef ENABLE_MFI_LIGHT
if (controller.light) {
result |= SDL_JOYSTICK_CAP_RGB_LED;
}
#endif
#ifdef ENABLE_MFI_RUMBLE
if (controller.haptics) {
for (GCHapticsLocality locality in controller.haptics.supportedLocalities) {
if ([locality isEqualToString:GCHapticsLocalityHandles]) {
result |= SDL_JOYSTICK_CAP_RUMBLE;
} else if ([locality isEqualToString:GCHapticsLocalityTriggers]) {
result |= SDL_JOYSTICK_CAP_TRIGGER_RUMBLE;
}
}
}
#endif
}
}
#endif /* ENABLE_MFI_LIGHT || ENABLE_MFI_RUMBLE */
return result;
}
static int IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
#ifdef ENABLE_MFI_LIGHT
@@ -2184,7 +2166,6 @@ SDL_JoystickDriver SDL_IOS_JoystickDriver = {
IOS_JoystickOpen,
IOS_JoystickRumble,
IOS_JoystickRumbleTriggers,
IOS_JoystickGetCapabilities,
IOS_JoystickSetLED,
IOS_JoystickSendEffect,
IOS_JoystickSetSensorsEnabled,

View File

@@ -829,11 +829,6 @@ static SDL_bool BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi
return SDL_FALSE;
}
static Uint32 BSD_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int BSD_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -863,7 +858,6 @@ SDL_JoystickDriver SDL_BSD_JoystickDriver = {
BSD_JoystickOpen,
BSD_JoystickRumble,
BSD_JoystickRumbleTriggers,
BSD_JoystickGetCapabilities,
BSD_JoystickSetLED,
BSD_JoystickSendEffect,
BSD_JoystickSetSensorsEnabled,

View File

@@ -770,6 +770,11 @@ static int DARWIN_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->naxes = device->axes;
joystick->nhats = device->hats;
joystick->nbuttons = device->buttons;
if (device->ffservice) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
}
return 0;
}
@@ -908,22 +913,6 @@ static int DARWIN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rum
return SDL_Unsupported();
}
static Uint32 DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick)
{
recDevice *device = joystick->hwdata;
Uint32 result = 0;
if (!device) {
return 0;
}
if (device->ffservice) {
result |= SDL_JOYSTICK_CAP_RUMBLE;
}
return result;
}
static int DARWIN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -1084,7 +1073,6 @@ SDL_JoystickDriver SDL_DARWIN_JoystickDriver = {
DARWIN_JoystickOpen,
DARWIN_JoystickRumble,
DARWIN_JoystickRumbleTriggers,
DARWIN_JoystickGetCapabilities,
DARWIN_JoystickSetLED,
DARWIN_JoystickSendEffect,
DARWIN_JoystickSetSensorsEnabled,

View File

@@ -92,11 +92,6 @@ static int DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumb
return SDL_Unsupported();
}
static Uint32 DUMMY_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int DUMMY_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -143,7 +138,6 @@ SDL_JoystickDriver SDL_DUMMY_JoystickDriver = {
DUMMY_JoystickOpen,
DUMMY_JoystickRumble,
DUMMY_JoystickRumbleTriggers,
DUMMY_JoystickGetCapabilities,
DUMMY_JoystickSetLED,
DUMMY_JoystickSendEffect,
DUMMY_JoystickSetSensorsEnabled,

View File

@@ -395,11 +395,6 @@ static SDL_bool EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_Gamep
return SDL_FALSE;
}
static Uint32 EMSCRIPTEN_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int EMSCRIPTEN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -429,7 +424,6 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver = {
EMSCRIPTEN_JoystickOpen,
EMSCRIPTEN_JoystickRumble,
EMSCRIPTEN_JoystickRumbleTriggers,
EMSCRIPTEN_JoystickGetCapabilities,
EMSCRIPTEN_JoystickSetLED,
EMSCRIPTEN_JoystickSendEffect,
EMSCRIPTEN_JoystickSetSensorsEnabled,

View File

@@ -272,11 +272,6 @@ extern "C"
return SDL_FALSE;
}
static Uint32 HAIKU_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int HAIKU_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -308,7 +303,6 @@ extern "C"
HAIKU_JoystickOpen,
HAIKU_JoystickRumble,
HAIKU_JoystickRumbleTriggers,
HAIKU_JoystickGetCapabilities,
HAIKU_JoystickSetLED,
HAIKU_JoystickSendEffect,
HAIKU_JoystickSetSensorsEnabled,

View File

@@ -723,6 +723,8 @@ static void HIDAPI_DriverPS4_SetEnhancedModeAvailable(SDL_DriverPS4_Context *ctx
if (ctx->device->is_bluetooth && ctx->official_controller) {
ctx->report_battery = SDL_TRUE;
}
HIDAPI_UpdateDeviceProperties(ctx->device);
}
static void HIDAPI_DriverPS4_SetEnhancedMode(SDL_DriverPS4_Context *ctx)

View File

@@ -818,6 +818,8 @@ static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx
if (ctx->device->is_bluetooth) {
ctx->report_battery = SDL_TRUE;
}
HIDAPI_UpdateDeviceProperties(ctx->device);
}
static void HIDAPI_DriverPS5_SetEnhancedMode(SDL_DriverPS5_Context *ctx)

View File

@@ -727,6 +727,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
ctx->m_bPlayerLights = bPlayerLights;
UpdateSlotLED(ctx);
HIDAPI_UpdateDeviceProperties(ctx->device);
}
}

View File

@@ -131,6 +131,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
ctx->player_lights = player_lights;
UpdateSlotLED(ctx);
HIDAPI_UpdateDeviceProperties(ctx->device);
}
}

View File

@@ -103,6 +103,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
ctx->player_lights = player_lights;
UpdateSlotLED(ctx);
HIDAPI_UpdateDeviceProperties(ctx->device);
}
}

View File

@@ -859,6 +859,54 @@ void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joyst
SDL_UnlockJoysticks();
}
static void HIDAPI_UpdateJoystickProperties(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{
SDL_PropertiesID props = SDL_GetJoystickProperties(joystick);
Uint32 caps = device->driver->GetJoystickCapabilities(device, joystick);
if (caps & SDL_JOYSTICK_CAP_MONO_LED) {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, SDL_TRUE);
} else {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, SDL_FALSE);
}
if (caps & SDL_JOYSTICK_CAP_RGB_LED) {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE);
} else {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_FALSE);
}
if (caps & SDL_JOYSTICK_CAP_PLAYER_LED) {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN, SDL_TRUE);
} else {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN, SDL_FALSE);
}
if (caps & SDL_JOYSTICK_CAP_RUMBLE) {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
} else {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_FALSE);
}
if (caps & SDL_JOYSTICK_CAP_TRIGGER_RUMBLE) {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
} else {
SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_FALSE);
}
}
void HIDAPI_UpdateDeviceProperties(SDL_HIDAPI_Device *device)
{
int i;
SDL_LockJoysticks();
for (i = 0; i < device->num_joysticks; ++i) {
SDL_Joystick *joystick = SDL_GetJoystickFromInstanceID(device->joysticks[i]);
if (joystick) {
HIDAPI_UpdateJoystickProperties(device, joystick);
}
}
SDL_UnlockJoysticks();
}
static int HIDAPI_JoystickGetCount(void)
{
return SDL_HIDAPI_numjoysticks;
@@ -1471,6 +1519,8 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index)
return -1;
}
HIDAPI_UpdateJoystickProperties(device, joystick);
if (device->serial) {
joystick->serial = SDL_strdup(device->serial);
}
@@ -1520,18 +1570,6 @@ static int HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rum
return result;
}
static Uint32 HIDAPI_JoystickGetCapabilities(SDL_Joystick *joystick)
{
Uint32 result = 0;
SDL_HIDAPI_Device *device = NULL;
if (HIDAPI_GetJoystickDevice(joystick, &device)) {
result = device->driver->GetJoystickCapabilities(device, joystick);
}
return result;
}
static int HIDAPI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
int result;
@@ -1671,7 +1709,6 @@ SDL_JoystickDriver SDL_HIDAPI_JoystickDriver = {
HIDAPI_JoystickOpen,
HIDAPI_JoystickRumble,
HIDAPI_JoystickRumbleTriggers,
HIDAPI_JoystickGetCapabilities,
HIDAPI_JoystickSetLED,
HIDAPI_JoystickSendEffect,
HIDAPI_JoystickSetSensorsEnabled,

View File

@@ -40,6 +40,13 @@
#define SDL_JOYSTICK_HIDAPI_XBOXONE
#define SDL_JOYSTICK_HIDAPI_SHIELD
/* Joystick capability definitions */
#define SDL_JOYSTICK_CAP_MONO_LED 0x00000001
#define SDL_JOYSTICK_CAP_RGB_LED 0x00000002
#define SDL_JOYSTICK_CAP_PLAYER_LED 0x00000004
#define SDL_JOYSTICK_CAP_RUMBLE 0x00000010
#define SDL_JOYSTICK_CAP_TRIGGER_RUMBLE 0x00000020
/* Whether HIDAPI is enabled by default */
#define SDL_HIDAPI_DEFAULT SDL_TRUE
@@ -156,6 +163,7 @@ extern SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial);
extern void HIDAPI_DisconnectBluetoothDevice(const char *serial);
extern SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID);
extern void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID);
extern void HIDAPI_UpdateDeviceProperties(SDL_HIDAPI_Device *device);
extern void HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size);

View File

@@ -1609,6 +1609,9 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->hwdata->fd_sensor = -1;
}
if (joystick->hwdata->ff_rumble || joystick->hwdata->ff_sine) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
}
return 0;
}
@@ -1660,19 +1663,6 @@ static int LINUX_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumb
return SDL_Unsupported();
}
static Uint32 LINUX_JoystickGetCapabilities(SDL_Joystick *joystick)
{
Uint32 result = 0;
SDL_AssertJoysticksLocked();
if (joystick->hwdata->ff_rumble || joystick->hwdata->ff_sine) {
result |= SDL_JOYSTICK_CAP_RUMBLE;
}
return result;
}
static int LINUX_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -2706,7 +2696,6 @@ SDL_JoystickDriver SDL_LINUX_JoystickDriver = {
LINUX_JoystickOpen,
LINUX_JoystickRumble,
LINUX_JoystickRumbleTriggers,
LINUX_JoystickGetCapabilities,
LINUX_JoystickSetLED,
LINUX_JoystickSendEffect,
LINUX_JoystickSetSensorsEnabled,

View File

@@ -245,11 +245,6 @@ static void N3DS_JoystickSetDevicePlayerIndex(int device_index, int player_index
{
}
static Uint32 N3DS_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int N3DS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
return SDL_Unsupported();
@@ -284,7 +279,6 @@ SDL_JoystickDriver SDL_N3DS_JoystickDriver = {
.Open = N3DS_JoystickOpen,
.Rumble = N3DS_JoystickRumble,
.RumbleTriggers = N3DS_JoystickRumbleTriggers,
.GetCapabilities = N3DS_JoystickGetCapabilities,
.SetLED = N3DS_JoystickSetLED,
.SendEffect = N3DS_JoystickSendEffect,
.SetSensorsEnabled = N3DS_JoystickSetSensorsEnabled,

View File

@@ -210,6 +210,8 @@ static int PS2_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->nhats = 0;
joystick->instance_id = device_index;
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
return 0;
}
@@ -240,31 +242,25 @@ static int PS2_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl
/* Rumble functionality */
static int PS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right)
{
return -1;
}
/* Capability detection */
static Uint32 PS2_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return SDL_JOYSTICK_CAP_RUMBLE;
return SDL_Unsupported();
}
/* LED functionality */
static int PS2_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return -1;
return SDL_Unsupported();
}
/* General effects */
static int PS2_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
{
return -1;
return SDL_Unsupported();
}
/* Sensor functionality */
static int PS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
{
return -1;
return SDL_Unsupported();
}
/* Function to update the state of a joystick - called as a device poll.
@@ -355,7 +351,6 @@ SDL_JoystickDriver SDL_PS2_JoystickDriver = {
PS2_JoystickOpen,
PS2_JoystickRumble,
PS2_JoystickRumbleTriggers,
PS2_JoystickGetCapabilities,
PS2_JoystickSetLED,
PS2_JoystickSendEffect,
PS2_JoystickSetSensorsEnabled,

View File

@@ -173,11 +173,6 @@ static int PSP_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble
return SDL_Unsupported();
}
static Uint32 PSP_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
static int PSP_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -266,7 +261,6 @@ SDL_JoystickDriver SDL_PSP_JoystickDriver = {
PSP_JoystickOpen,
PSP_JoystickRumble,
PSP_JoystickRumbleTriggers,
PSP_JoystickGetCapabilities,
PSP_JoystickSetLED,
PSP_JoystickSendEffect,
PSP_JoystickSetSensorsEnabled,

View File

@@ -422,6 +422,16 @@ static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->nbuttons = hwdata->desc.nbuttons;
joystick->nhats = hwdata->desc.nhats;
hwdata->joystick = joystick;
if (hwdata->desc.SetLED) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE);
}
if (hwdata->desc.Rumble) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
}
if (hwdata->desc.RumbleTriggers) {
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
}
return 0;
}
@@ -465,28 +475,6 @@ static int VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_ru
return result;
}
static Uint32 VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick)
{
joystick_hwdata *hwdata;
Uint32 caps = 0;
SDL_AssertJoysticksLocked();
hwdata = joystick->hwdata;
if (hwdata) {
if (hwdata->desc.Rumble) {
caps |= SDL_JOYSTICK_CAP_RUMBLE;
}
if (hwdata->desc.RumbleTriggers) {
caps |= SDL_JOYSTICK_CAP_TRIGGER_RUMBLE;
}
if (hwdata->desc.SetLED) {
caps |= SDL_JOYSTICK_CAP_RGB_LED;
}
}
return caps;
}
static int VIRTUAL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
int result;
@@ -741,7 +729,6 @@ SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = {
VIRTUAL_JoystickOpen,
VIRTUAL_JoystickRumble,
VIRTUAL_JoystickRumbleTriggers,
VIRTUAL_JoystickGetCapabilities,
VIRTUAL_JoystickSetLED,
VIRTUAL_JoystickSendEffect,
VIRTUAL_JoystickSetSensorsEnabled,

View File

@@ -207,6 +207,9 @@ int VITA_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->nhats = 0;
joystick->instance_id = device_index;
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE);
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
return 0;
}
@@ -344,12 +347,6 @@ static int VITA_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint
return SDL_Unsupported();
}
static Uint32 VITA_JoystickGetCapabilities(SDL_Joystick *joystick)
{
// always return LED and rumble supported for now
return SDL_JOYSTICK_CAP_RGB_LED | SDL_JOYSTICK_CAP_RUMBLE;
}
static int VITA_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
int index = (int)SDL_GetJoystickInstanceID(joystick) - 1;
@@ -388,17 +385,12 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver = {
VITA_JoystickSetDevicePlayerIndex,
VITA_JoystickGetDeviceGUID,
VITA_JoystickGetDeviceInstanceID,
VITA_JoystickOpen,
VITA_JoystickRumble,
VITA_JoystickRumbleTriggers,
VITA_JoystickGetCapabilities,
VITA_JoystickSetLED,
VITA_JoystickSendEffect,
VITA_JoystickSetSensorsEnabled,
VITA_JoystickUpdate,
VITA_JoystickClose,
VITA_JoystickQuit,

View File

@@ -826,6 +826,8 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic
return SetDIerror("IDirectInputDevice8::SetProperty", result);
}
*/
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
}
/* What buttons and axes does it have? */
@@ -945,17 +947,6 @@ int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl
return 0;
}
Uint32 SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
Uint32 result = 0;
if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
result |= SDL_JOYSTICK_CAP_RUMBLE;
}
return result;
}
static Uint8 TranslatePOV(DWORD value)
{
const Uint8 HAT_VALS[] = {
@@ -1193,11 +1184,6 @@ int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl
return SDL_Unsupported();
}
Uint32 SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick)
{
}

View File

@@ -30,7 +30,6 @@ extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext);
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_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_JoystickClose(SDL_Joystick *joystick);
extern void SDL_DINPUT_JoystickQuit(void);

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,

View File

@@ -749,6 +749,11 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index)
__x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_AxisCount(hwdata->controller, &joystick->naxes);
__x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_SwitchCount(hwdata->controller, &joystick->nhats);
if (hwdata->gamepad) {
/* FIXME: Can WGI even tell us if trigger rumble is supported? */
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE);
}
return 0;
}
@@ -794,18 +799,6 @@ static int WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble
}
}
static Uint32 WGI_JoystickGetCapabilities(SDL_Joystick *joystick)
{
struct joystick_hwdata *hwdata = joystick->hwdata;
if (hwdata->gamepad) {
/* FIXME: Can WGI even tell us if trigger rumble is supported? */
return (SDL_JOYSTICK_CAP_RUMBLE | SDL_JOYSTICK_CAP_TRIGGER_RUMBLE);
} else {
return 0;
}
}
static int WGI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -1026,7 +1019,6 @@ SDL_JoystickDriver SDL_WGI_JoystickDriver = {
WGI_JoystickOpen,
WGI_JoystickRumble,
WGI_JoystickRumbleTriggers,
WGI_JoystickGetCapabilities,
WGI_JoystickSetLED,
WGI_JoystickSendEffect,
WGI_JoystickSetSensorsEnabled,

View File

@@ -704,15 +704,6 @@ static int WINDOWS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_ru
return SDL_Unsupported();
}
static Uint32 WINDOWS_JoystickGetCapabilities(SDL_Joystick *joystick)
{
if (joystick->hwdata->bXInputDevice) {
return SDL_XINPUT_JoystickGetCapabilities(joystick);
} else {
return SDL_DINPUT_JoystickGetCapabilities(joystick);
}
}
static int WINDOWS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{
return SDL_Unsupported();
@@ -807,7 +798,6 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = {
WINDOWS_JoystickOpen,
WINDOWS_JoystickRumble,
WINDOWS_JoystickRumbleTriggers,
WINDOWS_JoystickGetCapabilities,
WINDOWS_JoystickSetLED,
WINDOWS_JoystickSendEffect,
WINDOWS_JoystickSetSensorsEnabled,

View File

@@ -263,6 +263,9 @@ int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic
joystick->naxes = 6;
joystick->nbuttons = 11;
joystick->nhats = 1;
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
return 0;
}
@@ -351,11 +354,6 @@ int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl
return 0;
}
Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return SDL_JOYSTICK_CAP_RUMBLE;
}
void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick)
{
DWORD result;
@@ -432,11 +430,6 @@ int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl
return SDL_Unsupported();
}
Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
{
return 0;
}
void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick)
{
}

View File

@@ -32,7 +32,6 @@ extern int SDL_XINPUT_JoystickInit(void);
extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext);
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 Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick);
extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick);
extern void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick);
extern void SDL_XINPUT_JoystickQuit(void);