joystick: Convert HasLED() into a generic GetCapabilities() function
parent
1ba695dc94
commit
1ccfbf963e
|
@ -944,7 +944,7 @@ SDL_JoystickHasLED(SDL_Joystick *joystick)
|
|||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
result = joystick->driver->HasLED(joystick);
|
||||
result = (joystick->driver->GetCapabilities(joystick) & SDL_JOYCAP_LED) != 0;
|
||||
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
|
|
|
@ -121,6 +121,9 @@ struct _SDL_Joystick
|
|||
#define SDL_HARDWARE_BUS_USB 0x03
|
||||
#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 */
|
||||
#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 (*RumbleTriggers)(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble);
|
||||
|
||||
/* Capability detection */
|
||||
Uint32 (*GetCapabilities)(SDL_Joystick *joystick);
|
||||
|
||||
/* LED functionality */
|
||||
SDL_bool (*HasLED)(SDL_Joystick *joystick);
|
||||
int (*SetLED)(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
/* General effects */
|
||||
|
|
|
@ -616,10 +616,10 @@ ANDROID_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
ANDROID_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
ANDROID_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -719,7 +719,7 @@ SDL_JoystickDriver SDL_ANDROID_JoystickDriver =
|
|||
ANDROID_JoystickOpen,
|
||||
ANDROID_JoystickRumble,
|
||||
ANDROID_JoystickRumbleTriggers,
|
||||
ANDROID_JoystickHasLED,
|
||||
ANDROID_JoystickGetCapabilities,
|
||||
ANDROID_JoystickSetLED,
|
||||
ANDROID_JoystickSendEffect,
|
||||
ANDROID_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -777,10 +777,10 @@ BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
|||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
BSD_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
BSD_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -814,7 +814,7 @@ SDL_JoystickDriver SDL_BSD_JoystickDriver =
|
|||
BSD_JoystickOpen,
|
||||
BSD_JoystickRumble,
|
||||
BSD_JoystickRumbleTriggers,
|
||||
BSD_JoystickHasLED,
|
||||
BSD_JoystickGetCapabilities,
|
||||
BSD_JoystickSetLED,
|
||||
BSD_JoystickSendEffect,
|
||||
BSD_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -939,10 +939,10 @@ DARWIN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
DARWIN_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1111,7 +1111,7 @@ SDL_JoystickDriver SDL_DARWIN_JoystickDriver =
|
|||
DARWIN_JoystickOpen,
|
||||
DARWIN_JoystickRumble,
|
||||
DARWIN_JoystickRumbleTriggers,
|
||||
DARWIN_JoystickHasLED,
|
||||
DARWIN_JoystickGetCapabilities,
|
||||
DARWIN_JoystickSetLED,
|
||||
DARWIN_JoystickSendEffect,
|
||||
DARWIN_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -95,10 +95,10 @@ DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
DUMMY_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
DUMMY_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -153,7 +153,7 @@ SDL_JoystickDriver SDL_DUMMY_JoystickDriver =
|
|||
DUMMY_JoystickOpen,
|
||||
DUMMY_JoystickRumble,
|
||||
DUMMY_JoystickRumbleTriggers,
|
||||
DUMMY_JoystickHasLED,
|
||||
DUMMY_JoystickGetCapabilities,
|
||||
DUMMY_JoystickSetLED,
|
||||
DUMMY_JoystickSendEffect,
|
||||
DUMMY_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -414,10 +414,10 @@ EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
|||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
EMSCRIPTEN_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
EMSCRIPTEN_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -451,7 +451,7 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver =
|
|||
EMSCRIPTEN_JoystickOpen,
|
||||
EMSCRIPTEN_JoystickRumble,
|
||||
EMSCRIPTEN_JoystickRumbleTriggers,
|
||||
EMSCRIPTEN_JoystickHasLED,
|
||||
EMSCRIPTEN_JoystickGetCapabilities,
|
||||
EMSCRIPTEN_JoystickSetLED,
|
||||
EMSCRIPTEN_JoystickSendEffect,
|
||||
EMSCRIPTEN_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -271,9 +271,9 @@ extern "C"
|
|||
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)
|
||||
|
@ -305,7 +305,7 @@ extern "C"
|
|||
HAIKU_JoystickOpen,
|
||||
HAIKU_JoystickRumble,
|
||||
HAIKU_JoystickRumbleTriggers,
|
||||
HAIKU_JoystickHasLED,
|
||||
HAIKU_JoystickGetCapabilities,
|
||||
HAIKU_JoystickSetLED,
|
||||
HAIKU_JoystickSendEffect,
|
||||
HAIKU_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -464,10 +464,10 @@ HIDAPI_DriverGameCube_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joys
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverGameCube_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverGameCube_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -532,7 +532,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube =
|
|||
HIDAPI_DriverGameCube_OpenJoystick,
|
||||
HIDAPI_DriverGameCube_RumbleJoystick,
|
||||
HIDAPI_DriverGameCube_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverGameCube_HasJoystickLED,
|
||||
HIDAPI_DriverGameCube_GetJoystickCapabilities,
|
||||
HIDAPI_DriverGameCube_SetJoystickLED,
|
||||
HIDAPI_DriverGameCube_SendJoystickEffect,
|
||||
HIDAPI_DriverGameCube_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -132,10 +132,10 @@ HIDAPI_DriverLuna_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverLuna_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -441,7 +441,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverLuna =
|
|||
HIDAPI_DriverLuna_OpenJoystick,
|
||||
HIDAPI_DriverLuna_RumbleJoystick,
|
||||
HIDAPI_DriverLuna_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverLuna_HasJoystickLED,
|
||||
HIDAPI_DriverLuna_GetJoystickCapabilities,
|
||||
HIDAPI_DriverLuna_SetJoystickLED,
|
||||
HIDAPI_DriverLuna_SendJoystickEffect,
|
||||
HIDAPI_DriverLuna_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -598,10 +598,10 @@ HIDAPI_DriverPS4_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverPS4_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverPS4_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_TRUE;
|
||||
return SDL_JOYCAP_LED;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -935,7 +935,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 =
|
|||
HIDAPI_DriverPS4_OpenJoystick,
|
||||
HIDAPI_DriverPS4_RumbleJoystick,
|
||||
HIDAPI_DriverPS4_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverPS4_HasJoystickLED,
|
||||
HIDAPI_DriverPS4_GetJoystickCapabilities,
|
||||
HIDAPI_DriverPS4_SetJoystickLED,
|
||||
HIDAPI_DriverPS4_SendJoystickEffect,
|
||||
HIDAPI_DriverPS4_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -663,10 +663,10 @@ HIDAPI_DriverPS5_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverPS5_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverPS5_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_TRUE;
|
||||
return SDL_JOYCAP_LED;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1098,7 +1098,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5 =
|
|||
HIDAPI_DriverPS5_OpenJoystick,
|
||||
HIDAPI_DriverPS5_RumbleJoystick,
|
||||
HIDAPI_DriverPS5_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverPS5_HasJoystickLED,
|
||||
HIDAPI_DriverPS5_GetJoystickCapabilities,
|
||||
HIDAPI_DriverPS5_SetJoystickLED,
|
||||
HIDAPI_DriverPS5_SendJoystickEffect,
|
||||
HIDAPI_DriverPS5_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -126,10 +126,10 @@ HIDAPI_DriverStadia_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joysti
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverStadia_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverStadia_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -315,7 +315,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia =
|
|||
HIDAPI_DriverStadia_OpenJoystick,
|
||||
HIDAPI_DriverStadia_RumbleJoystick,
|
||||
HIDAPI_DriverStadia_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverStadia_HasJoystickLED,
|
||||
HIDAPI_DriverStadia_GetJoystickCapabilities,
|
||||
HIDAPI_DriverStadia_SetJoystickLED,
|
||||
HIDAPI_DriverStadia_SendJoystickEffect,
|
||||
HIDAPI_DriverStadia_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -1095,11 +1095,11 @@ HIDAPI_DriverSteam_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystic
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverSteam_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverSteam_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
/* You should use the full Steam Input API for LED support */
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1293,7 +1293,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam =
|
|||
HIDAPI_DriverSteam_OpenJoystick,
|
||||
HIDAPI_DriverSteam_RumbleJoystick,
|
||||
HIDAPI_DriverSteam_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverSteam_HasJoystickLED,
|
||||
HIDAPI_DriverSteam_GetJoystickCapabilities,
|
||||
HIDAPI_DriverSteam_SetJoystickLED,
|
||||
HIDAPI_DriverSteam_SendJoystickEffect,
|
||||
HIDAPI_DriverSteam_SetSensorsEnabled,
|
||||
|
|
|
@ -1106,11 +1106,11 @@ HIDAPI_DriverSwitch_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joysti
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverSwitch_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
/* Doesn't have an RGB LED, so don't return true here */
|
||||
return SDL_FALSE;
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1557,7 +1557,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch =
|
|||
HIDAPI_DriverSwitch_OpenJoystick,
|
||||
HIDAPI_DriverSwitch_RumbleJoystick,
|
||||
HIDAPI_DriverSwitch_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverSwitch_HasJoystickLED,
|
||||
HIDAPI_DriverSwitch_GetJoystickCapabilities,
|
||||
HIDAPI_DriverSwitch_SetJoystickLED,
|
||||
HIDAPI_DriverSwitch_SendJoystickEffect,
|
||||
HIDAPI_DriverSwitch_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -203,11 +203,11 @@ HIDAPI_DriverXbox360_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joyst
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverXbox360_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverXbox360_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
/* Doesn't have an RGB LED, so don't return true here */
|
||||
return SDL_FALSE;
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -346,7 +346,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 =
|
|||
HIDAPI_DriverXbox360_OpenJoystick,
|
||||
HIDAPI_DriverXbox360_RumbleJoystick,
|
||||
HIDAPI_DriverXbox360_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverXbox360_HasJoystickLED,
|
||||
HIDAPI_DriverXbox360_GetJoystickCapabilities,
|
||||
HIDAPI_DriverXbox360_SetJoystickLED,
|
||||
HIDAPI_DriverXbox360_SendJoystickEffect,
|
||||
HIDAPI_DriverXbox360_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -173,11 +173,11 @@ HIDAPI_DriverXbox360W_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joys
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverXbox360W_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverXbox360W_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
/* Doesn't have an RGB LED, so don't return true here */
|
||||
return SDL_FALSE;
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -343,7 +343,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W =
|
|||
HIDAPI_DriverXbox360W_OpenJoystick,
|
||||
HIDAPI_DriverXbox360W_RumbleJoystick,
|
||||
HIDAPI_DriverXbox360W_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverXbox360W_HasJoystickLED,
|
||||
HIDAPI_DriverXbox360W_GetJoystickCapabilities,
|
||||
HIDAPI_DriverXbox360W_SetJoystickLED,
|
||||
HIDAPI_DriverXbox360W_SendJoystickEffect,
|
||||
HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -422,12 +422,17 @@ HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joyst
|
|||
return HIDAPI_DriverXboxOne_UpdateRumble(device);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_DriverXboxOne_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_DriverXboxOne_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
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
|
||||
|
@ -1126,7 +1131,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne =
|
|||
HIDAPI_DriverXboxOne_OpenJoystick,
|
||||
HIDAPI_DriverXboxOne_RumbleJoystick,
|
||||
HIDAPI_DriverXboxOne_RumbleJoystickTriggers,
|
||||
HIDAPI_DriverXboxOne_HasJoystickLED,
|
||||
HIDAPI_DriverXboxOne_GetJoystickCapabilities,
|
||||
HIDAPI_DriverXboxOne_SetJoystickLED,
|
||||
HIDAPI_DriverXboxOne_SendJoystickEffect,
|
||||
HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled,
|
||||
|
|
|
@ -894,15 +894,15 @@ HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
|
|||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HIDAPI_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
HIDAPI_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_bool result = SDL_FALSE;
|
||||
Uint32 result = 0;
|
||||
|
||||
if (joystick->hwdata) {
|
||||
SDL_HIDAPI_Device *device = joystick->hwdata->device;
|
||||
|
||||
result = device->driver->HasJoystickLED(device, joystick);
|
||||
result = device->driver->GetJoystickCapabilities(device, joystick);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1042,7 +1042,7 @@ SDL_JoystickDriver SDL_HIDAPI_JoystickDriver =
|
|||
HIDAPI_JoystickOpen,
|
||||
HIDAPI_JoystickRumble,
|
||||
HIDAPI_JoystickRumbleTriggers,
|
||||
HIDAPI_JoystickHasLED,
|
||||
HIDAPI_JoystickGetCapabilities,
|
||||
HIDAPI_JoystickSetLED,
|
||||
HIDAPI_JoystickSendEffect,
|
||||
HIDAPI_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -97,7 +97,7 @@ typedef struct _SDL_HIDAPI_DeviceDriver
|
|||
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 (*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 (*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);
|
||||
|
|
|
@ -1326,28 +1326,30 @@ IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri
|
|||
#endif
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
IOS_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
IOS_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
Uint32 result = 0;
|
||||
|
||||
#ifdef ENABLE_MFI_LIGHT
|
||||
@autoreleasepool {
|
||||
SDL_JoystickDeviceItem *device = joystick->hwdata;
|
||||
|
||||
if (device == NULL) {
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCController *controller = device->controller;
|
||||
GCDeviceLight *light = controller.light;
|
||||
if (light) {
|
||||
return SDL_TRUE;
|
||||
result |= SDL_JOYCAP_LED;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_MFI_LIGHT */
|
||||
|
||||
return SDL_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1751,7 +1753,7 @@ SDL_JoystickDriver SDL_IOS_JoystickDriver =
|
|||
IOS_JoystickOpen,
|
||||
IOS_JoystickRumble,
|
||||
IOS_JoystickRumbleTriggers,
|
||||
IOS_JoystickHasLED,
|
||||
IOS_JoystickGetCapabilities,
|
||||
IOS_JoystickSetLED,
|
||||
IOS_JoystickSendEffect,
|
||||
IOS_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -1190,10 +1190,10 @@ LINUX_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
LINUX_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
LINUX_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1790,7 +1790,7 @@ SDL_JoystickDriver SDL_LINUX_JoystickDriver =
|
|||
LINUX_JoystickOpen,
|
||||
LINUX_JoystickRumble,
|
||||
LINUX_JoystickRumbleTriggers,
|
||||
LINUX_JoystickHasLED,
|
||||
LINUX_JoystickGetCapabilities,
|
||||
LINUX_JoystickSetLED,
|
||||
LINUX_JoystickSendEffect,
|
||||
LINUX_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -472,9 +472,9 @@ static int OS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble
|
|||
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)
|
||||
|
@ -777,7 +777,7 @@ SDL_JoystickDriver SDL_OS2_JoystickDriver =
|
|||
OS2_JoystickOpen,
|
||||
OS2_JoystickRumble,
|
||||
OS2_JoystickRumbleTriggers,
|
||||
OS2_JoystickHasLED,
|
||||
OS2_JoystickGetCapabilities,
|
||||
OS2_JoystickSetLED,
|
||||
OS2_JoystickSendEffect,
|
||||
OS2_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -209,9 +209,9 @@ PSP_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri
|
|||
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
|
||||
|
@ -311,7 +311,7 @@ SDL_JoystickDriver SDL_PSP_JoystickDriver =
|
|||
PSP_JoystickOpen,
|
||||
PSP_JoystickRumble,
|
||||
PSP_JoystickRumbleTriggers,
|
||||
PSP_JoystickHasLED,
|
||||
PSP_JoystickGetCapabilities,
|
||||
PSP_JoystickSetLED,
|
||||
PSP_JoystickSendEffect,
|
||||
PSP_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -345,10 +345,10 @@ VIRTUAL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
|
|||
}
|
||||
|
||||
|
||||
static SDL_bool
|
||||
VIRTUAL_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
VIRTUAL_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -442,7 +442,7 @@ SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver =
|
|||
VIRTUAL_JoystickOpen,
|
||||
VIRTUAL_JoystickRumble,
|
||||
VIRTUAL_JoystickRumbleTriggers,
|
||||
VIRTUAL_JoystickHasLED,
|
||||
VIRTUAL_JoystickGetCapabilities,
|
||||
VIRTUAL_JoystickSetLED,
|
||||
VIRTUAL_JoystickSendEffect,
|
||||
VIRTUAL_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -365,11 +365,11 @@ VITA_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right)
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
VITA_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
VITA_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
// always return true for now
|
||||
return SDL_TRUE;
|
||||
// always return LED supported for now
|
||||
return SDL_JOYCAP_LED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,7 +409,7 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver =
|
|||
VITA_JoystickRumble,
|
||||
VITA_JoystickRumbleTriggers,
|
||||
|
||||
VITA_JoystickHasLED,
|
||||
VITA_JoystickGetCapabilities,
|
||||
VITA_JoystickSetLED,
|
||||
VITA_JoystickSendEffect,
|
||||
VITA_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -924,6 +924,12 @@ SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
|
|||
return 0;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Uint8
|
||||
TranslatePOV(DWORD value)
|
||||
{
|
||||
|
@ -1168,6 +1174,12 @@ SDL_DINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_DINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DINPUT_JoystickUpdate(SDL_Joystick * joystick)
|
||||
{
|
||||
|
|
|
@ -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 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);
|
||||
|
|
|
@ -334,9 +334,9 @@ WINMM_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16
|
|||
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
|
||||
|
@ -500,7 +500,7 @@ SDL_JoystickDriver SDL_WINMM_JoystickDriver =
|
|||
WINMM_JoystickOpen,
|
||||
WINMM_JoystickRumble,
|
||||
WINMM_JoystickRumbleTriggers,
|
||||
WINMM_JoystickHasLED,
|
||||
WINMM_JoystickGetCapabilities,
|
||||
WINMM_JoystickSetLED,
|
||||
WINMM_JoystickSendEffect,
|
||||
WINMM_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -1277,10 +1277,10 @@ RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint
|
|||
#endif
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
RAWINPUT_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
RAWINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1928,7 +1928,7 @@ SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver =
|
|||
RAWINPUT_JoystickOpen,
|
||||
RAWINPUT_JoystickRumble,
|
||||
RAWINPUT_JoystickRumbleTriggers,
|
||||
RAWINPUT_JoystickHasLED,
|
||||
RAWINPUT_JoystickGetCapabilities,
|
||||
RAWINPUT_JoystickSetLED,
|
||||
RAWINPUT_JoystickSendEffect,
|
||||
RAWINPUT_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -665,10 +665,10 @@ WGI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 ri
|
|||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WGI_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
WGI_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -876,7 +876,7 @@ SDL_JoystickDriver SDL_WGI_JoystickDriver =
|
|||
WGI_JoystickOpen,
|
||||
WGI_JoystickRumble,
|
||||
WGI_JoystickRumbleTriggers,
|
||||
WGI_JoystickHasLED,
|
||||
WGI_JoystickGetCapabilities,
|
||||
WGI_JoystickSetLED,
|
||||
WGI_JoystickSendEffect,
|
||||
WGI_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -658,10 +658,14 @@ WINDOWS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WINDOWS_JoystickHasLED(SDL_Joystick *joystick)
|
||||
static Uint32
|
||||
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
|
||||
|
@ -758,7 +762,7 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver =
|
|||
WINDOWS_JoystickOpen,
|
||||
WINDOWS_JoystickRumble,
|
||||
WINDOWS_JoystickRumbleTriggers,
|
||||
WINDOWS_JoystickHasLED,
|
||||
WINDOWS_JoystickGetCapabilities,
|
||||
WINDOWS_JoystickSetLED,
|
||||
WINDOWS_JoystickSendEffect,
|
||||
WINDOWS_JoystickSetSensorsEnabled,
|
||||
|
|
|
@ -503,6 +503,12 @@ SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
|
|||
return 0;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
|
||||
{
|
||||
|
@ -579,6 +585,12 @@ SDL_XINPUT_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble,
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick * joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ 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);
|
||||
|
|
Loading…
Reference in New Issue