comparison include/SDL_events.h @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents c71e05b4dc2e
children 051df511279c
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 22
23 /* Include file for SDL event handling */ 23 /**
24 * \file SDL_events.h
25 *
26 * Include file for SDL event handling
27 */
24 28
25 #ifndef _SDL_events_h 29 #ifndef _SDL_events_h
26 #define _SDL_events_h 30 #define _SDL_events_h
27 31
28 #include "SDL_stdinc.h" 32 #include "SDL_stdinc.h"
29 #include "SDL_error.h" 33 #include "SDL_error.h"
30 #include "SDL_active.h" 34 #include "SDL_video.h"
31 #include "SDL_keyboard.h" 35 #include "SDL_keyboard.h"
32 #include "SDL_mouse.h" 36 #include "SDL_mouse.h"
33 #include "SDL_joystick.h" 37 #include "SDL_joystick.h"
34 #include "SDL_quit.h" 38 #include "SDL_quit.h"
35 39
36 #include "begin_code.h" 40 #include "begin_code.h"
37 /* Set up for C function definitions, even when using C++ */ 41 /* Set up for C function definitions, even when using C++ */
38 #ifdef __cplusplus 42 #ifdef __cplusplus
43 /* *INDENT-OFF* */
39 extern "C" { 44 extern "C" {
45 /* *INDENT-ON* */
40 #endif 46 #endif
41 47
42 /* General keyboard/mouse state definitions */ 48 /* General keyboard/mouse state definitions */
43 #define SDL_RELEASED 0 49 #define SDL_RELEASED 0
44 #define SDL_PRESSED 1 50 #define SDL_PRESSED 1
45 51
46 /* Event enumerations */ 52 /**
47 typedef enum { 53 * \enum SDL_EventType
48 SDL_NOEVENT = 0, /* Unused (do not remove) */ 54 *
49 SDL_ACTIVEEVENT, /* Application loses/gains visibility */ 55 * \brief The types of events that can be delivered
50 SDL_KEYDOWN, /* Keys pressed */ 56 */
51 SDL_KEYUP, /* Keys released */ 57 typedef enum
52 SDL_MOUSEMOTION, /* Mouse moved */ 58 {
53 SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */ 59 SDL_NOEVENT = 0, /**< Unused (do not remove) */
54 SDL_MOUSEBUTTONUP, /* Mouse button released */ 60 SDL_WINDOWEVENT, /**< Window state change */
55 SDL_JOYAXISMOTION, /* Joystick axis motion */ 61 SDL_KEYDOWN, /**< Keys pressed */
56 SDL_JOYBALLMOTION, /* Joystick trackball motion */ 62 SDL_KEYUP, /**< Keys released */
57 SDL_JOYHATMOTION, /* Joystick hat position change */ 63 SDL_TEXTINPUT, /**< Keyboard text input */
58 SDL_JOYBUTTONDOWN, /* Joystick button pressed */ 64 SDL_MOUSEMOTION, /**< Mouse moved */
59 SDL_JOYBUTTONUP, /* Joystick button released */ 65 SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
60 SDL_QUIT, /* User-requested quit */ 66 SDL_MOUSEBUTTONUP, /**< Mouse button released */
61 SDL_SYSWMEVENT, /* System specific event */ 67 SDL_MOUSEWHEEL, /**< Mouse wheel motion */
62 SDL_EVENT_RESERVEDA, /* Reserved for future use.. */ 68 SDL_JOYAXISMOTION, /**< Joystick axis motion */
63 SDL_EVENT_RESERVEDB, /* Reserved for future use.. */ 69 SDL_JOYBALLMOTION, /**< Joystick trackball motion */
64 SDL_VIDEORESIZE, /* User resized video mode */ 70 SDL_JOYHATMOTION, /**< Joystick hat position change */
65 SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */ 71 SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
66 SDL_EVENT_RESERVED2, /* Reserved for future use.. */ 72 SDL_JOYBUTTONUP, /**< Joystick button released */
67 SDL_EVENT_RESERVED3, /* Reserved for future use.. */ 73 SDL_QUIT, /**< User-requested quit */
68 SDL_EVENT_RESERVED4, /* Reserved for future use.. */ 74 SDL_SYSWMEVENT, /**< System specific event */
69 SDL_EVENT_RESERVED5, /* Reserved for future use.. */ 75 SDL_EVENT_RESERVED1, /**< Reserved for future use... */
70 SDL_EVENT_RESERVED6, /* Reserved for future use.. */ 76 SDL_EVENT_RESERVED2, /**< Reserved for future use... */
71 SDL_EVENT_RESERVED7, /* Reserved for future use.. */ 77 SDL_EVENT_RESERVED3, /**< Reserved for future use... */
72 /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ 78 /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
73 SDL_USEREVENT = 24, 79 SDL_USEREVENT = 24,
74 /* This last event is only for bounding internal arrays 80 /* This last event is only for bounding internal arrays
75 It is the number of bits in the event mask datatype -- Uint32 81 It is the number of bits in the event mask datatype -- Uint32
76 */ 82 */
77 SDL_NUMEVENTS = 32 83 SDL_NUMEVENTS = 32
78 } SDL_EventType; 84 } SDL_EventType;
79 85
80 /* Predefined event masks */ 86 /**
87 * \enum SDL_EventMask
88 *
89 * \brief Predefined event masks
90 */
81 #define SDL_EVENTMASK(X) (1<<(X)) 91 #define SDL_EVENTMASK(X) (1<<(X))
82 typedef enum { 92 typedef enum
83 SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), 93 {
84 SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), 94 SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT),
85 SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), 95 SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
86 SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| 96 SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
87 SDL_EVENTMASK(SDL_KEYUP), 97 SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
88 SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), 98 SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
89 SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), 99 SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
90 SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), 100 SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
91 SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| 101 SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
92 SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| 102 SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
93 SDL_EVENTMASK(SDL_MOUSEBUTTONUP), 103 SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
94 SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), 104 SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
95 SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), 105 SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
96 SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), 106 SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION),
97 SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), 107 SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION),
98 SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), 108 SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
99 SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| 109 SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP),
100 SDL_EVENTMASK(SDL_JOYBALLMOTION)| 110 SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) |
101 SDL_EVENTMASK(SDL_JOYHATMOTION)| 111 SDL_EVENTMASK(SDL_JOYBALLMOTION) |
102 SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| 112 SDL_EVENTMASK(SDL_JOYHATMOTION) |
103 SDL_EVENTMASK(SDL_JOYBUTTONUP), 113 SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP),
104 SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), 114 SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
105 SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), 115 SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
106 SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), 116 } SDL_EventMask;
107 SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
108 } SDL_EventMask ;
109 #define SDL_ALLEVENTS 0xFFFFFFFF 117 #define SDL_ALLEVENTS 0xFFFFFFFF
110 118
111 /* Application visibility event structure */ 119 /**
112 typedef struct SDL_ActiveEvent { 120 * \struct SDL_WindowEvent
113 Uint8 type; /* SDL_ACTIVEEVENT */ 121 *
114 Uint8 gain; /* Whether given states were gained or lost (1/0) */ 122 * \brief Window state change event data
115 Uint8 state; /* A mask of the focus states */ 123 */
116 } SDL_ActiveEvent; 124 typedef struct SDL_WindowEvent
117 125 {
118 /* Keyboard event structure */ 126 Uint8 type; /**< SDL_WINDOWEVENT */
119 typedef struct SDL_KeyboardEvent { 127 Uint8 event; /**< SDL_WindowEventID */
120 Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */ 128 int data1; /**< event dependent data */
121 Uint8 which; /* The keyboard device index */ 129 int data2; /**< event dependent data */
122 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ 130 SDL_WindowID windowID; /**< The associated window */
123 SDL_keysym keysym; 131 } SDL_WindowEvent;
132
133 /**
134 * \struct SDL_KeyboardEvent
135 *
136 * \brief Keyboard button event structure
137 */
138 typedef struct SDL_KeyboardEvent
139 {
140 Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */
141 Uint8 which; /**< The keyboard device index */
142 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
143 SDL_keysym keysym; /**< The key that was pressed or released */
144 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
124 } SDL_KeyboardEvent; 145 } SDL_KeyboardEvent;
125 146
126 /* Mouse motion event structure */ 147 /**
127 typedef struct SDL_MouseMotionEvent { 148 * \struct SDL_TextInputEvent
128 Uint8 type; /* SDL_MOUSEMOTION */ 149 *
129 Uint8 which; /* The mouse device index */ 150 * \brief Keyboard text input event structure
130 Uint8 state; /* The current button state */ 151 */
131 Uint16 x, y; /* The X/Y coordinates of the mouse */ 152 typedef struct SDL_TextInputEvent
132 Sint16 xrel; /* The relative motion in the X direction */ 153 {
133 Sint16 yrel; /* The relative motion in the Y direction */ 154 Uint8 type; /**< SDL_TEXTINPUT */
155 Uint8 which; /**< The keyboard device index */
156 char text[32]; /**< The input text */
157 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
158 } SDL_TextInputEvent;
159
160 /**
161 * \struct SDL_MouseMotionEvent
162 *
163 * \brief Mouse motion event structure
164 */
165 typedef struct SDL_MouseMotionEvent
166 {
167 Uint8 type; /**< SDL_MOUSEMOTION */
168 Uint8 which; /**< The mouse device index */
169 Uint8 state; /**< The current button state */
170 int x; /**< X coordinate, relative to window */
171 int y; /**< Y coordinate, relative to window */
172 int xrel; /**< The relative motion in the X direction */
173 int yrel; /**< The relative motion in the Y direction */
174 SDL_WindowID windowID; /**< The window with mouse focus, if any */
134 } SDL_MouseMotionEvent; 175 } SDL_MouseMotionEvent;
135 176
136 /* Mouse button event structure */ 177 /**
137 typedef struct SDL_MouseButtonEvent { 178 * \struct SDL_MouseButtonEvent
138 Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ 179 *
139 Uint8 which; /* The mouse device index */ 180 * \brief Mouse button event structure
140 Uint8 button; /* The mouse button index */ 181 */
141 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ 182 typedef struct SDL_MouseButtonEvent
142 Uint16 x, y; /* The X/Y coordinates of the mouse at press time */ 183 {
184 Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
185 Uint8 which; /**< The mouse device index */
186 Uint8 button; /**< The mouse button index */
187 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
188 int x; /**< X coordinate, relative to window */
189 int y; /**< Y coordinate, relative to window */
190 SDL_WindowID windowID; /**< The window with mouse focus, if any */
143 } SDL_MouseButtonEvent; 191 } SDL_MouseButtonEvent;
144 192
145 /* Joystick axis motion event structure */ 193 /**
146 typedef struct SDL_JoyAxisEvent { 194 * \struct SDL_MouseWheelEvent
147 Uint8 type; /* SDL_JOYAXISMOTION */ 195 *
148 Uint8 which; /* The joystick device index */ 196 * \brief Mouse wheel event structure
149 Uint8 axis; /* The joystick axis index */ 197 */
150 Sint16 value; /* The axis value (range: -32768 to 32767) */ 198 typedef struct SDL_MouseWheelEvent
199 {
200 Uint8 type; /**< SDL_MOUSEWHEEL */
201 Uint8 which; /**< The mouse device index */
202 int motion; /**< The direction and distance scrolled */
203 SDL_WindowID windowID; /**< The window with mouse focus, if any */
204 } SDL_MouseWheelEvent;
205
206 /**
207 * \struct SDL_JoyAxisEvent
208 *
209 * \brief Joystick axis motion event structure
210 */
211 typedef struct SDL_JoyAxisEvent
212 {
213 Uint8 type; /**< SDL_JOYAXISMOTION */
214 Uint8 which; /**< The joystick device index */
215 Uint8 axis; /**< The joystick axis index */
216 int value; /**< The axis value (range: -32768 to 32767) */
151 } SDL_JoyAxisEvent; 217 } SDL_JoyAxisEvent;
152 218
153 /* Joystick trackball motion event structure */ 219 /**
154 typedef struct SDL_JoyBallEvent { 220 * \struct SDL_JoyBallEvent
155 Uint8 type; /* SDL_JOYBALLMOTION */ 221 *
156 Uint8 which; /* The joystick device index */ 222 * \brief Joystick trackball motion event structure
157 Uint8 ball; /* The joystick trackball index */ 223 */
158 Sint16 xrel; /* The relative motion in the X direction */ 224 typedef struct SDL_JoyBallEvent
159 Sint16 yrel; /* The relative motion in the Y direction */ 225 {
226 Uint8 type; /**< SDL_JOYBALLMOTION */
227 Uint8 which; /**< The joystick device index */
228 Uint8 ball; /**< The joystick trackball index */
229 int xrel; /**< The relative motion in the X direction */
230 int yrel; /**< The relative motion in the Y direction */
160 } SDL_JoyBallEvent; 231 } SDL_JoyBallEvent;
161 232
162 /* Joystick hat position change event structure */ 233 /**
163 typedef struct SDL_JoyHatEvent { 234 * \struct SDL_JoyHatEvent
164 Uint8 type; /* SDL_JOYHATMOTION */ 235 *
165 Uint8 which; /* The joystick device index */ 236 * \brief Joystick hat position change event structure
166 Uint8 hat; /* The joystick hat index */ 237 */
167 Uint8 value; /* The hat position value: 238 typedef struct SDL_JoyHatEvent
168 SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP 239 {
169 SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT 240 Uint8 type; /**< SDL_JOYHATMOTION */
170 SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN 241 Uint8 which; /**< The joystick device index */
171 Note that zero means the POV is centered. 242 Uint8 hat; /**< The joystick hat index */
172 */ 243 Uint8 value; /**< The hat position value:
244 SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
245 SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
246 SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
247 Note that zero means the POV is centered.
248 */
173 } SDL_JoyHatEvent; 249 } SDL_JoyHatEvent;
174 250
175 /* Joystick button event structure */ 251 /**
176 typedef struct SDL_JoyButtonEvent { 252 * \struct SDL_JoyButtonEvent
177 Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ 253 *
178 Uint8 which; /* The joystick device index */ 254 * \brief Joystick button event structure
179 Uint8 button; /* The joystick button index */ 255 */
180 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ 256 typedef struct SDL_JoyButtonEvent
257 {
258 Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
259 Uint8 which; /**< The joystick device index */
260 Uint8 button; /**< The joystick button index */
261 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
181 } SDL_JoyButtonEvent; 262 } SDL_JoyButtonEvent;
182 263
183 /* The "window resized" event 264 /**
184 When you get this event, you are responsible for setting a new video 265 * \struct SDL_QuitEvent
185 mode with the new width and height. 266 *
186 */ 267 * \brief The "quit requested" event
187 typedef struct SDL_ResizeEvent { 268 */
188 Uint8 type; /* SDL_VIDEORESIZE */ 269 typedef struct SDL_QuitEvent
189 int w; /* New width */ 270 {
190 int h; /* New height */ 271 Uint8 type; /**< SDL_QUIT */
191 } SDL_ResizeEvent;
192
193 /* The "screen redraw" event */
194 typedef struct SDL_ExposeEvent {
195 Uint8 type; /* SDL_VIDEOEXPOSE */
196 } SDL_ExposeEvent;
197
198 /* The "quit requested" event */
199 typedef struct SDL_QuitEvent {
200 Uint8 type; /* SDL_QUIT */
201 } SDL_QuitEvent; 272 } SDL_QuitEvent;
202 273
203 /* A user-defined event type */ 274 /**
204 typedef struct SDL_UserEvent { 275 * \struct SDL_UserEvent
205 Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */ 276 *
206 int code; /* User defined event code */ 277 * \brief A user-defined event type
207 void *data1; /* User defined data pointer */ 278 */
208 void *data2; /* User defined data pointer */ 279 typedef struct SDL_UserEvent
280 {
281 Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */
282 int code; /**< User defined event code */
283 void *data1; /**< User defined data pointer */
284 void *data2; /**< User defined data pointer */
209 } SDL_UserEvent; 285 } SDL_UserEvent;
210 286
211 /* If you want to use this event, you should include SDL_syswm.h */ 287 /**
288 * \struct SDL_SysWMEvent
289 *
290 * \brief A video driver dependent system event
291 *
292 * \note If you want to use this event, you should include SDL_syswm.h
293 */
212 struct SDL_SysWMmsg; 294 struct SDL_SysWMmsg;
213 typedef struct SDL_SysWMmsg SDL_SysWMmsg; 295 typedef struct SDL_SysWMmsg SDL_SysWMmsg;
214 typedef struct SDL_SysWMEvent { 296 typedef struct SDL_SysWMEvent
215 Uint8 type; 297 {
216 SDL_SysWMmsg *msg; 298 Uint8 type; /**< SDL_SYSWMEVENT */
299 SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
217 } SDL_SysWMEvent; 300 } SDL_SysWMEvent;
218 301
219 /* General event structure */ 302 /* Typedefs for backwards compatibility */
220 typedef union SDL_Event { 303 typedef struct SDL_ActiveEvent
221 Uint8 type; 304 {
222 SDL_ActiveEvent active; 305 Uint8 type;
223 SDL_KeyboardEvent key; 306 Uint8 gain;
224 SDL_MouseMotionEvent motion; 307 Uint8 state;
225 SDL_MouseButtonEvent button; 308 } SDL_ActiveEvent;
226 SDL_JoyAxisEvent jaxis; 309 typedef struct SDL_ResizeEvent
227 SDL_JoyBallEvent jball; 310 {
228 SDL_JoyHatEvent jhat; 311 Uint8 type;
229 SDL_JoyButtonEvent jbutton; 312 int w;
230 SDL_ResizeEvent resize; 313 int h;
231 SDL_ExposeEvent expose; 314 } SDL_ResizeEvent;
232 SDL_QuitEvent quit; 315
233 SDL_UserEvent user; 316 /**
234 SDL_SysWMEvent syswm; 317 * \union SDL_Event
318 *
319 * \brief General event structure
320 */
321 typedef union SDL_Event
322 {
323 Uint8 type; /**< Event type, shared with all events */
324 SDL_WindowEvent window; /**< Window event data */
325 SDL_KeyboardEvent key; /**< Keyboard event data */
326 SDL_TextInputEvent text; /**< Text input event data */
327 SDL_MouseMotionEvent motion; /**< Mouse motion event data */
328 SDL_MouseButtonEvent button; /**< Mouse button event data */
329 SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
330 SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
331 SDL_JoyBallEvent jball; /**< Joystick ball event data */
332 SDL_JoyHatEvent jhat; /**< Joystick hat event data */
333 SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
334 SDL_QuitEvent quit; /**< Quit request event data */
335 SDL_UserEvent user; /**< Custom event data */
336 SDL_SysWMEvent syswm; /**< System dependent window event data */
337
338 /* Temporarily here for backwards compatibility */
339 SDL_ActiveEvent active;
340 SDL_ResizeEvent resize;
235 } SDL_Event; 341 } SDL_Event;
236 342
237 343
238 /* Function prototypes */ 344 /* Function prototypes */
239 345
253 of the event queue, matching 'mask', will be returned and will be 359 of the event queue, matching 'mask', will be returned and will be
254 removed from the queue. 360 removed from the queue.
255 This function returns the number of events actually stored, or -1 361 This function returns the number of events actually stored, or -1
256 if there was an error. This function is thread-safe. 362 if there was an error. This function is thread-safe.
257 */ 363 */
258 typedef enum { 364 typedef enum
259 SDL_ADDEVENT, 365 {
260 SDL_PEEKEVENT, 366 SDL_ADDEVENT,
261 SDL_GETEVENT 367 SDL_PEEKEVENT,
368 SDL_GETEVENT
262 } SDL_eventaction; 369 } SDL_eventaction;
263 /* */ 370 /* */
264 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, 371 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
265 SDL_eventaction action, Uint32 mask); 372 SDL_eventaction action,
373 Uint32 mask);
374
375 /* Checks to see if certain event types are in the event queue.
376 */
377 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask);
266 378
267 /* Polls for currently pending events, and returns 1 if there are any pending 379 /* Polls for currently pending events, and returns 1 if there are any pending
268 events, or 0 if there are none available. If 'event' is not NULL, the next 380 events, or 0 if there are none available. If 'event' is not NULL, the next
269 event is removed from the queue and stored in that area. 381 event is removed from the queue and stored in that area.
270 */ 382 */
271 extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); 383 extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
272 384
273 /* Waits indefinitely for the next available event, returning 1, or 0 if there 385 /* Waits indefinitely for the next available event, returning 1, or 0 if there
274 was an error while waiting for events. If 'event' is not NULL, the next 386 was an error while waiting for events. If 'event' is not NULL, the next
275 event is removed from the queue and stored in that area. 387 event is removed from the queue and stored in that area.
276 */ 388 */
277 extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); 389 extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
278 390
279 /* Add an event to the event queue. 391 /* Add an event to the event queue.
280 This function returns 0 on success, or -1 if the event queue was full 392 This function returns 1 on success, 0 if the event was filtered,
281 or there was some other error. 393 or -1 if the event queue was full or there was some other error.
282 */ 394 */
283 extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); 395 extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
284 396
285 /* 397 /*
286 This function sets up a filter to process all events before they 398 This function sets up a filter to process all events before they
287 change internal state and are posted to the internal event queue. 399 change internal state and are posted to the internal event queue.
288 400
289 The filter is protypted as: 401 The filter is protypted as:
290 */ 402 */
291 typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); 403 typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
292 /* 404 /*
293 If the filter returns 1, then the event will be added to the internal queue. 405 If the filter returns 1, then the event will be added to the internal queue.
294 If it returns 0, then the event will be dropped from the queue, but the 406 If it returns 0, then the event will be dropped from the queue, but the
295 internal state will still be updated. This allows selective filtering of 407 internal state will still be updated. This allows selective filtering of
296 dynamically arriving events. 408 dynamically arriving events.
303 application window. If the event filter returns 1, then the window will 415 application window. If the event filter returns 1, then the window will
304 be closed, otherwise the window will remain open if possible. 416 be closed, otherwise the window will remain open if possible.
305 If the quit event is generated by an interrupt signal, it will bypass the 417 If the quit event is generated by an interrupt signal, it will bypass the
306 internal queue and be delivered to the application at the next event poll. 418 internal queue and be delivered to the application at the next event poll.
307 */ 419 */
308 extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); 420 extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
421 void *userdata);
309 422
310 /* 423 /*
311 Return the current event filter - can be used to "chain" filters. 424 Return the current event filter - can be used to "chain" filters.
312 If there is no event filter set, this function returns NULL. 425 If there is no event filter set, this function returns SDL_FALSE.
313 */ 426 */
314 extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); 427 extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
428 void **userdata);
429
430 /*
431 Run the filter function on the current event queue, removing any
432 events for which the filter returns 0.
433 */
434 extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
435 void *userdata);
315 436
316 /* 437 /*
317 This function allows you to set the state of processing certain events. 438 This function allows you to set the state of processing certain events.
318 If 'state' is set to SDL_IGNORE, that event will be automatically dropped 439 If 'state' is set to SDL_IGNORE, that event will be automatically dropped
319 from the event queue and will not event be filtered. 440 from the event queue and will not event be filtered.
328 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); 449 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
329 450
330 451
331 /* Ends C function definitions when using C++ */ 452 /* Ends C function definitions when using C++ */
332 #ifdef __cplusplus 453 #ifdef __cplusplus
454 /* *INDENT-OFF* */
333 } 455 }
456 /* *INDENT-ON* */
334 #endif 457 #endif
335 #include "close_code.h" 458 #include "close_code.h"
336 459
337 #endif /* _SDL_events_h */ 460 #endif /* _SDL_events_h */
461
462 /* vi: set ts=4 sw=4 expandtab: */