comparison include/SDL_events.h @ 4429:faa9fc8e7f67

General improvements for user custom event registration * Switched event type to enum (int32) * Switched polling by mask to polling by type range * Added SDL_RegisterEvents() to allow dynamic user event registration * Spread events out to allow inserting new related events without breaking binary compatibility * Added padding to event structures so they're the same size regardless of 32-bit compiler structure packing settings * Split SDL_HasEvent() to SDL_HasEvent() for a single event and SDL_HasEvents() for a range of events * Added SDL_GetEventState() as a shortcut for SDL_EventState(X, SDL_QUERY) * Added SDL_FlushEvent() and SDL_FlushEvents() to clear events from the event queue
author Sam Lantinga <slouken@libsdl.org>
date Thu, 25 Mar 2010 01:08:26 -0700
parents f7b03b6838cb
children 5c64052fb476
comparison
equal deleted inserted replaced
4428:68dfd6df47da 4429:faa9fc8e7f67
52 /** 52 /**
53 * \brief The types of events that can be delivered. 53 * \brief The types of events that can be delivered.
54 */ 54 */
55 typedef enum 55 typedef enum
56 { 56 {
57 SDL_NOEVENT = 0, /**< Unused (do not remove) */ 57 SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
58 SDL_WINDOWEVENT, /**< Window state change */ 58
59 SDL_KEYDOWN, /**< Keys pressed */ 59 /* Application events */
60 SDL_QUIT = 0x100, /**< User-requested quit */
61
62 /* Window events */
63 SDL_WINDOWEVENT = 0x200, /**< Window state change */
64 SDL_SYSWMEVENT, /**< System specific event */
65
66 /* Keyboard events */
67 SDL_KEYDOWN = 0x300, /**< Keys pressed */
60 SDL_KEYUP, /**< Keys released */ 68 SDL_KEYUP, /**< Keys released */
61 SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ 69 SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
62 SDL_TEXTINPUT, /**< Keyboard text input */ 70 SDL_TEXTINPUT, /**< Keyboard text input */
63 SDL_MOUSEMOTION, /**< Mouse moved */ 71
72 /* Mouse events */
73 SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
64 SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ 74 SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
65 SDL_MOUSEBUTTONUP, /**< Mouse button released */ 75 SDL_MOUSEBUTTONUP, /**< Mouse button released */
66 SDL_MOUSEWHEEL, /**< Mouse wheel motion */ 76 SDL_MOUSEWHEEL, /**< Mouse wheel motion */
67 SDL_JOYAXISMOTION, /**< Joystick axis motion */ 77
78 /* Tablet events */
79 SDL_PROXIMITYIN = 0x500, /**< Proximity In event */
80 SDL_PROXIMITYOUT, /**< Proximity Out event */
81
82 /* Joystick events */
83 SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
68 SDL_JOYBALLMOTION, /**< Joystick trackball motion */ 84 SDL_JOYBALLMOTION, /**< Joystick trackball motion */
69 SDL_JOYHATMOTION, /**< Joystick hat position change */ 85 SDL_JOYHATMOTION, /**< Joystick hat position change */
70 SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ 86 SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
71 SDL_JOYBUTTONUP, /**< Joystick button released */ 87 SDL_JOYBUTTONUP, /**< Joystick button released */
72 SDL_QUIT, /**< User-requested quit */ 88
73 SDL_SYSWMEVENT, /**< System specific event */ 89 /* Obsolete events */
74 SDL_PROXIMITYIN, /**< Proximity In event */ 90 SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
75 SDL_PROXIMITYOUT, /**< Proximity Out event */ 91 SDL_EVENT_COMPAT2,
76 SDL_EVENT_RESERVED1, /**< Reserved for future use... */ 92 SDL_EVENT_COMPAT3,
77 SDL_EVENT_RESERVED2, /**< Reserved for future use... */ 93
78 SDL_EVENT_RESERVED3, /**< Reserved for future use... */ 94 /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
79 /** Events ::SDL_USEREVENT through ::SDL_MAXEVENTS-1 are for your use */ 95 * and should be allocated with SDL_RegisterEvents()
80 SDL_USEREVENT = 24, 96 */
97 SDL_USEREVENT = 0x8000,
98
81 /** 99 /**
82 * This last event is only for bounding internal arrays 100 * This last event is only for bounding internal arrays
83 * It is the number of bits in the event mask datatype -- Uint32
84 */ 101 */
85 SDL_NUMEVENTS = 32 102 SDL_LASTEVENT = 0xFFFF
86 } SDL_EventType; 103 } SDL_EventType;
87 104
88 /*@{*/
89 #define SDL_EVENTMASK(X) (1<<(X))
90 /**
91 * \brief Predefined event masks
92 */
93 typedef enum
94 {
95 SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT),
96 SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
97 SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
98 SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
99 SDL_TEXTEDITINGMASK = SDL_EVENTMASK(SDL_TEXTEDITING),
100 SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
101 SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
102 SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
103 SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
104 SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
105 SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
106 SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
107 SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
108 SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION),
109 SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION),
110 SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
111 SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP),
112 SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) |
113 SDL_EVENTMASK(SDL_JOYBALLMOTION) |
114 SDL_EVENTMASK(SDL_JOYHATMOTION) |
115 SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP),
116 SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
117 SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT),
118 SDL_PROXIMITYINMASK = SDL_EVENTMASK(SDL_PROXIMITYIN),
119 SDL_PROXIMITYOUTMASK = SDL_EVENTMASK(SDL_PROXIMITYOUT)
120 } SDL_EventMask;
121 #define SDL_ALLEVENTS 0xFFFFFFFF
122 /*@}*/
123
124 /** 105 /**
125 * \brief Window state change event data (event.window.*) 106 * \brief Window state change event data (event.window.*)
126 */ 107 */
127 typedef struct SDL_WindowEvent 108 typedef struct SDL_WindowEvent
128 { 109 {
129 Uint8 type; /**< ::SDL_WINDOWEVENT */ 110 Uint32 type; /**< ::SDL_WINDOWEVENT */
130 Uint32 windowID; /**< The associated window */ 111 Uint32 windowID; /**< The associated window */
131 Uint8 event; /**< ::SDL_WindowEventID */ 112 Uint8 event; /**< ::SDL_WindowEventID */
132 int data1; /**< event dependent data */ 113 Uint8 padding1;
133 int data2; /**< event dependent data */ 114 Uint8 padding2;
115 Uint8 padding3;
116 int data1; /**< event dependent data */
117 int data2; /**< event dependent data */
134 } SDL_WindowEvent; 118 } SDL_WindowEvent;
135 119
136 /** 120 /**
137 * \brief Keyboard button event structure (event.key.*) 121 * \brief Keyboard button event structure (event.key.*)
138 */ 122 */
139 typedef struct SDL_KeyboardEvent 123 typedef struct SDL_KeyboardEvent
140 { 124 {
141 Uint8 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ 125 Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
142 Uint32 windowID; /**< The window with keyboard focus, if any */ 126 Uint32 windowID; /**< The window with keyboard focus, if any */
143 Uint8 which; /**< The keyboard device index */ 127 Uint8 which; /**< The keyboard device index */
144 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ 128 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
145 SDL_keysym keysym; /**< The key that was pressed or released */ 129 Uint8 padding1;
130 Uint8 padding2;
131 SDL_keysym keysym; /**< The key that was pressed or released */
146 } SDL_KeyboardEvent; 132 } SDL_KeyboardEvent;
147 133
148 #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) 134 #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
149 /** 135 /**
150 * \brief Keyboard text editing event structure (event.edit.*) 136 * \brief Keyboard text editing event structure (event.edit.*)
151 */ 137 */
152 typedef struct SDL_TextEditingEvent 138 typedef struct SDL_TextEditingEvent
153 { 139 {
154 Uint8 type; /**< ::SDL_TEXTEDITING */ 140 Uint32 type; /**< ::SDL_TEXTEDITING */
155 char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ 141 char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
156 int start; /**< The start cursor of selected editing text */ 142 int start; /**< The start cursor of selected editing text */
157 int length; /**< The length of selected editing text */ 143 int length; /**< The length of selected editing text */
158 } SDL_TextEditingEvent; 144 } SDL_TextEditingEvent;
159 145
162 /** 148 /**
163 * \brief Keyboard text input event structure (event.text.*) 149 * \brief Keyboard text input event structure (event.text.*)
164 */ 150 */
165 typedef struct SDL_TextInputEvent 151 typedef struct SDL_TextInputEvent
166 { 152 {
167 Uint8 type; /**< ::SDL_TEXTINPUT */ 153 Uint32 type; /**< ::SDL_TEXTINPUT */
168 Uint32 windowID; /**< The window with keyboard focus, if any */ 154 Uint32 windowID; /**< The window with keyboard focus, if any */
169 Uint8 which; /**< The keyboard device index */ 155 Uint8 which; /**< The keyboard device index */
156 Uint8 padding1;
157 Uint8 padding2;
158 Uint8 padding3;
170 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ 159 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
171 } SDL_TextInputEvent; 160 } SDL_TextInputEvent;
172 161
173 /** 162 /**
174 * \brief Mouse motion event structure (event.motion.*) 163 * \brief Mouse motion event structure (event.motion.*)
175 */ 164 */
176 typedef struct SDL_MouseMotionEvent 165 typedef struct SDL_MouseMotionEvent
177 { 166 {
178 Uint8 type; /**< ::SDL_MOUSEMOTION */ 167 Uint32 type; /**< ::SDL_MOUSEMOTION */
179 Uint32 windowID; /**< The window with mouse focus, if any */ 168 Uint32 windowID; /**< The window with mouse focus, if any */
180 Uint8 which; /**< The mouse device index */ 169 Uint8 which; /**< The mouse device index */
181 Uint8 state; /**< The current button state */ 170 Uint8 state; /**< The current button state */
182 int x; /**< X coordinate, relative to window */ 171 Uint8 padding1;
183 int y; /**< Y coordinate, relative to window */ 172 Uint8 padding2;
184 int z; /**< Z coordinate, for future use */ 173 int x; /**< X coordinate, relative to window */
185 int pressure; /**< Pressure reported by tablets */ 174 int y; /**< Y coordinate, relative to window */
186 int pressure_max; /**< Maximum value of the pressure reported by the device */ 175 int z; /**< Z coordinate, for future use */
187 int pressure_min; /**< Minimum value of the pressure reported by the device */ 176 int pressure; /**< Pressure reported by tablets */
188 int rotation; /**< For future use */ 177 int pressure_max; /**< Maximum value of the pressure reported by the device */
189 int tilt_x; /**< For future use */ 178 int pressure_min; /**< Minimum value of the pressure reported by the device */
190 int tilt_y; /**< For future use */ 179 int rotation; /**< For future use */
191 int cursor; /**< The cursor being used in the event */ 180 int tilt_x; /**< For future use */
192 int xrel; /**< The relative motion in the X direction */ 181 int tilt_y; /**< For future use */
193 int yrel; /**< The relative motion in the Y direction */ 182 int cursor; /**< The cursor being used in the event */
183 int xrel; /**< The relative motion in the X direction */
184 int yrel; /**< The relative motion in the Y direction */
194 } SDL_MouseMotionEvent; 185 } SDL_MouseMotionEvent;
195 186
196 /** 187 /**
197 * \brief Mouse button event structure (event.button.*) 188 * \brief Mouse button event structure (event.button.*)
198 */ 189 */
199 typedef struct SDL_MouseButtonEvent 190 typedef struct SDL_MouseButtonEvent
200 { 191 {
201 Uint8 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ 192 Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
202 Uint32 windowID; /**< The window with mouse focus, if any */ 193 Uint32 windowID; /**< The window with mouse focus, if any */
203 Uint8 which; /**< The mouse device index */ 194 Uint8 which; /**< The mouse device index */
204 Uint8 button; /**< The mouse button index */ 195 Uint8 button; /**< The mouse button index */
205 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ 196 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
206 int x; /**< X coordinate, relative to window */ 197 Uint8 padding1;
207 int y; /**< Y coordinate, relative to window */ 198 int x; /**< X coordinate, relative to window */
199 int y; /**< Y coordinate, relative to window */
208 } SDL_MouseButtonEvent; 200 } SDL_MouseButtonEvent;
209 201
210 /** 202 /**
211 * \brief Mouse wheel event structure (event.wheel.*) 203 * \brief Mouse wheel event structure (event.wheel.*)
212 */ 204 */
213 typedef struct SDL_MouseWheelEvent 205 typedef struct SDL_MouseWheelEvent
214 { 206 {
215 Uint8 type; /**< ::SDL_MOUSEWHEEL */ 207 Uint32 type; /**< ::SDL_MOUSEWHEEL */
216 Uint32 windowID; /**< The window with mouse focus, if any */ 208 Uint32 windowID; /**< The window with mouse focus, if any */
217 Uint8 which; /**< The mouse device index */ 209 Uint8 which; /**< The mouse device index */
218 int x; /**< The amount scrolled horizontally */ 210 Uint8 padding1;
219 int y; /**< The amount scrolled vertically */ 211 Uint8 padding2;
212 Uint8 padding3;
213 int x; /**< The amount scrolled horizontally */
214 int y; /**< The amount scrolled vertically */
220 } SDL_MouseWheelEvent; 215 } SDL_MouseWheelEvent;
221 216
222 /** 217 /**
218 * \brief Tablet pen proximity event
219 */
220 typedef struct SDL_ProximityEvent
221 {
222 Uint32 type; /**< ::SDL_PROXIMITYIN or ::SDL_PROXIMITYOUT */
223 Uint32 windowID; /**< The associated window */
224 Uint8 which;
225 Uint8 padding1;
226 Uint8 padding2;
227 Uint8 padding3;
228 int cursor;
229 int x;
230 int y;
231 } SDL_ProximityEvent;
232
233 /**
223 * \brief Joystick axis motion event structure (event.jaxis.*) 234 * \brief Joystick axis motion event structure (event.jaxis.*)
224 */ 235 */
225 typedef struct SDL_JoyAxisEvent 236 typedef struct SDL_JoyAxisEvent
226 { 237 {
227 Uint8 type; /**< ::SDL_JOYAXISMOTION */ 238 Uint32 type; /**< ::SDL_JOYAXISMOTION */
228 Uint8 which; /**< The joystick device index */ 239 Uint8 which; /**< The joystick device index */
229 Uint8 axis; /**< The joystick axis index */ 240 Uint8 axis; /**< The joystick axis index */
241 Uint8 padding1;
242 Uint8 padding2;
230 int value; /**< The axis value (range: -32768 to 32767) */ 243 int value; /**< The axis value (range: -32768 to 32767) */
231 } SDL_JoyAxisEvent; 244 } SDL_JoyAxisEvent;
232 245
233 /** 246 /**
234 * \brief Joystick trackball motion event structure (event.jball.*) 247 * \brief Joystick trackball motion event structure (event.jball.*)
235 */ 248 */
236 typedef struct SDL_JoyBallEvent 249 typedef struct SDL_JoyBallEvent
237 { 250 {
238 Uint8 type; /**< ::SDL_JOYBALLMOTION */ 251 Uint32 type; /**< ::SDL_JOYBALLMOTION */
239 Uint8 which; /**< The joystick device index */ 252 Uint8 which; /**< The joystick device index */
240 Uint8 ball; /**< The joystick trackball index */ 253 Uint8 ball; /**< The joystick trackball index */
254 Uint8 padding1;
255 Uint8 padding2;
241 int xrel; /**< The relative motion in the X direction */ 256 int xrel; /**< The relative motion in the X direction */
242 int yrel; /**< The relative motion in the Y direction */ 257 int yrel; /**< The relative motion in the Y direction */
243 } SDL_JoyBallEvent; 258 } SDL_JoyBallEvent;
244 259
245 /** 260 /**
246 * \brief Joystick hat position change event structure (event.jhat.*) 261 * \brief Joystick hat position change event structure (event.jhat.*)
247 */ 262 */
248 typedef struct SDL_JoyHatEvent 263 typedef struct SDL_JoyHatEvent
249 { 264 {
250 Uint8 type; /**< ::SDL_JOYHATMOTION */ 265 Uint32 type; /**< ::SDL_JOYHATMOTION */
251 Uint8 which; /**< The joystick device index */ 266 Uint8 which; /**< The joystick device index */
252 Uint8 hat; /**< The joystick hat index */ 267 Uint8 hat; /**< The joystick hat index */
253 Uint8 value; /**< The hat position value. 268 Uint8 value; /**< The hat position value.
254 * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP 269 * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
255 * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT 270 * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
256 * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN 271 * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
257 * 272 *
258 * Note that zero means the POV is centered. 273 * Note that zero means the POV is centered.
259 */ 274 */
275 Uint8 padding1;
260 } SDL_JoyHatEvent; 276 } SDL_JoyHatEvent;
261 277
262 /** 278 /**
263 * \brief Joystick button event structure (event.jbutton.*) 279 * \brief Joystick button event structure (event.jbutton.*)
264 */ 280 */
265 typedef struct SDL_JoyButtonEvent 281 typedef struct SDL_JoyButtonEvent
266 { 282 {
267 Uint8 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ 283 Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
268 Uint8 which; /**< The joystick device index */ 284 Uint8 which; /**< The joystick device index */
269 Uint8 button; /**< The joystick button index */ 285 Uint8 button; /**< The joystick button index */
270 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ 286 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
287 Uint8 padding1;
271 } SDL_JoyButtonEvent; 288 } SDL_JoyButtonEvent;
272 289
273 /** 290 /**
274 * \brief The "quit requested" event 291 * \brief The "quit requested" event
275 */ 292 */
276 typedef struct SDL_QuitEvent 293 typedef struct SDL_QuitEvent
277 { 294 {
278 Uint8 type; /**< ::SDL_QUIT */ 295 Uint32 type; /**< ::SDL_QUIT */
279 } SDL_QuitEvent; 296 } SDL_QuitEvent;
280 297
281 /** 298 /**
282 * \brief A user-defined event type (event.user.*) 299 * \brief A user-defined event type (event.user.*)
283 */ 300 */
284 typedef struct SDL_UserEvent 301 typedef struct SDL_UserEvent
285 { 302 {
286 Uint8 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */ 303 Uint32 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
287 Uint32 windowID; /**< The associated window if any*/ 304 Uint32 windowID; /**< The associated window if any */
288 int code; /**< User defined event code */ 305 int code; /**< User defined event code */
289 void *data1; /**< User defined data pointer */ 306 void *data1; /**< User defined data pointer */
290 void *data2; /**< User defined data pointer */ 307 void *data2; /**< User defined data pointer */
291 } SDL_UserEvent; 308 } SDL_UserEvent;
292 309
293 struct SDL_SysWMmsg; 310 struct SDL_SysWMmsg;
294 typedef struct SDL_SysWMmsg SDL_SysWMmsg; 311 typedef struct SDL_SysWMmsg SDL_SysWMmsg;
295 312
298 * 315 *
299 * \note If you want to use this event, you should include SDL_syswm.h. 316 * \note If you want to use this event, you should include SDL_syswm.h.
300 */ 317 */
301 typedef struct SDL_SysWMEvent 318 typedef struct SDL_SysWMEvent
302 { 319 {
303 Uint8 type; /**< ::SDL_SYSWMEVENT */ 320 Uint32 type; /**< ::SDL_SYSWMEVENT */
304 SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ 321 SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
305 } SDL_SysWMEvent; 322 } SDL_SysWMEvent;
306 323
307 typedef struct SDL_ProximityEvent
308 {
309 Uint8 type;
310 Uint32 windowID; /**< The associated window */
311 Uint8 which;
312 int cursor;
313 int x;
314 int y;
315 } SDL_ProximityEvent;
316
317 #ifndef SDL_NO_COMPAT 324 #ifndef SDL_NO_COMPAT
318 /** 325 /**
319 * \addtogroup Compatibility 326 * \addtogroup Compatibility
320 */ 327 */
321 /*@{*/ 328 /*@{*/
324 * \name Typedefs for backwards compatibility 331 * \name Typedefs for backwards compatibility
325 */ 332 */
326 /*@{*/ 333 /*@{*/
327 typedef struct SDL_ActiveEvent 334 typedef struct SDL_ActiveEvent
328 { 335 {
329 Uint8 type; 336 Uint32 type;
330 Uint8 gain; 337 Uint8 gain;
331 Uint8 state; 338 Uint8 state;
332 } SDL_ActiveEvent; 339 } SDL_ActiveEvent;
333 340
334 typedef struct SDL_ResizeEvent 341 typedef struct SDL_ResizeEvent
335 { 342 {
336 Uint8 type; 343 Uint32 type;
337 int w; 344 int w;
338 int h; 345 int h;
339 } SDL_ResizeEvent; 346 } SDL_ResizeEvent;
340 /*@}*/ 347 /*@}*/
341 348
345 /** 352 /**
346 * \brief General event structure 353 * \brief General event structure
347 */ 354 */
348 typedef union SDL_Event 355 typedef union SDL_Event
349 { 356 {
350 Uint8 type; /**< Event type, shared with all events */ 357 Uint32 type; /**< Event type, shared with all events */
351 SDL_WindowEvent window; /**< Window event data */ 358 SDL_WindowEvent window; /**< Window event data */
352 SDL_KeyboardEvent key; /**< Keyboard event data */ 359 SDL_KeyboardEvent key; /**< Keyboard event data */
353 SDL_TextEditingEvent edit; /**< Text editing event data */ 360 SDL_TextEditingEvent edit; /**< Text editing event data */
354 SDL_TextInputEvent text; /**< Text input event data */ 361 SDL_TextInputEvent text; /**< Text input event data */
355 SDL_MouseMotionEvent motion; /**< Mouse motion event data */ 362 SDL_MouseMotionEvent motion; /**< Mouse motion event data */
411 * 418 *
412 * This function is thread-safe. 419 * This function is thread-safe.
413 */ 420 */
414 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, 421 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
415 SDL_eventaction action, 422 SDL_eventaction action,
416 Uint32 mask); 423 Uint32 minType, Uint32 maxType);
417 /*@}*/ 424 /*@}*/
418 425
419 /** 426 /**
420 * Checks to see if certain event types are in the event queue. 427 * Checks to see if certain event types are in the event queue.
421 */ 428 */
422 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask); 429 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
430 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
431
432 /**
433 * This function clears events from the event queue
434 */
435 extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
436 extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
423 437
424 /** 438 /**
425 * \brief Polls for currently pending events. 439 * \brief Polls for currently pending events.
426 * 440 *
427 * \return 1 if there are any pending events, or 0 if there are none available. 441 * \return 1 if there are any pending events, or 0 if there are none available.
518 * - If \c state is set to ::SDL_ENABLE, that event will be processed 532 * - If \c state is set to ::SDL_ENABLE, that event will be processed
519 * normally. 533 * normally.
520 * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 534 * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the
521 * current processing state of the specified event. 535 * current processing state of the specified event.
522 */ 536 */
523 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); 537 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
524 /*@}*/ 538 /*@}*/
539 #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
540
541 /**
542 * This function allocates a set of user-defined events, and returns
543 * the beginning event number for that set of events.
544 *
545 * If there aren't enough user-defined events left, this function
546 * returns (Uint32)-1
547 */
548 extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
525 549
526 /* Ends C function definitions when using C++ */ 550 /* Ends C function definitions when using C++ */
527 #ifdef __cplusplus 551 #ifdef __cplusplus
528 /* *INDENT-OFF* */ 552 /* *INDENT-OFF* */
529 } 553 }