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

@@ -75,15 +75,6 @@ typedef enum
SDL_GAMEPAD_TYPE_MAX
} SDL_GamepadType;
typedef enum
{
SDL_GAMEPAD_CAP_MONO_LED = 0x00000001, /**< This gamepad has an LED that has adjustable brightness */
SDL_GAMEPAD_CAP_RGB_LED = 0x00000002, /**< This gamepad has an LED that has adjustable color */
SDL_GAMEPAD_CAP_PLAYER_LED = 0x00000004, /**< This gamepad has a player LED */
SDL_GAMEPAD_CAP_RUMBLE = 0x00000010, /**< This gamepad has left/right rumble */
SDL_GAMEPAD_CAP_TRIGGER_RUMBLE = 0x00000020, /**< This gamepad has simple trigger rumble */
} SDL_GamepadCaps;
/**
* The list of buttons available on a gamepad
*
@@ -603,6 +594,13 @@ extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_in
*
* These properties are shared with the underlying joystick object.
*
* The following read-only properties are provided by SDL:
* - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED that has adjustable brightness
* - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED that has adjustable color
* - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a player LED
* - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has left/right rumble
* - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has simple trigger rumble
*
* \param gamepad a gamepad identifier previously returned by
* SDL_OpenGamepad()
* \returns a valid property ID on success or 0 on failure; call
@@ -615,6 +613,12 @@ extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_in
*/
extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN
#define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
#define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN
#define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
#define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
/**
* Get the instance ID of an opened gamepad.
*
@@ -1178,17 +1182,6 @@ extern DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad,
*/
extern DECLSPEC int SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
/**
* Query gamepad capabilities
*
* \param gamepad The gamepad to query
* \returns a mask of SDL_GamepadCaps values indicating the gamepad
* capabilities.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetGamepadCaps(SDL_Gamepad *gamepad);
/**
* Start a rumble effect on a gamepad.
*
@@ -1204,8 +1197,6 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetGamepadCaps(SDL_Gamepad *gamepad);
* \returns 0, or -1 if rumble isn't supported on this gamepad
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetGamepadCaps
*/
extern DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@@ -1229,8 +1220,6 @@ extern DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_f
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetGamepadCaps
*/
extern DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
@@ -1251,8 +1240,6 @@ extern DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetGamepadCaps
*/
extern DECLSPEC int SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);

View File

@@ -97,15 +97,6 @@ typedef enum
SDL_JOYSTICK_TYPE_THROTTLE
} SDL_JoystickType;
typedef enum
{
SDL_JOYSTICK_CAP_MONO_LED = 0x00000001, /**< This joystick has an LED that has adjustable brightness */
SDL_JOYSTICK_CAP_RGB_LED = 0x00000002, /**< This joystick has an LED that has adjustable color */
SDL_JOYSTICK_CAP_PLAYER_LED = 0x00000004, /**< This joystick has a player LED */
SDL_JOYSTICK_CAP_RUMBLE = 0x00000010, /**< This joystick has left/right rumble */
SDL_JOYSTICK_CAP_TRIGGER_RUMBLE = 0x00000020, /**< This joystick has simple trigger rumble */
} SDL_JoystickCaps;
typedef enum
{
SDL_JOYSTICK_POWER_UNKNOWN = -1,
@@ -469,6 +460,13 @@ extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, in
/**
* Get the properties associated with a joystick.
*
* The following read-only properties are provided by SDL:
* - `SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`: true if this joystick has an LED that has adjustable brightness
* - `SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`: true if this joystick has an LED that has adjustable color
* - `SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`: true if this joystick has a player LED
* - `SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`: true if this joystick has left/right rumble
* - `SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this joystick has simple trigger rumble
*
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
@@ -480,6 +478,12 @@ extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, in
*/
extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick);
#define SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN "SDL.joystick.cap.mono_led"
#define SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN "SDL.joystick.cap.rgb_led"
#define SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN "SDL.joystick.cap.player_led"
#define SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN "SDL.joystick.cap.rumble"
#define SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN "SDL.joystick.cap.trigger_rumble"
/**
* Get the implementation dependent name of a joystick.
*
@@ -889,17 +893,6 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick,
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick,
int button);
/**
* Query joystick capabilities
*
* \param joystick The joystick to query
* \returns a mask of SDL_JoystickCaps values indicating the joystick
* capabilities.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetJoystickCaps(SDL_Joystick *joystick);
/**
* Start a rumble effect.
*
@@ -915,8 +908,6 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetJoystickCaps(SDL_Joystick *joystick);
* \returns 0, or -1 if rumble isn't supported on this joystick
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickCaps
*/
extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@@ -941,8 +932,6 @@ extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 lo
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickCaps
*/
extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
@@ -963,8 +952,6 @@ extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, U
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickCaps
*/
extern DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);