mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-26 01:04:17 +00:00
Initial support for hotplugging mice and keyboards
This commit is contained in:
@@ -143,12 +143,16 @@ typedef enum
|
||||
SDL_EVENT_TEXT_INPUT, /**< Keyboard text input */
|
||||
SDL_EVENT_KEYMAP_CHANGED, /**< Keymap changed due to a system event such as an
|
||||
input language or keyboard layout change. */
|
||||
SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */
|
||||
SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */
|
||||
|
||||
/* Mouse events */
|
||||
SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
|
||||
SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */
|
||||
SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */
|
||||
SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */
|
||||
SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */
|
||||
SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */
|
||||
|
||||
/* Joystick events */
|
||||
SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */
|
||||
@@ -270,6 +274,17 @@ typedef struct SDL_WindowEvent
|
||||
Sint32 data2; /**< event dependent data */
|
||||
} SDL_WindowEvent;
|
||||
|
||||
/**
|
||||
* Keyboard device event structure (event.kdevice.*)
|
||||
*/
|
||||
typedef struct SDL_KeyboardDeviceEvent
|
||||
{
|
||||
SDL_EventType type; /**< ::SDL_EVENT_KEYBOARD_ADDED or ::SDL_EVENT_KEYBOARD_REMOVED */
|
||||
Uint32 reserved;
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
SDL_KeyboardID which; /**< The keyboard instance id */
|
||||
} SDL_KeyboardDeviceEvent;
|
||||
|
||||
/**
|
||||
* Keyboard button event structure (event.key.*)
|
||||
*/
|
||||
@@ -279,6 +294,7 @@ typedef struct SDL_KeyboardEvent
|
||||
Uint32 reserved;
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
|
||||
SDL_KeyboardID which; /**< The keyboard instance id, or 0 if unknown or virtual */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 repeat; /**< Non-zero if this is a key repeat */
|
||||
Uint8 padding2;
|
||||
@@ -320,6 +336,17 @@ typedef struct SDL_TextInputEvent
|
||||
char *text; /**< The input text */
|
||||
} SDL_TextInputEvent;
|
||||
|
||||
/**
|
||||
* Mouse device event structure (event.mdevice.*)
|
||||
*/
|
||||
typedef struct SDL_MouseDeviceEvent
|
||||
{
|
||||
SDL_EventType type; /**< ::SDL_EVENT_MOUSE_ADDED or ::SDL_EVENT_MOUSE_REMOVED */
|
||||
Uint32 reserved;
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
SDL_MouseID which; /**< The mouse instance id */
|
||||
} SDL_MouseDeviceEvent;
|
||||
|
||||
/**
|
||||
* Mouse motion event structure (event.motion.*)
|
||||
*/
|
||||
@@ -718,21 +745,23 @@ typedef union SDL_Event
|
||||
SDL_CommonEvent common; /**< Common event data */
|
||||
SDL_DisplayEvent display; /**< Display event data */
|
||||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||
SDL_TextInputEvent text; /**< Text input event data */
|
||||
SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */
|
||||
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
|
||||
SDL_MouseButtonEvent button; /**< Mouse button event data */
|
||||
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
|
||||
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
|
||||
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
|
||||
SDL_JoyBallEvent jball; /**< Joystick ball event data */
|
||||
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
|
||||
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
|
||||
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
|
||||
SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
|
||||
SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */
|
||||
SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */
|
||||
SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */
|
||||
SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */
|
||||
SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */
|
||||
SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */
|
||||
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
|
||||
|
||||
@@ -389,6 +389,17 @@ extern DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
|
||||
|
||||
/**
|
||||
* Return whether a gamepad is currently connected.
|
||||
*
|
||||
* \returns SDL_TRUE if a gamepad is connected, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetGamepads
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasGamepad(void);
|
||||
|
||||
/**
|
||||
* Get a list of currently connected gamepads.
|
||||
*
|
||||
@@ -399,6 +410,7 @@ extern DECLSPEC int SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, co
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_HasGamepad
|
||||
* \sa SDL_OpenGamepad
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetGamepads(int *count);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef Uint32 SDL_KeyboardID;
|
||||
|
||||
/**
|
||||
* The SDL keysym structure, used in key events.
|
||||
*
|
||||
@@ -54,6 +56,31 @@ typedef struct SDL_Keysym
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* Return whether a keyboard is currently connected.
|
||||
*
|
||||
* \returns SDL_TRUE if a keyboard is connected, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyboards
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasKeyboard(void);
|
||||
|
||||
/**
|
||||
* Get a list of currently connected keyboards.
|
||||
*
|
||||
* \param count a pointer filled in with the number of keyboards returned
|
||||
* \returns a 0 terminated array of keyboards instance IDs which should be
|
||||
* freed with SDL_free(), or NULL on error; call SDL_GetError() for
|
||||
* more details.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_HasKeyboard
|
||||
*/
|
||||
extern DECLSPEC SDL_KeyboardID *SDLCALL SDL_GetKeyboards(int *count);
|
||||
|
||||
/**
|
||||
* Query the window which currently has keyboard focus.
|
||||
*
|
||||
|
||||
@@ -81,6 +81,31 @@ typedef enum
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* Return whether a mouse is currently connected.
|
||||
*
|
||||
* \returns SDL_TRUE if a mouse is connected, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetMice
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasMouse(void);
|
||||
|
||||
/**
|
||||
* Get a list of currently connected mice.
|
||||
*
|
||||
* \param count a pointer filled in with the number of mice returned
|
||||
* \returns a 0 terminated array of mouse instance IDs which should be
|
||||
* freed with SDL_free(), or NULL on error; call SDL_GetError() for
|
||||
* more details.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_HasMouse
|
||||
*/
|
||||
extern DECLSPEC SDL_MouseID *SDLCALL SDL_GetMice(int *count);
|
||||
|
||||
/**
|
||||
* Get the window which currently has mouse focus.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user