Path: blob/master/thirdparty/sdl/include/SDL3/SDL_events.h
9912 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* # CategoryEvents23*24* Event queue management.25*26* It's extremely common--often required--that an app deal with SDL's event27* queue. Almost all useful information about interactions with the real world28* flow through here: the user interacting with the computer and app, hardware29* coming and going, the system changing in some way, etc.30*31* An app generally takes a moment, perhaps at the start of a new frame, to32* examine any events that have occured since the last time and process or33* ignore them. This is generally done by calling SDL_PollEvent() in a loop34* until it returns false (or, if using the main callbacks, events are35* provided one at a time in calls to SDL_AppEvent() before the next call to36* SDL_AppIterate(); in this scenario, the app does not call SDL_PollEvent()37* at all).38*39* There is other forms of control, too: SDL_PeepEvents() has more40* functionality at the cost of more complexity, and SDL_WaitEvent() can block41* the process until something interesting happens, which might be beneficial42* for certain types of programs on low-power hardware. One may also call43* SDL_AddEventWatch() to set a callback when new events arrive.44*45* The app is free to generate their own events, too: SDL_PushEvent allows the46* app to put events onto the queue for later retrieval; SDL_RegisterEvents47* can guarantee that these events have a type that isn't in use by other48* parts of the system.49*/5051#ifndef SDL_events_h_52#define SDL_events_h_5354#include <SDL3/SDL_stdinc.h>55#include <SDL3/SDL_audio.h>56#include <SDL3/SDL_camera.h>57#include <SDL3/SDL_error.h>58#include <SDL3/SDL_gamepad.h>59#include <SDL3/SDL_joystick.h>60#include <SDL3/SDL_keyboard.h>61#include <SDL3/SDL_keycode.h>62#include <SDL3/SDL_mouse.h>63#include <SDL3/SDL_pen.h>64#include <SDL3/SDL_power.h>65#include <SDL3/SDL_sensor.h>66#include <SDL3/SDL_scancode.h>67#include <SDL3/SDL_touch.h>68#include <SDL3/SDL_video.h>6970#include <SDL3/SDL_begin_code.h>71/* Set up for C function definitions, even when using C++ */72#ifdef __cplusplus73extern "C" {74#endif7576/* General keyboard/mouse/pen state definitions */7778/**79* The types of events that can be delivered.80*81* \since This enum is available since SDL 3.2.0.82*/83typedef enum SDL_EventType84{85SDL_EVENT_FIRST = 0, /**< Unused (do not remove) */8687/* Application events */88SDL_EVENT_QUIT = 0x100, /**< User-requested quit */8990/* These application events have special meaning on iOS and Android, see README-ios.md and README-android.md for details */91SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch().92Called on iOS in applicationWillTerminate()93Called on Android in onDestroy()94*/95SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch().96Called on iOS in applicationDidReceiveMemoryWarning()97Called on Android in onTrimMemory()98*/99SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch().100Called on iOS in applicationWillResignActive()101Called on Android in onPause()102*/103SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch().104Called on iOS in applicationDidEnterBackground()105Called on Android in onPause()106*/107SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch().108Called on iOS in applicationWillEnterForeground()109Called on Android in onResume()110*/111SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch().112Called on iOS in applicationDidBecomeActive()113Called on Android in onResume()114*/115116SDL_EVENT_LOCALE_CHANGED, /**< The user's locale preferences have changed. */117118SDL_EVENT_SYSTEM_THEME_CHANGED, /**< The system theme changed */119120/* Display events */121/* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */122SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */123SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */124SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */125SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */126SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */127SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */128SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */129SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION,130SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED,131132/* Window events */133/* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */134/* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */135SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */136SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */137SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event */138SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */139SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */140SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */141SDL_EVENT_WINDOW_METAL_VIEW_RESIZED,/**< The pixel size of a Metal view associated with the window has changed */142SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */143SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */144SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */145SDL_EVENT_WINDOW_MOUSE_ENTER, /**< Window has gained mouse focus */146SDL_EVENT_WINDOW_MOUSE_LEAVE, /**< Window has lost mouse focus */147SDL_EVENT_WINDOW_FOCUS_GAINED, /**< Window has gained keyboard focus */148SDL_EVENT_WINDOW_FOCUS_LOST, /**< Window has lost keyboard focus */149SDL_EVENT_WINDOW_CLOSE_REQUESTED, /**< The window manager requests that the window be closed */150SDL_EVENT_WINDOW_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */151SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */152SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */153SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */154SDL_EVENT_WINDOW_SAFE_AREA_CHANGED, /**< The window safe area has been changed */155SDL_EVENT_WINDOW_OCCLUDED, /**< The window has been occluded */156SDL_EVENT_WINDOW_ENTER_FULLSCREEN, /**< The window has entered fullscreen mode */157SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, /**< The window has left fullscreen mode */158SDL_EVENT_WINDOW_DESTROYED, /**< The window with the associated ID is being or has been destroyed. If this message is being handled159in an event watcher, the window handle is still valid and can still be used to retrieve any properties160associated with the window. Otherwise, the handle has already been destroyed and all resources161associated with it are invalid */162SDL_EVENT_WINDOW_HDR_STATE_CHANGED, /**< Window HDR properties have changed */163SDL_EVENT_WINDOW_FIRST = SDL_EVENT_WINDOW_SHOWN,164SDL_EVENT_WINDOW_LAST = SDL_EVENT_WINDOW_HDR_STATE_CHANGED,165166/* Keyboard events */167SDL_EVENT_KEY_DOWN = 0x300, /**< Key pressed */168SDL_EVENT_KEY_UP, /**< Key released */169SDL_EVENT_TEXT_EDITING, /**< Keyboard text editing (composition) */170SDL_EVENT_TEXT_INPUT, /**< Keyboard text input */171SDL_EVENT_KEYMAP_CHANGED, /**< Keymap changed due to a system event such as an172input language or keyboard layout change. */173SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */174SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */175SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */176177/* Mouse events */178SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */179SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */180SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */181SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */182SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */183SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */184185/* Joystick events */186SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */187SDL_EVENT_JOYSTICK_BALL_MOTION, /**< Joystick trackball motion */188SDL_EVENT_JOYSTICK_HAT_MOTION, /**< Joystick hat position change */189SDL_EVENT_JOYSTICK_BUTTON_DOWN, /**< Joystick button pressed */190SDL_EVENT_JOYSTICK_BUTTON_UP, /**< Joystick button released */191SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */192SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */193SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */194SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */195196/* Gamepad events */197SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */198SDL_EVENT_GAMEPAD_BUTTON_DOWN, /**< Gamepad button pressed */199SDL_EVENT_GAMEPAD_BUTTON_UP, /**< Gamepad button released */200SDL_EVENT_GAMEPAD_ADDED, /**< A new gamepad has been inserted into the system */201SDL_EVENT_GAMEPAD_REMOVED, /**< A gamepad has been removed */202SDL_EVENT_GAMEPAD_REMAPPED, /**< The gamepad mapping was updated */203SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN, /**< Gamepad touchpad was touched */204SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, /**< Gamepad touchpad finger was moved */205SDL_EVENT_GAMEPAD_TOUCHPAD_UP, /**< Gamepad touchpad finger was lifted */206SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */207SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete */208SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED, /**< Gamepad Steam handle has changed */209210/* Touch events */211SDL_EVENT_FINGER_DOWN = 0x700,212SDL_EVENT_FINGER_UP,213SDL_EVENT_FINGER_MOTION,214SDL_EVENT_FINGER_CANCELED,215216/* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */217218/* Clipboard events */219SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard or primary selection changed */220221/* Drag and drop events */222SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */223SDL_EVENT_DROP_TEXT, /**< text/plain drag-and-drop event */224SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */225SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */226SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */227228/* Audio hotplug events */229SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */230SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */231SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED, /**< An audio device's format has been changed by the system. */232233/* Sensor events */234SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */235236/* Pressure-sensitive pen events */237SDL_EVENT_PEN_PROXIMITY_IN = 0x1300, /**< Pressure-sensitive pen has become available */238SDL_EVENT_PEN_PROXIMITY_OUT, /**< Pressure-sensitive pen has become unavailable */239SDL_EVENT_PEN_DOWN, /**< Pressure-sensitive pen touched drawing surface */240SDL_EVENT_PEN_UP, /**< Pressure-sensitive pen stopped touching drawing surface */241SDL_EVENT_PEN_BUTTON_DOWN, /**< Pressure-sensitive pen button pressed */242SDL_EVENT_PEN_BUTTON_UP, /**< Pressure-sensitive pen button released */243SDL_EVENT_PEN_MOTION, /**< Pressure-sensitive pen is moving on the tablet */244SDL_EVENT_PEN_AXIS, /**< Pressure-sensitive pen angle/pressure/etc changed */245246/* Camera hotplug events */247SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400, /**< A new camera device is available */248SDL_EVENT_CAMERA_DEVICE_REMOVED, /**< A camera device has been removed. */249SDL_EVENT_CAMERA_DEVICE_APPROVED, /**< A camera device has been approved for use by the user. */250SDL_EVENT_CAMERA_DEVICE_DENIED, /**< A camera device has been denied for use by the user. */251252/* Render events */253SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */254SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */255SDL_EVENT_RENDER_DEVICE_LOST, /**< The device has been lost and can't be recovered. */256257/* Reserved events for private platforms */258SDL_EVENT_PRIVATE0 = 0x4000,259SDL_EVENT_PRIVATE1,260SDL_EVENT_PRIVATE2,261SDL_EVENT_PRIVATE3,262263/* Internal events */264SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */265266/** Events SDL_EVENT_USER through SDL_EVENT_LAST are for your use,267* and should be allocated with SDL_RegisterEvents()268*/269SDL_EVENT_USER = 0x8000,270271/**272* This last event is only for bounding internal arrays273*/274SDL_EVENT_LAST = 0xFFFF,275276/* This just makes sure the enum is the size of Uint32 */277SDL_EVENT_ENUM_PADDING = 0x7FFFFFFF278279} SDL_EventType;280281/**282* Fields shared by every event283*284* \since This struct is available since SDL 3.2.0.285*/286typedef struct SDL_CommonEvent287{288Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */289Uint32 reserved;290Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */291} SDL_CommonEvent;292293/**294* Display state change event data (event.display.*)295*296* \since This struct is available since SDL 3.2.0.297*/298typedef struct SDL_DisplayEvent299{300SDL_EventType type; /**< SDL_DISPLAYEVENT_* */301Uint32 reserved;302Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */303SDL_DisplayID displayID;/**< The associated display */304Sint32 data1; /**< event dependent data */305Sint32 data2; /**< event dependent data */306} SDL_DisplayEvent;307308/**309* Window state change event data (event.window.*)310*311* \since This struct is available since SDL 3.2.0.312*/313typedef struct SDL_WindowEvent314{315SDL_EventType type; /**< SDL_EVENT_WINDOW_* */316Uint32 reserved;317Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */318SDL_WindowID windowID; /**< The associated window */319Sint32 data1; /**< event dependent data */320Sint32 data2; /**< event dependent data */321} SDL_WindowEvent;322323/**324* Keyboard device event structure (event.kdevice.*)325*326* \since This struct is available since SDL 3.2.0.327*/328typedef struct SDL_KeyboardDeviceEvent329{330SDL_EventType type; /**< SDL_EVENT_KEYBOARD_ADDED or SDL_EVENT_KEYBOARD_REMOVED */331Uint32 reserved;332Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */333SDL_KeyboardID which; /**< The keyboard instance id */334} SDL_KeyboardDeviceEvent;335336/**337* Keyboard button event structure (event.key.*)338*339* The `key` is the base SDL_Keycode generated by pressing the `scancode`340* using the current keyboard layout, applying any options specified in341* SDL_HINT_KEYCODE_OPTIONS. You can get the SDL_Keycode corresponding to the342* event scancode and modifiers directly from the keyboard layout, bypassing343* SDL_HINT_KEYCODE_OPTIONS, by calling SDL_GetKeyFromScancode().344*345* \since This struct is available since SDL 3.2.0.346*347* \sa SDL_GetKeyFromScancode348* \sa SDL_HINT_KEYCODE_OPTIONS349*/350typedef struct SDL_KeyboardEvent351{352SDL_EventType type; /**< SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP */353Uint32 reserved;354Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */355SDL_WindowID windowID; /**< The window with keyboard focus, if any */356SDL_KeyboardID which; /**< The keyboard instance id, or 0 if unknown or virtual */357SDL_Scancode scancode; /**< SDL physical key code */358SDL_Keycode key; /**< SDL virtual key code */359SDL_Keymod mod; /**< current key modifiers */360Uint16 raw; /**< The platform dependent scancode for this event */361bool down; /**< true if the key is pressed */362bool repeat; /**< true if this is a key repeat */363} SDL_KeyboardEvent;364365/**366* Keyboard text editing event structure (event.edit.*)367*368* The start cursor is the position, in UTF-8 characters, where new typing369* will be inserted into the editing text. The length is the number of UTF-8370* characters that will be replaced by new typing.371*372* \since This struct is available since SDL 3.2.0.373*/374typedef struct SDL_TextEditingEvent375{376SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING */377Uint32 reserved;378Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */379SDL_WindowID windowID; /**< The window with keyboard focus, if any */380const char *text; /**< The editing text */381Sint32 start; /**< The start cursor of selected editing text, or -1 if not set */382Sint32 length; /**< The length of selected editing text, or -1 if not set */383} SDL_TextEditingEvent;384385/**386* Keyboard IME candidates event structure (event.edit_candidates.*)387*388* \since This struct is available since SDL 3.2.0.389*/390typedef struct SDL_TextEditingCandidatesEvent391{392SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING_CANDIDATES */393Uint32 reserved;394Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */395SDL_WindowID windowID; /**< The window with keyboard focus, if any */396const char * const *candidates; /**< The list of candidates, or NULL if there are no candidates available */397Sint32 num_candidates; /**< The number of strings in `candidates` */398Sint32 selected_candidate; /**< The index of the selected candidate, or -1 if no candidate is selected */399bool horizontal; /**< true if the list is horizontal, false if it's vertical */400Uint8 padding1;401Uint8 padding2;402Uint8 padding3;403} SDL_TextEditingCandidatesEvent;404405/**406* Keyboard text input event structure (event.text.*)407*408* This event will never be delivered unless text input is enabled by calling409* SDL_StartTextInput(). Text input is disabled by default!410*411* \since This struct is available since SDL 3.2.0.412*413* \sa SDL_StartTextInput414* \sa SDL_StopTextInput415*/416typedef struct SDL_TextInputEvent417{418SDL_EventType type; /**< SDL_EVENT_TEXT_INPUT */419Uint32 reserved;420Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */421SDL_WindowID windowID; /**< The window with keyboard focus, if any */422const char *text; /**< The input text, UTF-8 encoded */423} SDL_TextInputEvent;424425/**426* Mouse device event structure (event.mdevice.*)427*428* \since This struct is available since SDL 3.2.0.429*/430typedef struct SDL_MouseDeviceEvent431{432SDL_EventType type; /**< SDL_EVENT_MOUSE_ADDED or SDL_EVENT_MOUSE_REMOVED */433Uint32 reserved;434Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */435SDL_MouseID which; /**< The mouse instance id */436} SDL_MouseDeviceEvent;437438/**439* Mouse motion event structure (event.motion.*)440*441* \since This struct is available since SDL 3.2.0.442*/443typedef struct SDL_MouseMotionEvent444{445SDL_EventType type; /**< SDL_EVENT_MOUSE_MOTION */446Uint32 reserved;447Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */448SDL_WindowID windowID; /**< The window with mouse focus, if any */449SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */450SDL_MouseButtonFlags state; /**< The current button state */451float x; /**< X coordinate, relative to window */452float y; /**< Y coordinate, relative to window */453float xrel; /**< The relative motion in the X direction */454float yrel; /**< The relative motion in the Y direction */455} SDL_MouseMotionEvent;456457/**458* Mouse button event structure (event.button.*)459*460* \since This struct is available since SDL 3.2.0.461*/462typedef struct SDL_MouseButtonEvent463{464SDL_EventType type; /**< SDL_EVENT_MOUSE_BUTTON_DOWN or SDL_EVENT_MOUSE_BUTTON_UP */465Uint32 reserved;466Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */467SDL_WindowID windowID; /**< The window with mouse focus, if any */468SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */469Uint8 button; /**< The mouse button index */470bool down; /**< true if the button is pressed */471Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */472Uint8 padding;473float x; /**< X coordinate, relative to window */474float y; /**< Y coordinate, relative to window */475} SDL_MouseButtonEvent;476477/**478* Mouse wheel event structure (event.wheel.*)479*480* \since This struct is available since SDL 3.2.0.481*/482typedef struct SDL_MouseWheelEvent483{484SDL_EventType type; /**< SDL_EVENT_MOUSE_WHEEL */485Uint32 reserved;486Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */487SDL_WindowID windowID; /**< The window with mouse focus, if any */488SDL_MouseID which; /**< The mouse instance id in relative mode or 0 */489float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */490float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */491SDL_MouseWheelDirection direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */492float mouse_x; /**< X coordinate, relative to window */493float mouse_y; /**< Y coordinate, relative to window */494Sint32 integer_x; /**< The amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12) */495Sint32 integer_y; /**< The amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12) */496} SDL_MouseWheelEvent;497498/**499* Joystick axis motion event structure (event.jaxis.*)500*501* \since This struct is available since SDL 3.2.0.502*/503typedef struct SDL_JoyAxisEvent504{505SDL_EventType type; /**< SDL_EVENT_JOYSTICK_AXIS_MOTION */506Uint32 reserved;507Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */508SDL_JoystickID which; /**< The joystick instance id */509Uint8 axis; /**< The joystick axis index */510Uint8 padding1;511Uint8 padding2;512Uint8 padding3;513Sint16 value; /**< The axis value (range: -32768 to 32767) */514Uint16 padding4;515} SDL_JoyAxisEvent;516517/**518* Joystick trackball motion event structure (event.jball.*)519*520* \since This struct is available since SDL 3.2.0.521*/522typedef struct SDL_JoyBallEvent523{524SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BALL_MOTION */525Uint32 reserved;526Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */527SDL_JoystickID which; /**< The joystick instance id */528Uint8 ball; /**< The joystick trackball index */529Uint8 padding1;530Uint8 padding2;531Uint8 padding3;532Sint16 xrel; /**< The relative motion in the X direction */533Sint16 yrel; /**< The relative motion in the Y direction */534} SDL_JoyBallEvent;535536/**537* Joystick hat position change event structure (event.jhat.*)538*539* \since This struct is available since SDL 3.2.0.540*/541typedef struct SDL_JoyHatEvent542{543SDL_EventType type; /**< SDL_EVENT_JOYSTICK_HAT_MOTION */544Uint32 reserved;545Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */546SDL_JoystickID which; /**< The joystick instance id */547Uint8 hat; /**< The joystick hat index */548Uint8 value; /**< The hat position value.549* \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP550* \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT551* \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN552*553* Note that zero means the POV is centered.554*/555Uint8 padding1;556Uint8 padding2;557} SDL_JoyHatEvent;558559/**560* Joystick button event structure (event.jbutton.*)561*562* \since This struct is available since SDL 3.2.0.563*/564typedef struct SDL_JoyButtonEvent565{566SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP */567Uint32 reserved;568Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */569SDL_JoystickID which; /**< The joystick instance id */570Uint8 button; /**< The joystick button index */571bool down; /**< true if the button is pressed */572Uint8 padding1;573Uint8 padding2;574} SDL_JoyButtonEvent;575576/**577* Joystick device event structure (event.jdevice.*)578*579* SDL will send JOYSTICK_ADDED events for devices that are already plugged in580* during SDL_Init.581*582* \since This struct is available since SDL 3.2.0.583*584* \sa SDL_GamepadDeviceEvent585*/586typedef struct SDL_JoyDeviceEvent587{588SDL_EventType type; /**< SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE */589Uint32 reserved;590Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */591SDL_JoystickID which; /**< The joystick instance id */592} SDL_JoyDeviceEvent;593594/**595* Joystick battery level change event structure (event.jbattery.*)596*597* \since This struct is available since SDL 3.2.0.598*/599typedef struct SDL_JoyBatteryEvent600{601SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BATTERY_UPDATED */602Uint32 reserved;603Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */604SDL_JoystickID which; /**< The joystick instance id */605SDL_PowerState state; /**< The joystick battery state */606int percent; /**< The joystick battery percent charge remaining */607} SDL_JoyBatteryEvent;608609/**610* Gamepad axis motion event structure (event.gaxis.*)611*612* \since This struct is available since SDL 3.2.0.613*/614typedef struct SDL_GamepadAxisEvent615{616SDL_EventType type; /**< SDL_EVENT_GAMEPAD_AXIS_MOTION */617Uint32 reserved;618Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */619SDL_JoystickID which; /**< The joystick instance id */620Uint8 axis; /**< The gamepad axis (SDL_GamepadAxis) */621Uint8 padding1;622Uint8 padding2;623Uint8 padding3;624Sint16 value; /**< The axis value (range: -32768 to 32767) */625Uint16 padding4;626} SDL_GamepadAxisEvent;627628629/**630* Gamepad button event structure (event.gbutton.*)631*632* \since This struct is available since SDL 3.2.0.633*/634typedef struct SDL_GamepadButtonEvent635{636SDL_EventType type; /**< SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP */637Uint32 reserved;638Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */639SDL_JoystickID which; /**< The joystick instance id */640Uint8 button; /**< The gamepad button (SDL_GamepadButton) */641bool down; /**< true if the button is pressed */642Uint8 padding1;643Uint8 padding2;644} SDL_GamepadButtonEvent;645646647/**648* Gamepad device event structure (event.gdevice.*)649*650* Joysticks that are supported gamepads receive both an SDL_JoyDeviceEvent651* and an SDL_GamepadDeviceEvent.652*653* SDL will send GAMEPAD_ADDED events for joysticks that are already plugged654* in during SDL_Init() and are recognized as gamepads. It will also send655* events for joysticks that get gamepad mappings at runtime.656*657* \since This struct is available since SDL 3.2.0.658*659* \sa SDL_JoyDeviceEvent660*/661typedef struct SDL_GamepadDeviceEvent662{663SDL_EventType type; /**< SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMOVED, or SDL_EVENT_GAMEPAD_REMAPPED, SDL_EVENT_GAMEPAD_UPDATE_COMPLETE or SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED */664Uint32 reserved;665Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */666SDL_JoystickID which; /**< The joystick instance id */667} SDL_GamepadDeviceEvent;668669/**670* Gamepad touchpad event structure (event.gtouchpad.*)671*672* \since This struct is available since SDL 3.2.0.673*/674typedef struct SDL_GamepadTouchpadEvent675{676SDL_EventType type; /**< SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP */677Uint32 reserved;678Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */679SDL_JoystickID which; /**< The joystick instance id */680Sint32 touchpad; /**< The index of the touchpad */681Sint32 finger; /**< The index of the finger on the touchpad */682float x; /**< Normalized in the range 0...1 with 0 being on the left */683float y; /**< Normalized in the range 0...1 with 0 being at the top */684float pressure; /**< Normalized in the range 0...1 */685} SDL_GamepadTouchpadEvent;686687/**688* Gamepad sensor event structure (event.gsensor.*)689*690* \since This struct is available since SDL 3.2.0.691*/692typedef struct SDL_GamepadSensorEvent693{694SDL_EventType type; /**< SDL_EVENT_GAMEPAD_SENSOR_UPDATE */695Uint32 reserved;696Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */697SDL_JoystickID which; /**< The joystick instance id */698Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */699float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */700Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */701} SDL_GamepadSensorEvent;702703/**704* Audio device event structure (event.adevice.*)705*706* \since This struct is available since SDL 3.2.0.707*/708typedef struct SDL_AudioDeviceEvent709{710SDL_EventType type; /**< SDL_EVENT_AUDIO_DEVICE_ADDED, or SDL_EVENT_AUDIO_DEVICE_REMOVED, or SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED */711Uint32 reserved;712Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */713SDL_AudioDeviceID which; /**< SDL_AudioDeviceID for the device being added or removed or changing */714bool recording; /**< false if a playback device, true if a recording device. */715Uint8 padding1;716Uint8 padding2;717Uint8 padding3;718} SDL_AudioDeviceEvent;719720/**721* Camera device event structure (event.cdevice.*)722*723* \since This struct is available since SDL 3.2.0.724*/725typedef struct SDL_CameraDeviceEvent726{727SDL_EventType type; /**< SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED */728Uint32 reserved;729Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */730SDL_CameraID which; /**< SDL_CameraID for the device being added or removed or changing */731} SDL_CameraDeviceEvent;732733734/**735* Renderer event structure (event.render.*)736*737* \since This struct is available since SDL 3.2.0.738*/739typedef struct SDL_RenderEvent740{741SDL_EventType type; /**< SDL_EVENT_RENDER_TARGETS_RESET, SDL_EVENT_RENDER_DEVICE_RESET, SDL_EVENT_RENDER_DEVICE_LOST */742Uint32 reserved;743Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */744SDL_WindowID windowID; /**< The window containing the renderer in question. */745} SDL_RenderEvent;746747748/**749* Touch finger event structure (event.tfinger.*)750*751* Coordinates in this event are normalized. `x` and `y` are normalized to a752* range between 0.0f and 1.0f, relative to the window, so (0,0) is the top753* left and (1,1) is the bottom right. Delta coordinates `dx` and `dy` are754* normalized in the ranges of -1.0f (traversed all the way from the bottom or755* right to all the way up or left) to 1.0f (traversed all the way from the756* top or left to all the way down or right).757*758* Note that while the coordinates are _normalized_, they are not _clamped_,759* which means in some circumstances you can get a value outside of this760* range. For example, a renderer using logical presentation might give a761* negative value when the touch is in the letterboxing. Some platforms might762* report a touch outside of the window, which will also be outside of the763* range.764*765* \since This struct is available since SDL 3.2.0.766*/767typedef struct SDL_TouchFingerEvent768{769SDL_EventType type; /**< SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED */770Uint32 reserved;771Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */772SDL_TouchID touchID; /**< The touch device id */773SDL_FingerID fingerID;774float x; /**< Normalized in the range 0...1 */775float y; /**< Normalized in the range 0...1 */776float dx; /**< Normalized in the range -1...1 */777float dy; /**< Normalized in the range -1...1 */778float pressure; /**< Normalized in the range 0...1 */779SDL_WindowID windowID; /**< The window underneath the finger, if any */780} SDL_TouchFingerEvent;781782/**783* Pressure-sensitive pen proximity event structure (event.pmotion.*)784*785* When a pen becomes visible to the system (it is close enough to a tablet,786* etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's787* ID. This ID is valid until the pen leaves proximity again (has been removed788* from the tablet's area, the tablet has been unplugged, etc). If the same789* pen reenters proximity again, it will be given a new ID.790*791* Note that "proximity" means "close enough for the tablet to know the tool792* is there." The pen touching and lifting off from the tablet while not793* leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP.794*795* \since This struct is available since SDL 3.2.0.796*/797typedef struct SDL_PenProximityEvent798{799SDL_EventType type; /**< SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT */800Uint32 reserved;801Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */802SDL_WindowID windowID; /**< The window with pen focus, if any */803SDL_PenID which; /**< The pen instance id */804} SDL_PenProximityEvent;805806/**807* Pressure-sensitive pen motion event structure (event.pmotion.*)808*809* Depending on the hardware, you may get motion events when the pen is not810* touching a tablet, for tracking a pen even when it isn't drawing. You811* should listen for SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP events, or check812* `pen_state & SDL_PEN_INPUT_DOWN` to decide if a pen is "drawing" when813* dealing with pen motion.814*815* \since This struct is available since SDL 3.2.0.816*/817typedef struct SDL_PenMotionEvent818{819SDL_EventType type; /**< SDL_EVENT_PEN_MOTION */820Uint32 reserved;821Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */822SDL_WindowID windowID; /**< The window with pen focus, if any */823SDL_PenID which; /**< The pen instance id */824SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */825float x; /**< X coordinate, relative to window */826float y; /**< Y coordinate, relative to window */827} SDL_PenMotionEvent;828829/**830* Pressure-sensitive pen touched event structure (event.ptouch.*)831*832* These events come when a pen touches a surface (a tablet, etc), or lifts833* off from one.834*835* \since This struct is available since SDL 3.2.0.836*/837typedef struct SDL_PenTouchEvent838{839SDL_EventType type; /**< SDL_EVENT_PEN_DOWN or SDL_EVENT_PEN_UP */840Uint32 reserved;841Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */842SDL_WindowID windowID; /**< The window with pen focus, if any */843SDL_PenID which; /**< The pen instance id */844SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */845float x; /**< X coordinate, relative to window */846float y; /**< Y coordinate, relative to window */847bool eraser; /**< true if eraser end is used (not all pens support this). */848bool down; /**< true if the pen is touching or false if the pen is lifted off */849} SDL_PenTouchEvent;850851/**852* Pressure-sensitive pen button event structure (event.pbutton.*)853*854* This is for buttons on the pen itself that the user might click. The pen855* itself pressing down to draw triggers a SDL_EVENT_PEN_DOWN event instead.856*857* \since This struct is available since SDL 3.2.0.858*/859typedef struct SDL_PenButtonEvent860{861SDL_EventType type; /**< SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP */862Uint32 reserved;863Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */864SDL_WindowID windowID; /**< The window with mouse focus, if any */865SDL_PenID which; /**< The pen instance id */866SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */867float x; /**< X coordinate, relative to window */868float y; /**< Y coordinate, relative to window */869Uint8 button; /**< The pen button index (first button is 1). */870bool down; /**< true if the button is pressed */871} SDL_PenButtonEvent;872873/**874* Pressure-sensitive pen pressure / angle event structure (event.paxis.*)875*876* You might get some of these events even if the pen isn't touching the877* tablet.878*879* \since This struct is available since SDL 3.2.0.880*/881typedef struct SDL_PenAxisEvent882{883SDL_EventType type; /**< SDL_EVENT_PEN_AXIS */884Uint32 reserved;885Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */886SDL_WindowID windowID; /**< The window with pen focus, if any */887SDL_PenID which; /**< The pen instance id */888SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */889float x; /**< X coordinate, relative to window */890float y; /**< Y coordinate, relative to window */891SDL_PenAxis axis; /**< Axis that has changed */892float value; /**< New value of axis */893} SDL_PenAxisEvent;894895/**896* An event used to drop text or request a file open by the system897* (event.drop.*)898*899* \since This struct is available since SDL 3.2.0.900*/901typedef struct SDL_DropEvent902{903SDL_EventType type; /**< SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION */904Uint32 reserved;905Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */906SDL_WindowID windowID; /**< The window that was dropped on, if any */907float x; /**< X coordinate, relative to window (not on begin) */908float y; /**< Y coordinate, relative to window (not on begin) */909const char *source; /**< The source app that sent this drop event, or NULL if that isn't available */910const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */911} SDL_DropEvent;912913/**914* An event triggered when the clipboard contents have changed915* (event.clipboard.*)916*917* \since This struct is available since SDL 3.2.0.918*/919typedef struct SDL_ClipboardEvent920{921SDL_EventType type; /**< SDL_EVENT_CLIPBOARD_UPDATE */922Uint32 reserved;923Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */924bool owner; /**< are we owning the clipboard (internal update) */925Sint32 num_mime_types; /**< number of mime types */926const char **mime_types; /**< current mime types */927} SDL_ClipboardEvent;928929/**930* Sensor event structure (event.sensor.*)931*932* \since This struct is available since SDL 3.2.0.933*/934typedef struct SDL_SensorEvent935{936SDL_EventType type; /**< SDL_EVENT_SENSOR_UPDATE */937Uint32 reserved;938Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */939SDL_SensorID which; /**< The instance ID of the sensor */940float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData() */941Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */942} SDL_SensorEvent;943944/**945* The "quit requested" event946*947* \since This struct is available since SDL 3.2.0.948*/949typedef struct SDL_QuitEvent950{951SDL_EventType type; /**< SDL_EVENT_QUIT */952Uint32 reserved;953Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */954} SDL_QuitEvent;955956/**957* A user-defined event type (event.user.*)958*959* This event is unique; it is never created by SDL, but only by the960* application. The event can be pushed onto the event queue using961* SDL_PushEvent(). The contents of the structure members are completely up to962* the programmer; the only requirement is that '''type''' is a value obtained963* from SDL_RegisterEvents().964*965* \since This struct is available since SDL 3.2.0.966*/967typedef struct SDL_UserEvent968{969Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */970Uint32 reserved;971Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */972SDL_WindowID windowID; /**< The associated window if any */973Sint32 code; /**< User defined event code */974void *data1; /**< User defined data pointer */975void *data2; /**< User defined data pointer */976} SDL_UserEvent;977978979/**980* The structure for all events in SDL.981*982* The SDL_Event structure is the core of all event handling in SDL. SDL_Event983* is a union of all event structures used in SDL.984*985* \since This struct is available since SDL 3.2.0.986*/987typedef union SDL_Event988{989Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */990SDL_CommonEvent common; /**< Common event data */991SDL_DisplayEvent display; /**< Display event data */992SDL_WindowEvent window; /**< Window event data */993SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */994SDL_KeyboardEvent key; /**< Keyboard event data */995SDL_TextEditingEvent edit; /**< Text editing event data */996SDL_TextEditingCandidatesEvent edit_candidates; /**< Text editing candidates event data */997SDL_TextInputEvent text; /**< Text input event data */998SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */999SDL_MouseMotionEvent motion; /**< Mouse motion event data */1000SDL_MouseButtonEvent button; /**< Mouse button event data */1001SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */1002SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */1003SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */1004SDL_JoyBallEvent jball; /**< Joystick ball event data */1005SDL_JoyHatEvent jhat; /**< Joystick hat event data */1006SDL_JoyButtonEvent jbutton; /**< Joystick button event data */1007SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */1008SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */1009SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */1010SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */1011SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */1012SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */1013SDL_AudioDeviceEvent adevice; /**< Audio device event data */1014SDL_CameraDeviceEvent cdevice; /**< Camera device event data */1015SDL_SensorEvent sensor; /**< Sensor event data */1016SDL_QuitEvent quit; /**< Quit request event data */1017SDL_UserEvent user; /**< Custom event data */1018SDL_TouchFingerEvent tfinger; /**< Touch finger event data */1019SDL_PenProximityEvent pproximity; /**< Pen proximity event data */1020SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */1021SDL_PenMotionEvent pmotion; /**< Pen motion event data */1022SDL_PenButtonEvent pbutton; /**< Pen button event data */1023SDL_PenAxisEvent paxis; /**< Pen axis event data */1024SDL_RenderEvent render; /**< Render event data */1025SDL_DropEvent drop; /**< Drag and drop event data */1026SDL_ClipboardEvent clipboard; /**< Clipboard event data */10271028/* This is necessary for ABI compatibility between Visual C++ and GCC.1029Visual C++ will respect the push pack pragma and use 52 bytes (size of1030SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit1031architectures) for this union, and GCC will use the alignment of the1032largest datatype within the union, which is 8 bytes on 64-bit1033architectures.10341035So... we'll add padding to force the size to be the same for both.10361037On architectures where pointers are 16 bytes, this needs rounding up to1038the next multiple of 16, 64, and on architectures where pointers are1039even larger the size of SDL_UserEvent will dominate as being 3 pointers.1040*/1041Uint8 padding[128];1042} SDL_Event;10431044/* Make sure we haven't broken binary compatibility */1045SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));104610471048/* Function prototypes */10491050/**1051* Pump the event loop, gathering events from the input devices.1052*1053* This function updates the event queue and internal input device state.1054*1055* SDL_PumpEvents() gathers all the pending input information from devices and1056* places it in the event queue. Without calls to SDL_PumpEvents() no events1057* would ever be placed on the queue. Often the need for calls to1058* SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and1059* SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not1060* polling or waiting for events (e.g. you are filtering them), then you must1061* call SDL_PumpEvents() to force an event queue update.1062*1063* \threadsafety This function should only be called on the main thread.1064*1065* \since This function is available since SDL 3.2.0.1066*1067* \sa SDL_PollEvent1068* \sa SDL_WaitEvent1069*/1070extern SDL_DECLSPEC void SDLCALL SDL_PumpEvents(void);10711072/* @{ */10731074/**1075* The type of action to request from SDL_PeepEvents().1076*1077* \since This enum is available since SDL 3.2.0.1078*/1079typedef enum SDL_EventAction1080{1081SDL_ADDEVENT, /**< Add events to the back of the queue. */1082SDL_PEEKEVENT, /**< Check but don't remove events from the queue front. */1083SDL_GETEVENT /**< Retrieve/remove events from the front of the queue. */1084} SDL_EventAction;10851086/**1087* Check the event queue for messages and optionally return them.1088*1089* `action` may be any of the following:1090*1091* - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the1092* event queue.1093* - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,1094* within the specified minimum and maximum type, will be returned to the1095* caller and will _not_ be removed from the queue. If you pass NULL for1096* `events`, then `numevents` is ignored and the total number of matching1097* events will be returned.1098* - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,1099* within the specified minimum and maximum type, will be returned to the1100* caller and will be removed from the queue.1101*1102* You may have to call SDL_PumpEvents() before calling this function.1103* Otherwise, the events may not be ready to be filtered when you call1104* SDL_PeepEvents().1105*1106* \param events destination buffer for the retrieved events, may be NULL to1107* leave the events in the queue and return the number of events1108* that would have been stored.1109* \param numevents if action is SDL_ADDEVENT, the number of events to add1110* back to the event queue; if action is SDL_PEEKEVENT or1111* SDL_GETEVENT, the maximum number of events to retrieve.1112* \param action action to take; see [Remarks](#remarks) for details.1113* \param minType minimum value of the event type to be considered;1114* SDL_EVENT_FIRST is a safe choice.1115* \param maxType maximum value of the event type to be considered;1116* SDL_EVENT_LAST is a safe choice.1117* \returns the number of events actually stored or -1 on failure; call1118* SDL_GetError() for more information.1119*1120* \threadsafety It is safe to call this function from any thread.1121*1122* \since This function is available since SDL 3.2.0.1123*1124* \sa SDL_PollEvent1125* \sa SDL_PumpEvents1126* \sa SDL_PushEvent1127*/1128extern SDL_DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType);1129/* @} */11301131/**1132* Check for the existence of a certain event type in the event queue.1133*1134* If you need to check for a range of event types, use SDL_HasEvents()1135* instead.1136*1137* \param type the type of event to be queried; see SDL_EventType for details.1138* \returns true if events matching `type` are present, or false if events1139* matching `type` are not present.1140*1141* \threadsafety It is safe to call this function from any thread.1142*1143* \since This function is available since SDL 3.2.0.1144*1145* \sa SDL_HasEvents1146*/1147extern SDL_DECLSPEC bool SDLCALL SDL_HasEvent(Uint32 type);114811491150/**1151* Check for the existence of certain event types in the event queue.1152*1153* If you need to check for a single event type, use SDL_HasEvent() instead.1154*1155* \param minType the low end of event type to be queried, inclusive; see1156* SDL_EventType for details.1157* \param maxType the high end of event type to be queried, inclusive; see1158* SDL_EventType for details.1159* \returns true if events with type >= `minType` and <= `maxType` are1160* present, or false if not.1161*1162* \threadsafety It is safe to call this function from any thread.1163*1164* \since This function is available since SDL 3.2.0.1165*1166* \sa SDL_HasEvents1167*/1168extern SDL_DECLSPEC bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);11691170/**1171* Clear events of a specific type from the event queue.1172*1173* This will unconditionally remove any events from the queue that match1174* `type`. If you need to remove a range of event types, use SDL_FlushEvents()1175* instead.1176*1177* It's also normal to just ignore events you don't care about in your event1178* loop without calling this function.1179*1180* This function only affects currently queued events. If you want to make1181* sure that all pending OS events are flushed, you can call SDL_PumpEvents()1182* on the main thread immediately before the flush call.1183*1184* If you have user events with custom data that needs to be freed, you should1185* use SDL_PeepEvents() to remove and clean up those events before calling1186* this function.1187*1188* \param type the type of event to be cleared; see SDL_EventType for details.1189*1190* \threadsafety It is safe to call this function from any thread.1191*1192* \since This function is available since SDL 3.2.0.1193*1194* \sa SDL_FlushEvents1195*/1196extern SDL_DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);11971198/**1199* Clear events of a range of types from the event queue.1200*1201* This will unconditionally remove any events from the queue that are in the1202* range of `minType` to `maxType`, inclusive. If you need to remove a single1203* event type, use SDL_FlushEvent() instead.1204*1205* It's also normal to just ignore events you don't care about in your event1206* loop without calling this function.1207*1208* This function only affects currently queued events. If you want to make1209* sure that all pending OS events are flushed, you can call SDL_PumpEvents()1210* on the main thread immediately before the flush call.1211*1212* \param minType the low end of event type to be cleared, inclusive; see1213* SDL_EventType for details.1214* \param maxType the high end of event type to be cleared, inclusive; see1215* SDL_EventType for details.1216*1217* \threadsafety It is safe to call this function from any thread.1218*1219* \since This function is available since SDL 3.2.0.1220*1221* \sa SDL_FlushEvent1222*/1223extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);12241225/**1226* Poll for currently pending events.1227*1228* If `event` is not NULL, the next event is removed from the queue and stored1229* in the SDL_Event structure pointed to by `event`. The 1 returned refers to1230* this event, immediately stored in the SDL Event structure -- not an event1231* to follow.1232*1233* If `event` is NULL, it simply returns 1 if there is an event in the queue,1234* but will not remove it from the queue.1235*1236* As this function may implicitly call SDL_PumpEvents(), you can only call1237* this function in the thread that set the video mode.1238*1239* SDL_PollEvent() is the favored way of receiving system events since it can1240* be done from the main loop and does not suspend the main loop while waiting1241* on an event to be posted.1242*1243* The common practice is to fully process the event queue once every frame,1244* usually as a first step before updating the game's state:1245*1246* ```c1247* while (game_is_still_running) {1248* SDL_Event event;1249* while (SDL_PollEvent(&event)) { // poll until all events are handled!1250* // decide what to do with this event.1251* }1252*1253* // update game state, draw the current frame1254* }1255* ```1256*1257* \param event the SDL_Event structure to be filled with the next event from1258* the queue, or NULL.1259* \returns true if this got an event or false if there are none available.1260*1261* \threadsafety This function should only be called on the main thread.1262*1263* \since This function is available since SDL 3.2.0.1264*1265* \sa SDL_PushEvent1266* \sa SDL_WaitEvent1267* \sa SDL_WaitEventTimeout1268*/1269extern SDL_DECLSPEC bool SDLCALL SDL_PollEvent(SDL_Event *event);12701271/**1272* Wait indefinitely for the next available event.1273*1274* If `event` is not NULL, the next event is removed from the queue and stored1275* in the SDL_Event structure pointed to by `event`.1276*1277* As this function may implicitly call SDL_PumpEvents(), you can only call1278* this function in the thread that initialized the video subsystem.1279*1280* \param event the SDL_Event structure to be filled in with the next event1281* from the queue, or NULL.1282* \returns true on success or false if there was an error while waiting for1283* events; call SDL_GetError() for more information.1284*1285* \threadsafety This function should only be called on the main thread.1286*1287* \since This function is available since SDL 3.2.0.1288*1289* \sa SDL_PollEvent1290* \sa SDL_PushEvent1291* \sa SDL_WaitEventTimeout1292*/1293extern SDL_DECLSPEC bool SDLCALL SDL_WaitEvent(SDL_Event *event);12941295/**1296* Wait until the specified timeout (in milliseconds) for the next available1297* event.1298*1299* If `event` is not NULL, the next event is removed from the queue and stored1300* in the SDL_Event structure pointed to by `event`.1301*1302* As this function may implicitly call SDL_PumpEvents(), you can only call1303* this function in the thread that initialized the video subsystem.1304*1305* The timeout is not guaranteed, the actual wait time could be longer due to1306* system scheduling.1307*1308* \param event the SDL_Event structure to be filled in with the next event1309* from the queue, or NULL.1310* \param timeoutMS the maximum number of milliseconds to wait for the next1311* available event.1312* \returns true if this got an event or false if the timeout elapsed without1313* any events available.1314*1315* \threadsafety This function should only be called on the main thread.1316*1317* \since This function is available since SDL 3.2.0.1318*1319* \sa SDL_PollEvent1320* \sa SDL_PushEvent1321* \sa SDL_WaitEvent1322*/1323extern SDL_DECLSPEC bool SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS);13241325/**1326* Add an event to the event queue.1327*1328* The event queue can actually be used as a two way communication channel.1329* Not only can events be read from the queue, but the user can also push1330* their own events onto it. `event` is a pointer to the event structure you1331* wish to push onto the queue. The event is copied into the queue, and the1332* caller may dispose of the memory pointed to after SDL_PushEvent() returns.1333*1334* Note: Pushing device input events onto the queue doesn't modify the state1335* of the device within SDL.1336*1337* Note: Events pushed onto the queue with SDL_PushEvent() get passed through1338* the event filter but events added with SDL_PeepEvents() do not.1339*1340* For pushing application-specific events, please use SDL_RegisterEvents() to1341* get an event type that does not conflict with other code that also wants1342* its own custom event types.1343*1344* \param event the SDL_Event to be added to the queue.1345* \returns true on success, false if the event was filtered or on failure;1346* call SDL_GetError() for more information. A common reason for1347* error is the event queue being full.1348*1349* \threadsafety It is safe to call this function from any thread.1350*1351* \since This function is available since SDL 3.2.0.1352*1353* \sa SDL_PeepEvents1354* \sa SDL_PollEvent1355* \sa SDL_RegisterEvents1356*/1357extern SDL_DECLSPEC bool SDLCALL SDL_PushEvent(SDL_Event *event);13581359/**1360* A function pointer used for callbacks that watch the event queue.1361*1362* \param userdata what was passed as `userdata` to SDL_SetEventFilter() or1363* SDL_AddEventWatch, etc.1364* \param event the event that triggered the callback.1365* \returns true to permit event to be added to the queue, and false to1366* disallow it. When used with SDL_AddEventWatch, the return value is1367* ignored.1368*1369* \threadsafety SDL may call this callback at any time from any thread; the1370* application is responsible for locking resources the callback1371* touches that need to be protected.1372*1373* \since This datatype is available since SDL 3.2.0.1374*1375* \sa SDL_SetEventFilter1376* \sa SDL_AddEventWatch1377*/1378typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event);13791380/**1381* Set up a filter to process all events before they are added to the internal1382* event queue.1383*1384* If you just want to see events without modifying them or preventing them1385* from being queued, you should use SDL_AddEventWatch() instead.1386*1387* If the filter function returns true when called, then the event will be1388* added to the internal queue. If it returns false, then the event will be1389* dropped from the queue, but the internal state will still be updated. This1390* allows selective filtering of dynamically arriving events.1391*1392* **WARNING**: Be very careful of what you do in the event filter function,1393* as it may run in a different thread!1394*1395* On platforms that support it, if the quit event is generated by an1396* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the1397* application at the next event poll.1398*1399* Note: Disabled events never make it to the event filter function; see1400* SDL_SetEventEnabled().1401*1402* Note: Events pushed onto the queue with SDL_PushEvent() get passed through1403* the event filter, but events pushed onto the queue with SDL_PeepEvents() do1404* not.1405*1406* \param filter an SDL_EventFilter function to call when an event happens.1407* \param userdata a pointer that is passed to `filter`.1408*1409* \threadsafety It is safe to call this function from any thread.1410*1411* \since This function is available since SDL 3.2.0.1412*1413* \sa SDL_AddEventWatch1414* \sa SDL_SetEventEnabled1415* \sa SDL_GetEventFilter1416* \sa SDL_PeepEvents1417* \sa SDL_PushEvent1418*/1419extern SDL_DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, void *userdata);14201421/**1422* Query the current event filter.1423*1424* This function can be used to "chain" filters, by saving the existing filter1425* before replacing it with a function that will call that saved filter.1426*1427* \param filter the current callback function will be stored here.1428* \param userdata the pointer that is passed to the current event filter will1429* be stored here.1430* \returns true on success or false if there is no event filter set.1431*1432* \threadsafety It is safe to call this function from any thread.1433*1434* \since This function is available since SDL 3.2.0.1435*1436* \sa SDL_SetEventFilter1437*/1438extern SDL_DECLSPEC bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata);14391440/**1441* Add a callback to be triggered when an event is added to the event queue.1442*1443* `filter` will be called when an event happens, and its return value is1444* ignored.1445*1446* **WARNING**: Be very careful of what you do in the event filter function,1447* as it may run in a different thread!1448*1449* If the quit event is generated by a signal (e.g. SIGINT), it will bypass1450* the internal queue and be delivered to the watch callback immediately, and1451* arrive at the next event poll.1452*1453* Note: the callback is called for events posted by the user through1454* SDL_PushEvent(), but not for disabled events, nor for events by a filter1455* callback set with SDL_SetEventFilter(), nor for events posted by the user1456* through SDL_PeepEvents().1457*1458* \param filter an SDL_EventFilter function to call when an event happens.1459* \param userdata a pointer that is passed to `filter`.1460* \returns true on success or false on failure; call SDL_GetError() for more1461* information.1462*1463* \threadsafety It is safe to call this function from any thread.1464*1465* \since This function is available since SDL 3.2.0.1466*1467* \sa SDL_RemoveEventWatch1468* \sa SDL_SetEventFilter1469*/1470extern SDL_DECLSPEC bool SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata);14711472/**1473* Remove an event watch callback added with SDL_AddEventWatch().1474*1475* This function takes the same input as SDL_AddEventWatch() to identify and1476* delete the corresponding callback.1477*1478* \param filter the function originally passed to SDL_AddEventWatch().1479* \param userdata the pointer originally passed to SDL_AddEventWatch().1480*1481* \threadsafety It is safe to call this function from any thread.1482*1483* \since This function is available since SDL 3.2.0.1484*1485* \sa SDL_AddEventWatch1486*/1487extern SDL_DECLSPEC void SDLCALL SDL_RemoveEventWatch(SDL_EventFilter filter, void *userdata);14881489/**1490* Run a specific filter function on the current event queue, removing any1491* events for which the filter returns false.1492*1493* See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),1494* this function does not change the filter permanently, it only uses the1495* supplied filter until this function returns.1496*1497* \param filter the SDL_EventFilter function to call when an event happens.1498* \param userdata a pointer that is passed to `filter`.1499*1500* \threadsafety It is safe to call this function from any thread.1501*1502* \since This function is available since SDL 3.2.0.1503*1504* \sa SDL_GetEventFilter1505* \sa SDL_SetEventFilter1506*/1507extern SDL_DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata);15081509/**1510* Set the state of processing events by type.1511*1512* \param type the type of event; see SDL_EventType for details.1513* \param enabled whether to process the event or not.1514*1515* \threadsafety It is safe to call this function from any thread.1516*1517* \since This function is available since SDL 3.2.0.1518*1519* \sa SDL_EventEnabled1520*/1521extern SDL_DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, bool enabled);15221523/**1524* Query the state of processing events by type.1525*1526* \param type the type of event; see SDL_EventType for details.1527* \returns true if the event is being processed, false otherwise.1528*1529* \threadsafety It is safe to call this function from any thread.1530*1531* \since This function is available since SDL 3.2.0.1532*1533* \sa SDL_SetEventEnabled1534*/1535extern SDL_DECLSPEC bool SDLCALL SDL_EventEnabled(Uint32 type);15361537/**1538* Allocate a set of user-defined events, and return the beginning event1539* number for that set of events.1540*1541* \param numevents the number of events to be allocated.1542* \returns the beginning event number, or 0 if numevents is invalid or if1543* there are not enough user-defined events left.1544*1545* \threadsafety It is safe to call this function from any thread.1546*1547* \since This function is available since SDL 3.2.0.1548*1549* \sa SDL_PushEvent1550*/1551extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);15521553/**1554* Get window associated with an event.1555*1556* \param event an event containing a `windowID`.1557* \returns the associated window on success or NULL if there is none.1558*1559* \threadsafety It is safe to call this function from any thread.1560*1561* \since This function is available since SDL 3.2.0.1562*1563* \sa SDL_PollEvent1564* \sa SDL_WaitEvent1565* \sa SDL_WaitEventTimeout1566*/1567extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event);15681569/* Ends C function definitions when using C++ */1570#ifdef __cplusplus1571}1572#endif1573#include <SDL3/SDL_close_code.h>15741575#endif /* SDL_events_h_ */157615771578