Added SDL_GetJoystickCaps() and SDL_GetGamepadCaps() to get the capabilities of controllers
Also added SDL_GAMEPAD_CAP_PLAYER_LED to let the application know if the controller has a visible player LED
This commit is contained in:
@@ -459,7 +459,7 @@ static Uint32 HIDAPI_DriverGameCube_GetJoystickCapabilities(SDL_HIDAPI_Device *d
|
||||
for (i = 0; i < MAX_CONTROLLERS; i += 1) {
|
||||
if (joystick->instance_id == ctx->joysticks[i]) {
|
||||
if (!ctx->wireless[i] && ctx->rumbleAllowed[i]) {
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ static Uint32 HIDAPI_DriverLuna_GetJoystickCapabilities(SDL_HIDAPI_Device *devic
|
||||
|
||||
#ifdef ENABLE_LUNA_BLUETOOTH_RUMBLE
|
||||
if (device->product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER) {
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ static int HIDAPI_DriverPS3_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SD
|
||||
|
||||
static Uint32 HIDAPI_DriverPS3_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_JOYCAP_RUMBLE;
|
||||
return SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverPS3_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
@@ -869,10 +869,10 @@ static Uint32 HIDAPI_DriverPS4_GetJoystickCapabilities(SDL_HIDAPI_Device *device
|
||||
|
||||
if (ctx->enhanced_mode_available) {
|
||||
if (ctx->lightbar_supported) {
|
||||
result |= SDL_JOYCAP_LED;
|
||||
result |= SDL_JOYSTICK_CAP_RGB_LED;
|
||||
}
|
||||
if (ctx->vibration_supported) {
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1000,10 +1000,13 @@ static Uint32 HIDAPI_DriverPS5_GetJoystickCapabilities(SDL_HIDAPI_Device *device
|
||||
|
||||
if (ctx->enhanced_mode_available) {
|
||||
if (ctx->lightbar_supported) {
|
||||
result |= SDL_JOYCAP_LED;
|
||||
result |= SDL_JOYSTICK_CAP_RGB_LED;
|
||||
}
|
||||
if (ctx->playerled_supported) {
|
||||
result |= SDL_JOYSTICK_CAP_PLAYER_LED;
|
||||
}
|
||||
if (ctx->vibration_supported) {
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ static int HIDAPI_DriverShield_RumbleJoystickTriggers(SDL_HIDAPI_Device *device,
|
||||
|
||||
static Uint32 HIDAPI_DriverShield_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_JOYCAP_RUMBLE;
|
||||
return SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverShield_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
@@ -147,7 +147,7 @@ static Uint32 HIDAPI_DriverStadia_GetJoystickCapabilities(SDL_HIDAPI_Device *dev
|
||||
Uint32 caps = 0;
|
||||
|
||||
if (ctx->rumble_supported) {
|
||||
caps |= SDL_JOYCAP_RUMBLE;
|
||||
caps |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
return caps;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ static int HIDAPI_DriverSteamDeck_RumbleJoystickTriggers(SDL_HIDAPI_Device *devi
|
||||
|
||||
static Uint32 HIDAPI_DriverSteamDeck_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_JOYCAP_RUMBLE;
|
||||
return SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverSteamDeck_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
@@ -1577,12 +1577,16 @@ static Uint32 HIDAPI_DriverSwitch_GetJoystickCapabilities(SDL_HIDAPI_Device *dev
|
||||
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
||||
Uint32 result = 0;
|
||||
|
||||
if (ctx->m_bPlayerLights && !ctx->m_bInputOnly) {
|
||||
result |= SDL_JOYSTICK_CAP_PLAYER_LED;
|
||||
}
|
||||
|
||||
if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_ProController && !ctx->m_bInputOnly) {
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYSTICK_CAP_RGB_LED here */
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
} else if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft ||
|
||||
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ static int HIDAPI_DriverWii_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SD
|
||||
|
||||
static Uint32 HIDAPI_DriverWii_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
return SDL_JOYCAP_RUMBLE;
|
||||
return SDL_JOYSTICK_CAP_RUMBLE;
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverWii_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
@@ -115,7 +115,7 @@ static SDL_bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, SDL_bool on)
|
||||
|
||||
static void UpdateSlotLED(SDL_DriverXbox360_Context *ctx)
|
||||
{
|
||||
if (ctx->player_lights) {
|
||||
if (ctx->player_lights && ctx->player_index >= 0) {
|
||||
SetSlotLED(ctx->device->dev, (ctx->player_index % 4), SDL_TRUE);
|
||||
} else {
|
||||
SetSlotLED(ctx->device->dev, 0, SDL_FALSE);
|
||||
@@ -240,8 +240,13 @@ static int HIDAPI_DriverXbox360_RumbleJoystickTriggers(SDL_HIDAPI_Device *device
|
||||
|
||||
static Uint32 HIDAPI_DriverXbox360_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
|
||||
return SDL_JOYCAP_RUMBLE;
|
||||
SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context;
|
||||
Uint32 result = SDL_JOYSTICK_CAP_RUMBLE;
|
||||
|
||||
if (ctx->player_lights) {
|
||||
result |= SDL_JOYSTICK_CAP_PLAYER_LED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverXbox360_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
@@ -87,7 +87,7 @@ static SDL_bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, SDL_bool on)
|
||||
|
||||
static void UpdateSlotLED(SDL_DriverXbox360W_Context *ctx)
|
||||
{
|
||||
if (ctx->player_lights) {
|
||||
if (ctx->player_lights && ctx->player_index >= 0) {
|
||||
SetSlotLED(ctx->device->dev, (ctx->player_index % 4), SDL_TRUE);
|
||||
} else {
|
||||
SetSlotLED(ctx->device->dev, 0, SDL_FALSE);
|
||||
@@ -210,8 +210,13 @@ static int HIDAPI_DriverXbox360W_RumbleJoystickTriggers(SDL_HIDAPI_Device *devic
|
||||
|
||||
static Uint32 HIDAPI_DriverXbox360W_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||
{
|
||||
/* Doesn't have an RGB LED, so don't return SDL_JOYCAP_LED here */
|
||||
return SDL_JOYCAP_RUMBLE;
|
||||
SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context;
|
||||
Uint32 result = SDL_JOYSTICK_CAP_RUMBLE;
|
||||
|
||||
if (ctx->player_lights) {
|
||||
result |= SDL_JOYSTICK_CAP_PLAYER_LED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int HIDAPI_DriverXbox360W_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
@@ -540,13 +540,13 @@ static Uint32 HIDAPI_DriverXboxOne_GetJoystickCapabilities(SDL_HIDAPI_Device *de
|
||||
SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context;
|
||||
Uint32 result = 0;
|
||||
|
||||
result |= SDL_JOYCAP_RUMBLE;
|
||||
result |= SDL_JOYSTICK_CAP_RUMBLE;
|
||||
if (ctx->has_trigger_rumble) {
|
||||
result |= SDL_JOYCAP_RUMBLE_TRIGGERS;
|
||||
result |= SDL_JOYSTICK_CAP_TRIGGER_RUMBLE;
|
||||
}
|
||||
|
||||
if (ctx->has_color_led) {
|
||||
result |= SDL_JOYCAP_LED;
|
||||
result |= SDL_JOYSTICK_CAP_RGB_LED;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user