Added the events SDL_EVENT_JOYSTICK_UPDATE_COMPLETE and SDL_EVENT_GAMEPAD_UPDATE_COMPLETE

This allows the application to tell when a joystick polling cycle is complete and can process state changes as a single atomic update. It is disabled by default, at least for now.
This commit is contained in:
Sam Lantinga
2023-06-21 13:59:53 -07:00
parent 808d83dd67
commit 4c9fb3e169
5 changed files with 67 additions and 2 deletions

View File

@@ -151,6 +151,7 @@ typedef enum
SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */
SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */
SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete (disabled by default) */
/* Gamepad events */
SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */
@@ -163,6 +164,7 @@ typedef enum
SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, /**< Gamepad touchpad finger was moved */
SDL_EVENT_GAMEPAD_TOUCHPAD_UP, /**< Gamepad touchpad finger was lifted */
SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */
SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete (disabled by default) */
/* Touch events */
SDL_EVENT_FINGER_DOWN = 0x700,
@@ -398,7 +400,7 @@ typedef struct SDL_JoyButtonEvent
*/
typedef struct SDL_JoyDeviceEvent
{
Uint32 type; /**< ::SDL_EVENT_JOYSTICK_ADDED or ::SDL_EVENT_JOYSTICK_REMOVED */
Uint32 type; /**< ::SDL_EVENT_JOYSTICK_ADDED or ::SDL_EVENT_JOYSTICK_REMOVED or ::SDL_EVENT_JOYSTICK_UPDATE_COMPLETE */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
} SDL_JoyDeviceEvent;
@@ -451,7 +453,7 @@ typedef struct SDL_GamepadButtonEvent
*/
typedef struct SDL_GamepadDeviceEvent
{
Uint32 type; /**< ::SDL_EVENT_GAMEPAD_ADDED, ::SDL_EVENT_GAMEPAD_REMOVED, or ::SDL_EVENT_GAMEPAD_REMAPPED */
Uint32 type; /**< ::SDL_EVENT_GAMEPAD_ADDED, ::SDL_EVENT_GAMEPAD_REMOVED, or ::SDL_EVENT_GAMEPAD_REMAPPED or ::SDL_EVENT_GAMEPAD_UPDATE_COMPLETE */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
} SDL_GamepadDeviceEvent;