Skip to content

Commit 5674a6a

Browse files
committed
Add FIRST and LAST event aliases to SDL_event
This makes it easier for SDL users to offload handling of event types to different handlers, and have those handlers match on the specific event type; the event poller only has to check the ranges to know who to hand the event to.
1 parent ef4b748 commit 5674a6a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

include/SDL3/SDL_events.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ typedef enum SDL_EventType
175175
SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */
176176
SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */
177177
SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */
178+
SDL_EVENT_KEYBOARD_FIRST = SDL_EVENT_KEY_DOWN,
179+
SDL_EVENT_KEYBOARD_LAST = SDL_EVENT_TEXT_EDITING_CANDIDATES,
178180

179181
/* Mouse events */
180182
SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
@@ -183,6 +185,8 @@ typedef enum SDL_EventType
183185
SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */
184186
SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */
185187
SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */
188+
SDL_EVENT_MOUSE_FIRST = SDL_EVENT_MOUSE_MOTION,
189+
SDL_EVENT_MOUSE_LAST = SDL_EVENT_MOUSE_REMOVED,
186190

187191
/* Joystick events */
188192
SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */
@@ -194,6 +198,8 @@ typedef enum SDL_EventType
194198
SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
195199
SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */
196200
SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */
201+
SDL_EVENT_JOYSTICK_FIRST = SDL_EVENT_JOYSTICK_AXIS_MOTION,
202+
SDL_EVENT_JOYSTICK_LAST = SDL_EVENT_JOYSTICK_UPDATE_COMPLETE,
197203

198204
/* Gamepad events */
199205
SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */
@@ -208,12 +214,16 @@ typedef enum SDL_EventType
208214
SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */
209215
SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete */
210216
SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED, /**< Gamepad Steam handle has changed */
217+
SDL_EVENT_GAMEPAD_FIRST = SDL_EVENT_GAMEPAD_AXIS_MOTION,
218+
SDL_EVENT_GAMEPAD_LAST = SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED,
211219

212220
/* Touch events */
213221
SDL_EVENT_FINGER_DOWN = 0x700,
214222
SDL_EVENT_FINGER_UP,
215223
SDL_EVENT_FINGER_MOTION,
216224
SDL_EVENT_FINGER_CANCELED,
225+
SDL_EVENT_FINGER_FIRST = SDL_EVENT_FINGER_DOWN,
226+
SDL_EVENT_FINGER_LAST = SDL_EVENT_FINGER_CANCELLED,
217227

218228
/* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */
219229

@@ -226,11 +236,15 @@ typedef enum SDL_EventType
226236
SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */
227237
SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */
228238
SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */
239+
SDL_EVENT_DROP_FIRST = SDL_EVENT_DROP_FILE,
240+
SDL_EVENT_DROP_LAST = SDL_EVENT_DROP_POSITION,
229241

230242
/* Audio hotplug events */
231243
SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */
232244
SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */
233245
SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED, /**< An audio device's format has been changed by the system. */
246+
SDL_EVENT_AUDIO_FIRST = SDL_EVENT_AUDIO_DEVICE_ADDED,
247+
SDL_EVENT_AUDIO_LAST = SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED,
234248

235249
/* Sensor events */
236250
SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */
@@ -244,17 +258,24 @@ typedef enum SDL_EventType
244258
SDL_EVENT_PEN_BUTTON_UP, /**< Pressure-sensitive pen button released */
245259
SDL_EVENT_PEN_MOTION, /**< Pressure-sensitive pen is moving on the tablet */
246260
SDL_EVENT_PEN_AXIS, /**< Pressure-sensitive pen angle/pressure/etc changed */
261+
SDL_EVENT_PEN_FIRST = SDL_EVENT_PEN_PROXIMITY_IN,
262+
SDL_EVENT_PEN_LAST = SDL_EVENT_PEN_AXIS,
247263

248264
/* Camera hotplug events */
249265
SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400, /**< A new camera device is available */
250266
SDL_EVENT_CAMERA_DEVICE_REMOVED, /**< A camera device has been removed. */
251267
SDL_EVENT_CAMERA_DEVICE_APPROVED, /**< A camera device has been approved for use by the user. */
252268
SDL_EVENT_CAMERA_DEVICE_DENIED, /**< A camera device has been denied for use by the user. */
269+
SDL_EVENT_CAMERA_FIRST = SDL_EVENT_CAMERA_DEVICE_ADDED,
270+
SDL_EVENT_CAMERA_LAST = SDL_EVENT_CAMERA_DEVICE_DENIED,
253271

254272
/* Render events */
255273
SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
256274
SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
257275
SDL_EVENT_RENDER_DEVICE_LOST, /**< The device has been lost and can't be recovered. */
276+
SDL_EVENT_RENDER_FIRST = SDL_EVENT_RENDER_TARGETS_RESET,
277+
SDL_EVENT_RENDER_LAST = SDL_EVENT_RENDER_DEVICE_LOST,
278+
258279

259280
/* Reserved events for private platforms */
260281
SDL_EVENT_PRIVATE0 = 0x4000,

0 commit comments

Comments
 (0)