sdl (master post 3.1 preview) Merge commit 'e4f454091a943345938608570b104400f62fd625'

This commit is contained in:
2024-03-28 16:27:42 +01:00
862 changed files with 204894 additions and 45662 deletions

View File

@@ -137,6 +137,17 @@ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lo
*/
extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
/**
* Return whether a joystick is currently connected.
*
* \returns SDL_TRUE if a joystick is connected, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoysticks
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasJoystick(void);
/**
* Get a list of currently connected joysticks.
*
@@ -147,6 +158,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HasJoystick
* \sa SDL_OpenJoystick
*/
extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetJoysticks(int *count);
@@ -163,7 +175,7 @@ extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetJoysticks(int *count);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickName
* \sa SDL_OpenJoystick
* \sa SDL_GetJoysticks
*/
extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstanceName(SDL_JoystickID instance_id);
@@ -179,7 +191,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstanceName(SDL_JoystickID i
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickPath
* \sa SDL_OpenJoystick
* \sa SDL_GetJoysticks
*/
extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstancePath(SDL_JoystickID instance_id);
@@ -194,7 +206,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstancePath(SDL_JoystickID i
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickPlayerIndex
* \sa SDL_OpenJoystick
* \sa SDL_GetJoysticks
*/
extern DECLSPEC int SDLCALL SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID instance_id);
@@ -204,8 +216,8 @@ extern DECLSPEC int SDLCALL SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID in
* This can be called before any joysticks are opened.
*
* \param instance_id the joystick instance ID
* \returns the GUID of the selected joystick. If called on an invalid index,
* this function returns a zero GUID
* \returns the GUID of the selected joystick. If called with an invalid
* instance_id, this function returns a zero GUID.
*
* \since This function is available since SDL 3.0.0.
*
@@ -221,10 +233,13 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickInstanceGUID(SDL_Joystic
* available this function returns 0.
*
* \param instance_id the joystick instance ID
* \returns the USB vendor ID of the selected joystick. If called on an
* invalid index, this function returns zero
* \returns the USB vendor ID of the selected joystick. If called with an
* invalid instance_id, this function returns 0.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickVendor
* \sa SDL_GetJoysticks
*/
extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceVendor(SDL_JoystickID instance_id);
@@ -235,10 +250,13 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceVendor(SDL_JoystickID inst
* available this function returns 0.
*
* \param instance_id the joystick instance ID
* \returns the USB product ID of the selected joystick. If called on an
* invalid index, this function returns zero
* \returns the USB product ID of the selected joystick. If called with an
* invalid instance_id, this function returns 0.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickProduct
* \sa SDL_GetJoysticks
*/
extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProduct(SDL_JoystickID instance_id);
@@ -249,10 +267,13 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProduct(SDL_JoystickID ins
* isn't available this function returns 0.
*
* \param instance_id the joystick instance ID
* \returns the product version of the selected joystick. If called on an
* invalid index, this function returns zero
* \returns the product version of the selected joystick. If called with an
* invalid instance_id, this function returns 0.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickProductVersion
* \sa SDL_GetJoysticks
*/
extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProductVersion(SDL_JoystickID instance_id);
@@ -262,10 +283,14 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProductVersion(SDL_Joystic
* This can be called before any joysticks are opened.
*
* \param instance_id the joystick instance ID
* \returns the SDL_JoystickType of the selected joystick. If called on an
* invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
* \returns the SDL_JoystickType of the selected joystick. If called with an
* invalid instance_id, this function returns
* `SDL_JOYSTICK_TYPE_UNKNOWN`.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickType
* \sa SDL_GetJoysticks
*/
extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickInstanceType(SDL_JoystickID instance_id);
@@ -304,6 +329,9 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromInstanceID(SDL_Joystick
* for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickPlayerIndex
* \sa SDL_SetJoystickPlayerIndex
*/
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index);
@@ -318,6 +346,9 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromPlayerIndex(int player_
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AttachVirtualJoystickEx
* \sa SDL_DetachVirtualJoystick
*/
extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(SDL_JoystickType type,
int naxes,
@@ -371,6 +402,9 @@ typedef struct SDL_VirtualJoystickDesc
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AttachVirtualJoystick
* \sa SDL_DetachVirtualJoystick
*/
extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystickEx(const SDL_VirtualJoystickDesc *desc);
@@ -383,6 +417,9 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystickEx(const SDL_Vir
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AttachVirtualJoystick
* \sa SDL_AttachVirtualJoystickEx
*/
extern DECLSPEC int SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
@@ -460,6 +497,19 @@ 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.
@@ -471,6 +521,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.
*
@@ -481,7 +537,6 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickInstanceName
* \sa SDL_OpenJoystick
*/
extern DECLSPEC const char *SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick);
@@ -508,6 +563,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetJoystickPath(SDL_Joystick *joystick);
* \returns the player index, or -1 if it's not available.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetJoystickPlayerIndex
*/
extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
@@ -521,6 +578,8 @@ extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickPlayerIndex
*/
extern DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
@@ -550,6 +609,8 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joyst
* \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickInstanceVendor
*/
extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick);
@@ -562,6 +623,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick);
* \returns the USB product ID of the selected joystick, or 0 if unavailable.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickInstanceProduct
*/
extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick);
@@ -574,6 +637,8 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick);
* \returns the product version of the selected joystick, or 0 if unavailable.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickInstanceProductVersion
*/
extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *joystick);
@@ -610,6 +675,8 @@ extern DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystic
* \returns the SDL_JoystickType of the selected joystick.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickInstanceType
*/
extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick);
@@ -675,9 +742,6 @@ extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint
* call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CloseJoystick
* \sa SDL_OpenJoystick
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
@@ -689,8 +753,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_OpenJoystick
*/
extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickInstanceID(SDL_Joystick *joystick);
@@ -709,10 +771,33 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickInstanceID(SDL_Joystick *j
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickAxis
* \sa SDL_OpenJoystick
* \sa SDL_GetNumJoystickBalls
* \sa SDL_GetNumJoystickButtons
* \sa SDL_GetNumJoystickHats
*/
extern DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
/**
* Get the number of trackballs on a joystick.
*
* Joystick trackballs have only relative motion events associated with them
* and their state cannot be polled.
*
* Most joysticks do not have trackballs.
*
* \param joystick an SDL_Joystick structure containing joystick information
* \returns the number of trackballs on success or a negative error code on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickBall
* \sa SDL_GetNumJoystickAxes
* \sa SDL_GetNumJoystickButtons
* \sa SDL_GetNumJoystickHats
*/
extern DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
/**
* Get the number of POV hats on a joystick.
*
@@ -723,7 +808,9 @@ extern DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickHat
* \sa SDL_OpenJoystick
* \sa SDL_GetNumJoystickAxes
* \sa SDL_GetNumJoystickBalls
* \sa SDL_GetNumJoystickButtons
*/
extern DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
@@ -737,7 +824,9 @@ extern DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickButton
* \sa SDL_OpenJoystick
* \sa SDL_GetNumJoystickAxes
* \sa SDL_GetNumJoystickBalls
* \sa SDL_GetNumJoystickHats
*/
extern DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
@@ -753,6 +842,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_JoystickEventsEnabled
* \sa SDL_UpdateJoysticks
*/
extern DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(SDL_bool enabled);
@@ -804,8 +894,7 @@ extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
*
* \sa SDL_GetNumJoystickAxes
*/
extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick,
int axis);
extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
/**
* Get the initial state of an axis control on a joystick.
@@ -821,8 +910,28 @@ extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick,
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick,
int axis, Sint16 *state);
extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
/**
* Get the ball axis change since the last poll.
*
* Trackballs can only return relative motion since the last call to
* SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`.
*
* Most joysticks do not have trackballs.
*
* \param joystick the SDL_Joystick to query
* \param ball the ball index to query; ball indices start at index 0
* \param dx stores the difference in the x axis position since the last poll
* \param dy stores the difference in the y axis position since the last poll
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumJoystickBalls
*/
extern DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
/**
* \name Hat positions
@@ -862,8 +971,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *j
*
* \sa SDL_GetNumJoystickHats
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick,
int hat);
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
/**
* Get the current state of a button on a joystick.
@@ -877,8 +985,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick,
*
* \sa SDL_GetNumJoystickButtons
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick,
int button);
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button);
/**
* Start a rumble effect.
@@ -886,6 +993,9 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick,
* Each call to this function cancels any previous rumble effect, and calling
* it with 0 intensity stops any rumbling.
*
* This function requires you to process SDL events or call
* SDL_UpdateJoysticks() to update rumble state.
*
* \param joystick The joystick to vibrate
* \param low_frequency_rumble The intensity of the low frequency (left)
* rumble motor, from 0 to 0xFFFF
@@ -895,8 +1005,6 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(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_JoystickHasRumble
*/
extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
@@ -911,6 +1019,9 @@ extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 lo
* want the (more common) whole-controller rumble, use SDL_RumbleJoystick()
* instead.
*
* This function requires you to process SDL events or call
* SDL_UpdateJoysticks() to update rumble state.
*
* \param joystick The joystick to vibrate
* \param left_rumble The intensity of the left trigger rumble motor, from 0
* to 0xFFFF
@@ -922,47 +1033,9 @@ extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 lo
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_JoystickHasRumbleTriggers
*/
extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
/**
* Query whether a joystick has an LED.
*
* An example of a joystick LED is the light on the back of a PlayStation 4's
* DualShock 4 controller.
*
* \param joystick The joystick to query
* \returns SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE
* otherwise.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
/**
* Query whether a joystick has rumble support.
*
* \param joystick The joystick to query
* \returns SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_RumbleJoystick
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
/**
* Query whether a joystick has rumble support on triggers.
*
* \param joystick The joystick to query
* \returns SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_RumbleJoystickTriggers
*/
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick);
extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
/**
* Update a joystick's LED color.
@@ -970,6 +1043,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joy
* An example of a joystick LED is the light on the back of a PlayStation 4's
* DualShock 4 controller.
*
* For joysticks with a single color LED, the maximum of the RGB values will
* be used as the LED brightness.
*
* \param joystick The joystick to update
* \param red The intensity of the red LED
* \param green The intensity of the green LED