Skip to content

Commit 4c5cd76

Browse files
authored
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 4c5cd76

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/SDL3/SDL_events.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ typedef enum SDL_EventType
183183
SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */
184184
SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */
185185
SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */
186+
SDL_EVENT_MOUSE_FIRST = SDL_EVENT_MOUSE_MOTION,
187+
SDL_EVENT_MOUSE_LAST = SDL_EVENT_MOUSE_REMOVED,
186188

187189
/* Joystick events */
188190
SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */
@@ -194,6 +196,8 @@ typedef enum SDL_EventType
194196
SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
195197
SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */
196198
SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */
199+
SDL_EVENT_JOYSTICK_FIRST = SDL_EVENT_JOYSTICK_AXIS_MOTION,
200+
SDL_EVENT_JOYSTICK_LAST = SDL_EVENT_JOYSTICK_UPDATE_COMPLETE,
197201

198202
/* Gamepad events */
199203
SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */
@@ -208,12 +212,16 @@ typedef enum SDL_EventType
208212
SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */
209213
SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete */
210214
SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED, /**< Gamepad Steam handle has changed */
215+
SDL_EVENT_GAMEPAD_FIRST = SDL_EVENT_GAMEPAD_AXIS_MOTION,
216+
SDL_EVENT_GAMEPAD_LAST = SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED,
211217

212218
/* Touch events */
213219
SDL_EVENT_FINGER_DOWN = 0x700,
214220
SDL_EVENT_FINGER_UP,
215221
SDL_EVENT_FINGER_MOTION,
216222
SDL_EVENT_FINGER_CANCELED,
223+
SDL_EVENT_FINGER_FIRST = SDL_EVENT_FINGER_DOWN,
224+
SDL_EVENT_FINGER_LAST = SDL_EVENT_FINGER_CANCELLED,
217225

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

@@ -226,11 +234,15 @@ typedef enum SDL_EventType
226234
SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */
227235
SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */
228236
SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */
237+
SDL_EVENT_DROP_FIRST = SDL_EVENT_DROP_FILE,
238+
SDL_EVENT_DROP_LAST = SDL_EVENT_DROP_POSITION,
229239

230240
/* Audio hotplug events */
231241
SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */
232242
SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */
233243
SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED, /**< An audio device's format has been changed by the system. */
244+
SDL_EVENT_AUDIO_DEVICE_FIRST = SDL_EVENT_AUDIO_DEVICE_ADDED,
245+
SDL_EVENT_AUDIO_DEVICE_LAST = SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED,
234246

235247
/* Sensor events */
236248
SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */
@@ -244,17 +256,24 @@ typedef enum SDL_EventType
244256
SDL_EVENT_PEN_BUTTON_UP, /**< Pressure-sensitive pen button released */
245257
SDL_EVENT_PEN_MOTION, /**< Pressure-sensitive pen is moving on the tablet */
246258
SDL_EVENT_PEN_AXIS, /**< Pressure-sensitive pen angle/pressure/etc changed */
259+
SDL_EVENT_PEN_FIRST = SDL_EVENT_PEN_PROXIMITY_IN,
260+
SDL_EVENT_PEN_LAST = SDL_EVENT_PEN_AXIS,
247261

248262
/* Camera hotplug events */
249263
SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400, /**< A new camera device is available */
250264
SDL_EVENT_CAMERA_DEVICE_REMOVED, /**< A camera device has been removed. */
251265
SDL_EVENT_CAMERA_DEVICE_APPROVED, /**< A camera device has been approved for use by the user. */
252266
SDL_EVENT_CAMERA_DEVICE_DENIED, /**< A camera device has been denied for use by the user. */
267+
SDL_EVENT_CAMERA_FIRST = SDL_EVENT_CAMERA_DEVICE_ADDED,
268+
SDL_EVENT_CAMERA_DEVICE_LAST = SDL_EVENT_CAMERA_DEVICE_DENIED,
253269

254270
/* Render events */
255271
SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
256272
SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
257273
SDL_EVENT_RENDER_DEVICE_LOST, /**< The device has been lost and can't be recovered. */
274+
SDL_EVENT_RENDER_DEVICE_FIRST = SDL_EVENT_RENDER_TARGETS_RESET,
275+
SDL_EVENT_RENDER_DEVICE_LAST = SDL_EVENT_RENDER_DEVICE_LOST,
276+
258277

259278
/* Reserved events for private platforms */
260279
SDL_EVENT_PRIVATE0 = 0x4000,

0 commit comments

Comments
 (0)