Subversion Repositories Games.Carmageddon

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
  Simple DirectMedia Layer
3
  Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
4
 
5
  This software is provided 'as-is', without any express or implied
6
  warranty.  In no event will the authors be held liable for any damages
7
  arising from the use of this software.
8
 
9
  Permission is granted to anyone to use this software for any purpose,
10
  including commercial applications, and to alter it and redistribute it
11
  freely, subject to the following restrictions:
12
 
13
  1. The origin of this software must not be misrepresented; you must not
14
     claim that you wrote the original software. If you use this software
15
     in a product, an acknowledgment in the product documentation would be
16
     appreciated but is not required.
17
  2. Altered source versions must be plainly marked as such, and must not be
18
     misrepresented as being the original software.
19
  3. This notice may not be removed or altered from any source distribution.
20
*/
21
 
22
/**
23
 *  \file SDL_events.h
24
 *
25
 *  Include file for SDL event handling.
26
 */
27
 
28
#ifndef SDL_events_h_
29
#define SDL_events_h_
30
 
31
#include "SDL_stdinc.h"
32
#include "SDL_error.h"
33
#include "SDL_video.h"
34
#include "SDL_keyboard.h"
35
#include "SDL_mouse.h"
36
#include "SDL_joystick.h"
37
#include "SDL_gamecontroller.h"
38
#include "SDL_quit.h"
39
#include "SDL_gesture.h"
40
#include "SDL_touch.h"
41
 
42
#include "begin_code.h"
43
/* Set up for C function definitions, even when using C++ */
44
#ifdef __cplusplus
45
extern "C" {
46
#endif
47
 
48
/* General keyboard/mouse state definitions */
49
#define SDL_RELEASED    0
50
#define SDL_PRESSED 1
51
 
52
/**
53
 * The types of events that can be delivered.
54
 */
55
typedef enum
56
{
57
    SDL_FIRSTEVENT     = 0,     /**< Unused (do not remove) */
58
 
59
    /* Application events */
60
    SDL_QUIT           = 0x100, /**< User-requested quit */
61
 
62
    /* These application events have special meaning on iOS, see README-ios.md for details */
63
    SDL_APP_TERMINATING,        /**< The application is being terminated by the OS
64
                                     Called on iOS in applicationWillTerminate()
65
                                     Called on Android in onDestroy()
66
                                */
67
    SDL_APP_LOWMEMORY,          /**< The application is low on memory, free memory if possible.
68
                                     Called on iOS in applicationDidReceiveMemoryWarning()
69
                                     Called on Android in onLowMemory()
70
                                */
71
    SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background
72
                                     Called on iOS in applicationWillResignActive()
73
                                     Called on Android in onPause()
74
                                */
75
    SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time
76
                                     Called on iOS in applicationDidEnterBackground()
77
                                     Called on Android in onPause()
78
                                */
79
    SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground
80
                                     Called on iOS in applicationWillEnterForeground()
81
                                     Called on Android in onResume()
82
                                */
83
    SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive
84
                                     Called on iOS in applicationDidBecomeActive()
85
                                     Called on Android in onResume()
86
                                */
87
 
88
    SDL_LOCALECHANGED,  /**< The user's locale preferences have changed. */
89
 
90
    /* Display events */
91
    SDL_DISPLAYEVENT   = 0x150,  /**< Display state change */
92
 
93
    /* Window events */
94
    SDL_WINDOWEVENT    = 0x200, /**< Window state change */
95
    SDL_SYSWMEVENT,             /**< System specific event */
96
 
97
    /* Keyboard events */
98
    SDL_KEYDOWN        = 0x300, /**< Key pressed */
99
    SDL_KEYUP,                  /**< Key released */
100
    SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
101
    SDL_TEXTINPUT,              /**< Keyboard text input */
102
    SDL_KEYMAPCHANGED,          /**< Keymap changed due to a system event such as an
103
                                     input language or keyboard layout change.
104
                                */
105
    SDL_TEXTEDITING_EXT,       /**< Extended keyboard text editing (composition) */
106
 
107
    /* Mouse events */
108
    SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
109
    SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
110
    SDL_MOUSEBUTTONUP,          /**< Mouse button released */
111
    SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
112
 
113
    /* Joystick events */
114
    SDL_JOYAXISMOTION  = 0x600, /**< Joystick axis motion */
115
    SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
116
    SDL_JOYHATMOTION,           /**< Joystick hat position change */
117
    SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
118
    SDL_JOYBUTTONUP,            /**< Joystick button released */
119
    SDL_JOYDEVICEADDED,         /**< A new joystick has been inserted into the system */
120
    SDL_JOYDEVICEREMOVED,       /**< An opened joystick has been removed */
121
    SDL_JOYBATTERYUPDATED,      /**< Joystick battery level change */
122
 
123
    /* Game controller events */
124
    SDL_CONTROLLERAXISMOTION  = 0x650, /**< Game controller axis motion */
125
    SDL_CONTROLLERBUTTONDOWN,          /**< Game controller button pressed */
126
    SDL_CONTROLLERBUTTONUP,            /**< Game controller button released */
127
    SDL_CONTROLLERDEVICEADDED,         /**< A new Game controller has been inserted into the system */
128
    SDL_CONTROLLERDEVICEREMOVED,       /**< An opened Game controller has been removed */
129
    SDL_CONTROLLERDEVICEREMAPPED,      /**< The controller mapping was updated */
130
    SDL_CONTROLLERTOUCHPADDOWN,        /**< Game controller touchpad was touched */
131
    SDL_CONTROLLERTOUCHPADMOTION,      /**< Game controller touchpad finger was moved */
132
    SDL_CONTROLLERTOUCHPADUP,          /**< Game controller touchpad finger was lifted */
133
    SDL_CONTROLLERSENSORUPDATE,        /**< Game controller sensor was updated */
134
 
135
    /* Touch events */
136
    SDL_FINGERDOWN      = 0x700,
137
    SDL_FINGERUP,
138
    SDL_FINGERMOTION,
139
 
140
    /* Gesture events */
141
    SDL_DOLLARGESTURE   = 0x800,
142
    SDL_DOLLARRECORD,
143
    SDL_MULTIGESTURE,
144
 
145
    /* Clipboard events */
146
    SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard or primary selection changed */
147
 
148
    /* Drag and drop events */
149
    SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
150
    SDL_DROPTEXT,                 /**< text/plain drag-and-drop event */
151
    SDL_DROPBEGIN,                /**< A new set of drops is beginning (NULL filename) */
152
    SDL_DROPCOMPLETE,             /**< Current set of drops is now complete (NULL filename) */
153
 
154
    /* Audio hotplug events */
155
    SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
156
    SDL_AUDIODEVICEREMOVED,        /**< An audio device has been removed. */
157
 
158
    /* Sensor events */
159
    SDL_SENSORUPDATE = 0x1200,     /**< A sensor was updated */
160
 
161
    /* Render events */
162
    SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
163
    SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
164
 
165
    /* Internal events */
166
    SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
167
 
168
    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
169
     *  and should be allocated with SDL_RegisterEvents()
170
     */
171
    SDL_USEREVENT    = 0x8000,
172
 
173
    /**
174
     *  This last event is only for bounding internal arrays
175
     */
176
    SDL_LASTEVENT    = 0xFFFF
177
} SDL_EventType;
178
 
179
/**
180
 *  \brief Fields shared by every event
181
 */
182
typedef struct SDL_CommonEvent
183
{
184
    Uint32 type;
185
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
186
} SDL_CommonEvent;
187
 
188
/**
189
 *  \brief Display state change event data (event.display.*)
190
 */
191
typedef struct SDL_DisplayEvent
192
{
193
    Uint32 type;        /**< ::SDL_DISPLAYEVENT */
194
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
195
    Uint32 display;     /**< The associated display index */
196
    Uint8 event;        /**< ::SDL_DisplayEventID */
197
    Uint8 padding1;
198
    Uint8 padding2;
199
    Uint8 padding3;
200
    Sint32 data1;       /**< event dependent data */
201
} SDL_DisplayEvent;
202
 
203
/**
204
 *  \brief Window state change event data (event.window.*)
205
 */
206
typedef struct SDL_WindowEvent
207
{
208
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
209
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
210
    Uint32 windowID;    /**< The associated window */
211
    Uint8 event;        /**< ::SDL_WindowEventID */
212
    Uint8 padding1;
213
    Uint8 padding2;
214
    Uint8 padding3;
215
    Sint32 data1;       /**< event dependent data */
216
    Sint32 data2;       /**< event dependent data */
217
} SDL_WindowEvent;
218
 
219
/**
220
 *  \brief Keyboard button event structure (event.key.*)
221
 */
222
typedef struct SDL_KeyboardEvent
223
{
224
    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
225
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
226
    Uint32 windowID;    /**< The window with keyboard focus, if any */
227
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
228
    Uint8 repeat;       /**< Non-zero if this is a key repeat */
229
    Uint8 padding2;
230
    Uint8 padding3;
231
    SDL_Keysym keysym;  /**< The key that was pressed or released */
232
} SDL_KeyboardEvent;
233
 
234
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
235
/**
236
 *  \brief Keyboard text editing event structure (event.edit.*)
237
 */
238
typedef struct SDL_TextEditingEvent
239
{
240
    Uint32 type;                                /**< ::SDL_TEXTEDITING */
241
    Uint32 timestamp;                           /**< In milliseconds, populated using SDL_GetTicks() */
242
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
243
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
244
    Sint32 start;                               /**< The start cursor of selected editing text */
245
    Sint32 length;                              /**< The length of selected editing text */
246
} SDL_TextEditingEvent;
247
 
248
/**
249
 *  \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
250
 *  truncated if stored in the text buffer SDL_TextEditingEvent
251
 */
252
typedef struct SDL_TextEditingExtEvent
253
{
254
    Uint32 type;                                /**< ::SDL_TEXTEDITING_EXT */
255
    Uint32 timestamp;                           /**< In milliseconds, populated using SDL_GetTicks() */
256
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
257
    char* text;                                 /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
258
    Sint32 start;                               /**< The start cursor of selected editing text */
259
    Sint32 length;                              /**< The length of selected editing text */
260
} SDL_TextEditingExtEvent;
261
 
262
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
263
/**
264
 *  \brief Keyboard text input event structure (event.text.*)
265
 */
266
typedef struct SDL_TextInputEvent
267
{
268
    Uint32 type;                              /**< ::SDL_TEXTINPUT */
269
    Uint32 timestamp;                         /**< In milliseconds, populated using SDL_GetTicks() */
270
    Uint32 windowID;                          /**< The window with keyboard focus, if any */
271
    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
272
} SDL_TextInputEvent;
273
 
274
/**
275
 *  \brief Mouse motion event structure (event.motion.*)
276
 */
277
typedef struct SDL_MouseMotionEvent
278
{
279
    Uint32 type;        /**< ::SDL_MOUSEMOTION */
280
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
281
    Uint32 windowID;    /**< The window with mouse focus, if any */
282
    Uint32 which;       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
283
    Uint32 state;       /**< The current button state */
284
    Sint32 x;           /**< X coordinate, relative to window */
285
    Sint32 y;           /**< Y coordinate, relative to window */
286
    Sint32 xrel;        /**< The relative motion in the X direction */
287
    Sint32 yrel;        /**< The relative motion in the Y direction */
288
} SDL_MouseMotionEvent;
289
 
290
/**
291
 *  \brief Mouse button event structure (event.button.*)
292
 */
293
typedef struct SDL_MouseButtonEvent
294
{
295
    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
296
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
297
    Uint32 windowID;    /**< The window with mouse focus, if any */
298
    Uint32 which;       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
299
    Uint8 button;       /**< The mouse button index */
300
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
301
    Uint8 clicks;       /**< 1 for single-click, 2 for double-click, etc. */
302
    Uint8 padding1;
303
    Sint32 x;           /**< X coordinate, relative to window */
304
    Sint32 y;           /**< Y coordinate, relative to window */
305
} SDL_MouseButtonEvent;
306
 
307
/**
308
 *  \brief Mouse wheel event structure (event.wheel.*)
309
 */
310
typedef struct SDL_MouseWheelEvent
311
{
312
    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
313
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
314
    Uint32 windowID;    /**< The window with mouse focus, if any */
315
    Uint32 which;       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
316
    Sint32 x;           /**< The amount scrolled horizontally, positive to the right and negative to the left */
317
    Sint32 y;           /**< The amount scrolled vertically, positive away from the user and negative toward the user */
318
    Uint32 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 */
319
    float preciseX;     /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
320
    float preciseY;     /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
321
    Sint32 mouseX;      /**< X coordinate, relative to window (added in 2.26.0) */
322
    Sint32 mouseY;      /**< Y coordinate, relative to window (added in 2.26.0) */
323
} SDL_MouseWheelEvent;
324
 
325
/**
326
 *  \brief Joystick axis motion event structure (event.jaxis.*)
327
 */
328
typedef struct SDL_JoyAxisEvent
329
{
330
    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
331
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
332
    SDL_JoystickID which; /**< The joystick instance id */
333
    Uint8 axis;         /**< The joystick axis index */
334
    Uint8 padding1;
335
    Uint8 padding2;
336
    Uint8 padding3;
337
    Sint16 value;       /**< The axis value (range: -32768 to 32767) */
338
    Uint16 padding4;
339
} SDL_JoyAxisEvent;
340
 
341
/**
342
 *  \brief Joystick trackball motion event structure (event.jball.*)
343
 */
344
typedef struct SDL_JoyBallEvent
345
{
346
    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
347
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
348
    SDL_JoystickID which; /**< The joystick instance id */
349
    Uint8 ball;         /**< The joystick trackball index */
350
    Uint8 padding1;
351
    Uint8 padding2;
352
    Uint8 padding3;
353
    Sint16 xrel;        /**< The relative motion in the X direction */
354
    Sint16 yrel;        /**< The relative motion in the Y direction */
355
} SDL_JoyBallEvent;
356
 
357
/**
358
 *  \brief Joystick hat position change event structure (event.jhat.*)
359
 */
360
typedef struct SDL_JoyHatEvent
361
{
362
    Uint32 type;        /**< ::SDL_JOYHATMOTION */
363
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
364
    SDL_JoystickID which; /**< The joystick instance id */
365
    Uint8 hat;          /**< The joystick hat index */
366
    Uint8 value;        /**< The hat position value.
367
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
368
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
369
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
370
                         *
371
                         *   Note that zero means the POV is centered.
372
                         */
373
    Uint8 padding1;
374
    Uint8 padding2;
375
} SDL_JoyHatEvent;
376
 
377
/**
378
 *  \brief Joystick button event structure (event.jbutton.*)
379
 */
380
typedef struct SDL_JoyButtonEvent
381
{
382
    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
383
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
384
    SDL_JoystickID which; /**< The joystick instance id */
385
    Uint8 button;       /**< The joystick button index */
386
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
387
    Uint8 padding1;
388
    Uint8 padding2;
389
} SDL_JoyButtonEvent;
390
 
391
/**
392
 *  \brief Joystick device event structure (event.jdevice.*)
393
 */
394
typedef struct SDL_JoyDeviceEvent
395
{
396
    Uint32 type;        /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
397
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
398
    Sint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
399
} SDL_JoyDeviceEvent;
400
 
401
/**
402
 *  \brief Joysick battery level change event structure (event.jbattery.*)
403
 */
404
typedef struct SDL_JoyBatteryEvent
405
{
406
    Uint32 type;        /**< ::SDL_JOYBATTERYUPDATED */
407
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
408
    SDL_JoystickID which; /**< The joystick instance id */
409
    SDL_JoystickPowerLevel level; /**< The joystick battery level */
410
} SDL_JoyBatteryEvent;
411
 
412
/**
413
 *  \brief Game controller axis motion event structure (event.caxis.*)
414
 */
415
typedef struct SDL_ControllerAxisEvent
416
{
417
    Uint32 type;        /**< ::SDL_CONTROLLERAXISMOTION */
418
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
419
    SDL_JoystickID which; /**< The joystick instance id */
420
    Uint8 axis;         /**< The controller axis (SDL_GameControllerAxis) */
421
    Uint8 padding1;
422
    Uint8 padding2;
423
    Uint8 padding3;
424
    Sint16 value;       /**< The axis value (range: -32768 to 32767) */
425
    Uint16 padding4;
426
} SDL_ControllerAxisEvent;
427
 
428
 
429
/**
430
 *  \brief Game controller button event structure (event.cbutton.*)
431
 */
432
typedef struct SDL_ControllerButtonEvent
433
{
434
    Uint32 type;        /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
435
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
436
    SDL_JoystickID which; /**< The joystick instance id */
437
    Uint8 button;       /**< The controller button (SDL_GameControllerButton) */
438
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
439
    Uint8 padding1;
440
    Uint8 padding2;
441
} SDL_ControllerButtonEvent;
442
 
443
 
444
/**
445
 *  \brief Controller device event structure (event.cdevice.*)
446
 */
447
typedef struct SDL_ControllerDeviceEvent
448
{
449
    Uint32 type;        /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
450
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
451
    Sint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
452
} SDL_ControllerDeviceEvent;
453
 
454
/**
455
 *  \brief Game controller touchpad event structure (event.ctouchpad.*)
456
 */
457
typedef struct SDL_ControllerTouchpadEvent
458
{
459
    Uint32 type;        /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
460
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
461
    SDL_JoystickID which; /**< The joystick instance id */
462
    Sint32 touchpad;    /**< The index of the touchpad */
463
    Sint32 finger;      /**< The index of the finger on the touchpad */
464
    float x;            /**< Normalized in the range 0...1 with 0 being on the left */
465
    float y;            /**< Normalized in the range 0...1 with 0 being at the top */
466
    float pressure;     /**< Normalized in the range 0...1 */
467
} SDL_ControllerTouchpadEvent;
468
 
469
/**
470
 *  \brief Game controller sensor event structure (event.csensor.*)
471
 */
472
typedef struct SDL_ControllerSensorEvent
473
{
474
    Uint32 type;        /**< ::SDL_CONTROLLERSENSORUPDATE */
475
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
476
    SDL_JoystickID which; /**< The joystick instance id */
477
    Sint32 sensor;      /**< The type of the sensor, one of the values of ::SDL_SensorType */
478
    float data[3];      /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
479
    Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
480
} SDL_ControllerSensorEvent;
481
 
482
/**
483
 *  \brief Audio device event structure (event.adevice.*)
484
 */
485
typedef struct SDL_AudioDeviceEvent
486
{
487
    Uint32 type;        /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
488
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
489
    Uint32 which;       /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
490
    Uint8 iscapture;    /**< zero if an output device, non-zero if a capture device. */
491
    Uint8 padding1;
492
    Uint8 padding2;
493
    Uint8 padding3;
494
} SDL_AudioDeviceEvent;
495
 
496
 
497
/**
498
 *  \brief Touch finger event structure (event.tfinger.*)
499
 */
500
typedef struct SDL_TouchFingerEvent
501
{
502
    Uint32 type;        /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
503
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
504
    SDL_TouchID touchId; /**< The touch device id */
505
    SDL_FingerID fingerId;
506
    float x;            /**< Normalized in the range 0...1 */
507
    float y;            /**< Normalized in the range 0...1 */
508
    float dx;           /**< Normalized in the range -1...1 */
509
    float dy;           /**< Normalized in the range -1...1 */
510
    float pressure;     /**< Normalized in the range 0...1 */
511
    Uint32 windowID;    /**< The window underneath the finger, if any */
512
} SDL_TouchFingerEvent;
513
 
514
 
515
/**
516
 *  \brief Multiple Finger Gesture Event (event.mgesture.*)
517
 */
518
typedef struct SDL_MultiGestureEvent
519
{
520
    Uint32 type;        /**< ::SDL_MULTIGESTURE */
521
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
522
    SDL_TouchID touchId; /**< The touch device id */
523
    float dTheta;
524
    float dDist;
525
    float x;
526
    float y;
527
    Uint16 numFingers;
528
    Uint16 padding;
529
} SDL_MultiGestureEvent;
530
 
531
 
532
/**
533
 * \brief Dollar Gesture Event (event.dgesture.*)
534
 */
535
typedef struct SDL_DollarGestureEvent
536
{
537
    Uint32 type;        /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
538
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
539
    SDL_TouchID touchId; /**< The touch device id */
540
    SDL_GestureID gestureId;
541
    Uint32 numFingers;
542
    float error;
543
    float x;            /**< Normalized center of gesture */
544
    float y;            /**< Normalized center of gesture */
545
} SDL_DollarGestureEvent;
546
 
547
 
548
/**
549
 *  \brief An event used to request a file open by the system (event.drop.*)
550
 *         This event is enabled by default, you can disable it with SDL_EventState().
551
 *  \note If this event is enabled, you must free the filename in the event.
552
 */
553
typedef struct SDL_DropEvent
554
{
555
    Uint32 type;        /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
556
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
557
    char *file;         /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
558
    Uint32 windowID;    /**< The window that was dropped on, if any */
559
} SDL_DropEvent;
560
 
561
 
562
/**
563
 *  \brief Sensor event structure (event.sensor.*)
564
 */
565
typedef struct SDL_SensorEvent
566
{
567
    Uint32 type;        /**< ::SDL_SENSORUPDATE */
568
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
569
    Sint32 which;       /**< The instance ID of the sensor */
570
    float data[6];      /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
571
    Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
572
} SDL_SensorEvent;
573
 
574
/**
575
 *  \brief The "quit requested" event
576
 */
577
typedef struct SDL_QuitEvent
578
{
579
    Uint32 type;        /**< ::SDL_QUIT */
580
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
581
} SDL_QuitEvent;
582
 
583
/**
584
 *  \brief OS Specific event
585
 */
586
typedef struct SDL_OSEvent
587
{
588
    Uint32 type;        /**< ::SDL_QUIT */
589
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
590
} SDL_OSEvent;
591
 
592
/**
593
 *  \brief A user-defined event type (event.user.*)
594
 */
595
typedef struct SDL_UserEvent
596
{
597
    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
598
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
599
    Uint32 windowID;    /**< The associated window if any */
600
    Sint32 code;        /**< User defined event code */
601
    void *data1;        /**< User defined data pointer */
602
    void *data2;        /**< User defined data pointer */
603
} SDL_UserEvent;
604
 
605
 
606
struct SDL_SysWMmsg;
607
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
608
 
609
/**
610
 *  \brief A video driver dependent system event (event.syswm.*)
611
 *         This event is disabled by default, you can enable it with SDL_EventState()
612
 *
613
 *  \note If you want to use this event, you should include SDL_syswm.h.
614
 */
615
typedef struct SDL_SysWMEvent
616
{
617
    Uint32 type;        /**< ::SDL_SYSWMEVENT */
618
    Uint32 timestamp;   /**< In milliseconds, populated using SDL_GetTicks() */
619
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
620
} SDL_SysWMEvent;
621
 
622
/**
623
 *  \brief General event structure
624
 */
625
typedef union SDL_Event
626
{
627
    Uint32 type;                            /**< Event type, shared with all events */
628
    SDL_CommonEvent common;                 /**< Common event data */
629
    SDL_DisplayEvent display;               /**< Display event data */
630
    SDL_WindowEvent window;                 /**< Window event data */
631
    SDL_KeyboardEvent key;                  /**< Keyboard event data */
632
    SDL_TextEditingEvent edit;              /**< Text editing event data */
633
    SDL_TextEditingExtEvent editExt;        /**< Extended text editing event data */
634
    SDL_TextInputEvent text;                /**< Text input event data */
635
    SDL_MouseMotionEvent motion;            /**< Mouse motion event data */
636
    SDL_MouseButtonEvent button;            /**< Mouse button event data */
637
    SDL_MouseWheelEvent wheel;              /**< Mouse wheel event data */
638
    SDL_JoyAxisEvent jaxis;                 /**< Joystick axis event data */
639
    SDL_JoyBallEvent jball;                 /**< Joystick ball event data */
640
    SDL_JoyHatEvent jhat;                   /**< Joystick hat event data */
641
    SDL_JoyButtonEvent jbutton;             /**< Joystick button event data */
642
    SDL_JoyDeviceEvent jdevice;             /**< Joystick device change event data */
643
    SDL_JoyBatteryEvent jbattery;           /**< Joystick battery event data */
644
    SDL_ControllerAxisEvent caxis;          /**< Game Controller axis event data */
645
    SDL_ControllerButtonEvent cbutton;      /**< Game Controller button event data */
646
    SDL_ControllerDeviceEvent cdevice;      /**< Game Controller device event data */
647
    SDL_ControllerTouchpadEvent ctouchpad;  /**< Game Controller touchpad event data */
648
    SDL_ControllerSensorEvent csensor;      /**< Game Controller sensor event data */
649
    SDL_AudioDeviceEvent adevice;           /**< Audio device event data */
650
    SDL_SensorEvent sensor;                 /**< Sensor event data */
651
    SDL_QuitEvent quit;                     /**< Quit request event data */
652
    SDL_UserEvent user;                     /**< Custom event data */
653
    SDL_SysWMEvent syswm;                   /**< System dependent window event data */
654
    SDL_TouchFingerEvent tfinger;           /**< Touch finger event data */
655
    SDL_MultiGestureEvent mgesture;         /**< Gesture event data */
656
    SDL_DollarGestureEvent dgesture;        /**< Gesture event data */
657
    SDL_DropEvent drop;                     /**< Drag and drop event data */
658
 
659
    /* This is necessary for ABI compatibility between Visual C++ and GCC.
660
       Visual C++ will respect the push pack pragma and use 52 bytes (size of
661
       SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
662
       architectures) for this union, and GCC will use the alignment of the
663
       largest datatype within the union, which is 8 bytes on 64-bit
664
       architectures.
665
 
666
       So... we'll add padding to force the size to be 56 bytes for both.
667
 
668
       On architectures where pointers are 16 bytes, this needs rounding up to
669
       the next multiple of 16, 64, and on architectures where pointers are
670
       even larger the size of SDL_UserEvent will dominate as being 3 pointers.
671
    */
672
    Uint8 padding[sizeof(void *) <= 8 ? 56 : sizeof(void *) == 16 ? 64 : 3 * sizeof(void *)];
673
} SDL_Event;
674
 
675
/* Make sure we haven't broken binary compatibility */
676
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
677
 
678
 
679
/* Function prototypes */
680
 
681
/**
682
 * Pump the event loop, gathering events from the input devices.
683
 *
684
 * This function updates the event queue and internal input device state.
685
 *
686
 * **WARNING**: This should only be run in the thread that initialized the
687
 * video subsystem, and for extra safety, you should consider only doing those
688
 * things on the main thread in any case.
689
 *
690
 * SDL_PumpEvents() gathers all the pending input information from devices and
691
 * places it in the event queue. Without calls to SDL_PumpEvents() no events
692
 * would ever be placed on the queue. Often the need for calls to
693
 * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
694
 * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
695
 * polling or waiting for events (e.g. you are filtering them), then you must
696
 * call SDL_PumpEvents() to force an event queue update.
697
 *
698
 * \since This function is available since SDL 2.0.0.
699
 *
700
 * \sa SDL_PollEvent
701
 * \sa SDL_WaitEvent
702
 */
703
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
704
 
705
/* @{ */
706
typedef enum
707
{
708
    SDL_ADDEVENT,
709
    SDL_PEEKEVENT,
710
    SDL_GETEVENT
711
} SDL_eventaction;
712
 
713
/**
714
 * Check the event queue for messages and optionally return them.
715
 *
716
 * `action` may be any of the following:
717
 *
718
 * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the
719
 *   event queue.
720
 * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
721
 *   within the specified minimum and maximum type, will be returned to the
722
 *   caller and will _not_ be removed from the queue.
723
 * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
724
 *   within the specified minimum and maximum type, will be returned to the
725
 *   caller and will be removed from the queue.
726
 *
727
 * You may have to call SDL_PumpEvents() before calling this function.
728
 * Otherwise, the events may not be ready to be filtered when you call
729
 * SDL_PeepEvents().
730
 *
731
 * This function is thread-safe.
732
 *
733
 * \param events destination buffer for the retrieved events
734
 * \param numevents if action is SDL_ADDEVENT, the number of events to add
735
 *                  back to the event queue; if action is SDL_PEEKEVENT or
736
 *                  SDL_GETEVENT, the maximum number of events to retrieve
737
 * \param action action to take; see [[#action|Remarks]] for details
738
 * \param minType minimum value of the event type to be considered;
739
 *                SDL_FIRSTEVENT is a safe choice
740
 * \param maxType maximum value of the event type to be considered;
741
 *                SDL_LASTEVENT is a safe choice
742
 * \returns the number of events actually stored or a negative error code on
743
 *          failure; call SDL_GetError() for more information.
744
 *
745
 * \since This function is available since SDL 2.0.0.
746
 *
747
 * \sa SDL_PollEvent
748
 * \sa SDL_PumpEvents
749
 * \sa SDL_PushEvent
750
 */
751
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
752
                                           SDL_eventaction action,
753
                                           Uint32 minType, Uint32 maxType);
754
/* @} */
755
 
756
/**
757
 * Check for the existence of a certain event type in the event queue.
758
 *
759
 * If you need to check for a range of event types, use SDL_HasEvents()
760
 * instead.
761
 *
762
 * \param type the type of event to be queried; see SDL_EventType for details
763
 * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
764
 *          events matching `type` are not present.
765
 *
766
 * \since This function is available since SDL 2.0.0.
767
 *
768
 * \sa SDL_HasEvents
769
 */
770
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
771
 
772
 
773
/**
774
 * Check for the existence of certain event types in the event queue.
775
 *
776
 * If you need to check for a single event type, use SDL_HasEvent() instead.
777
 *
778
 * \param minType the low end of event type to be queried, inclusive; see
779
 *                SDL_EventType for details
780
 * \param maxType the high end of event type to be queried, inclusive; see
781
 *                SDL_EventType for details
782
 * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
783
 *          present, or SDL_FALSE if not.
784
 *
785
 * \since This function is available since SDL 2.0.0.
786
 *
787
 * \sa SDL_HasEvents
788
 */
789
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
790
 
791
/**
792
 * Clear events of a specific type from the event queue.
793
 *
794
 * This will unconditionally remove any events from the queue that match
795
 * `type`. If you need to remove a range of event types, use SDL_FlushEvents()
796
 * instead.
797
 *
798
 * It's also normal to just ignore events you don't care about in your event
799
 * loop without calling this function.
800
 *
801
 * This function only affects currently queued events. If you want to make
802
 * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
803
 * on the main thread immediately before the flush call.
804
 *
805
 * \param type the type of event to be cleared; see SDL_EventType for details
806
 *
807
 * \since This function is available since SDL 2.0.0.
808
 *
809
 * \sa SDL_FlushEvents
810
 */
811
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
812
 
813
/**
814
 * Clear events of a range of types from the event queue.
815
 *
816
 * This will unconditionally remove any events from the queue that are in the
817
 * range of `minType` to `maxType`, inclusive. If you need to remove a single
818
 * event type, use SDL_FlushEvent() instead.
819
 *
820
 * It's also normal to just ignore events you don't care about in your event
821
 * loop without calling this function.
822
 *
823
 * This function only affects currently queued events. If you want to make
824
 * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
825
 * on the main thread immediately before the flush call.
826
 *
827
 * \param minType the low end of event type to be cleared, inclusive; see
828
 *                SDL_EventType for details
829
 * \param maxType the high end of event type to be cleared, inclusive; see
830
 *                SDL_EventType for details
831
 *
832
 * \since This function is available since SDL 2.0.0.
833
 *
834
 * \sa SDL_FlushEvent
835
 */
836
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
837
 
838
/**
839
 * Poll for currently pending events.
840
 *
841
 * If `event` is not NULL, the next event is removed from the queue and stored
842
 * in the SDL_Event structure pointed to by `event`. The 1 returned refers to
843
 * this event, immediately stored in the SDL Event structure -- not an event
844
 * to follow.
845
 *
846
 * If `event` is NULL, it simply returns 1 if there is an event in the queue,
847
 * but will not remove it from the queue.
848
 *
849
 * As this function may implicitly call SDL_PumpEvents(), you can only call
850
 * this function in the thread that set the video mode.
851
 *
852
 * SDL_PollEvent() is the favored way of receiving system events since it can
853
 * be done from the main loop and does not suspend the main loop while waiting
854
 * on an event to be posted.
855
 *
856
 * The common practice is to fully process the event queue once every frame,
857
 * usually as a first step before updating the game's state:
858
 *
859
 * ```c
860
 * while (game_is_still_running) {
861
 *     SDL_Event event;
862
 *     while (SDL_PollEvent(&event)) {  // poll until all events are handled!
863
 *         // decide what to do with this event.
864
 *     }
865
 *
866
 *     // update game state, draw the current frame
867
 * }
868
 * ```
869
 *
870
 * \param event the SDL_Event structure to be filled with the next event from
871
 *              the queue, or NULL
872
 * \returns 1 if there is a pending event or 0 if there are none available.
873
 *
874
 * \since This function is available since SDL 2.0.0.
875
 *
876
 * \sa SDL_GetEventFilter
877
 * \sa SDL_PeepEvents
878
 * \sa SDL_PushEvent
879
 * \sa SDL_SetEventFilter
880
 * \sa SDL_WaitEvent
881
 * \sa SDL_WaitEventTimeout
882
 */
883
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
884
 
885
/**
886
 * Wait indefinitely for the next available event.
887
 *
888
 * If `event` is not NULL, the next event is removed from the queue and stored
889
 * in the SDL_Event structure pointed to by `event`.
890
 *
891
 * As this function may implicitly call SDL_PumpEvents(), you can only call
892
 * this function in the thread that initialized the video subsystem.
893
 *
894
 * \param event the SDL_Event structure to be filled in with the next event
895
 *              from the queue, or NULL
896
 * \returns 1 on success or 0 if there was an error while waiting for events;
897
 *          call SDL_GetError() for more information.
898
 *
899
 * \since This function is available since SDL 2.0.0.
900
 *
901
 * \sa SDL_PollEvent
902
 * \sa SDL_PumpEvents
903
 * \sa SDL_WaitEventTimeout
904
 */
905
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
906
 
907
/**
908
 * Wait until the specified timeout (in milliseconds) for the next available
909
 * event.
910
 *
911
 * If `event` is not NULL, the next event is removed from the queue and stored
912
 * in the SDL_Event structure pointed to by `event`.
913
 *
914
 * As this function may implicitly call SDL_PumpEvents(), you can only call
915
 * this function in the thread that initialized the video subsystem.
916
 *
917
 * \param event the SDL_Event structure to be filled in with the next event
918
 *              from the queue, or NULL
919
 * \param timeout the maximum number of milliseconds to wait for the next
920
 *                available event
921
 * \returns 1 on success or 0 if there was an error while waiting for events;
922
 *          call SDL_GetError() for more information. This also returns 0 if
923
 *          the timeout elapsed without an event arriving.
924
 *
925
 * \since This function is available since SDL 2.0.0.
926
 *
927
 * \sa SDL_PollEvent
928
 * \sa SDL_PumpEvents
929
 * \sa SDL_WaitEvent
930
 */
931
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
932
                                                 int timeout);
933
 
934
/**
935
 * Add an event to the event queue.
936
 *
937
 * The event queue can actually be used as a two way communication channel.
938
 * Not only can events be read from the queue, but the user can also push
939
 * their own events onto it. `event` is a pointer to the event structure you
940
 * wish to push onto the queue. The event is copied into the queue, and the
941
 * caller may dispose of the memory pointed to after SDL_PushEvent() returns.
942
 *
943
 * Note: Pushing device input events onto the queue doesn't modify the state
944
 * of the device within SDL.
945
 *
946
 * This function is thread-safe, and can be called from other threads safely.
947
 *
948
 * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
949
 * the event filter but events added with SDL_PeepEvents() do not.
950
 *
951
 * For pushing application-specific events, please use SDL_RegisterEvents() to
952
 * get an event type that does not conflict with other code that also wants
953
 * its own custom event types.
954
 *
955
 * \param event the SDL_Event to be added to the queue
956
 * \returns 1 on success, 0 if the event was filtered, or a negative error
957
 *          code on failure; call SDL_GetError() for more information. A
958
 *          common reason for error is the event queue being full.
959
 *
960
 * \since This function is available since SDL 2.0.0.
961
 *
962
 * \sa SDL_PeepEvents
963
 * \sa SDL_PollEvent
964
 * \sa SDL_RegisterEvents
965
 */
966
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
967
 
968
/**
969
 * A function pointer used for callbacks that watch the event queue.
970
 *
971
 * \param userdata what was passed as `userdata` to SDL_SetEventFilter()
972
 *        or SDL_AddEventWatch, etc
973
 * \param event the event that triggered the callback
974
 * \returns 1 to permit event to be added to the queue, and 0 to disallow
975
 *          it. When used with SDL_AddEventWatch, the return value is ignored.
976
 *
977
 * \sa SDL_SetEventFilter
978
 * \sa SDL_AddEventWatch
979
 */
980
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
981
 
982
/**
983
 * Set up a filter to process all events before they change internal state and
984
 * are posted to the internal event queue.
985
 *
986
 * If the filter function returns 1 when called, then the event will be added
987
 * to the internal queue. If it returns 0, then the event will be dropped from
988
 * the queue, but the internal state will still be updated. This allows
989
 * selective filtering of dynamically arriving events.
990
 *
991
 * **WARNING**: Be very careful of what you do in the event filter function,
992
 * as it may run in a different thread!
993
 *
994
 * On platforms that support it, if the quit event is generated by an
995
 * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
996
 * application at the next event poll.
997
 *
998
 * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
999
 * event filter is only called when the window manager desires to close the
1000
 * application window. If the event filter returns 1, then the window will be
1001
 * closed, otherwise the window will remain open if possible.
1002
 *
1003
 * Note: Disabled events never make it to the event filter function; see
1004
 * SDL_EventState().
1005
 *
1006
 * Note: If you just want to inspect events without filtering, you should use
1007
 * SDL_AddEventWatch() instead.
1008
 *
1009
 * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
1010
 * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
1011
 * not.
1012
 *
1013
 * \param filter An SDL_EventFilter function to call when an event happens
1014
 * \param userdata a pointer that is passed to `filter`
1015
 *
1016
 * \since This function is available since SDL 2.0.0.
1017
 *
1018
 * \sa SDL_AddEventWatch
1019
 * \sa SDL_EventState
1020
 * \sa SDL_GetEventFilter
1021
 * \sa SDL_PeepEvents
1022
 * \sa SDL_PushEvent
1023
 */
1024
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
1025
                                                void *userdata);
1026
 
1027
/**
1028
 * Query the current event filter.
1029
 *
1030
 * This function can be used to "chain" filters, by saving the existing filter
1031
 * before replacing it with a function that will call that saved filter.
1032
 *
1033
 * \param filter the current callback function will be stored here
1034
 * \param userdata the pointer that is passed to the current event filter will
1035
 *                 be stored here
1036
 * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
1037
 *
1038
 * \since This function is available since SDL 2.0.0.
1039
 *
1040
 * \sa SDL_SetEventFilter
1041
 */
1042
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
1043
                                                    void **userdata);
1044
 
1045
/**
1046
 * Add a callback to be triggered when an event is added to the event queue.
1047
 *
1048
 * `filter` will be called when an event happens, and its return value is
1049
 * ignored.
1050
 *
1051
 * **WARNING**: Be very careful of what you do in the event filter function,
1052
 * as it may run in a different thread!
1053
 *
1054
 * If the quit event is generated by a signal (e.g. SIGINT), it will bypass
1055
 * the internal queue and be delivered to the watch callback immediately, and
1056
 * arrive at the next event poll.
1057
 *
1058
 * Note: the callback is called for events posted by the user through
1059
 * SDL_PushEvent(), but not for disabled events, nor for events by a filter
1060
 * callback set with SDL_SetEventFilter(), nor for events posted by the user
1061
 * through SDL_PeepEvents().
1062
 *
1063
 * \param filter an SDL_EventFilter function to call when an event happens.
1064
 * \param userdata a pointer that is passed to `filter`
1065
 *
1066
 * \since This function is available since SDL 2.0.0.
1067
 *
1068
 * \sa SDL_DelEventWatch
1069
 * \sa SDL_SetEventFilter
1070
 */
1071
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
1072
                                               void *userdata);
1073
 
1074
/**
1075
 * Remove an event watch callback added with SDL_AddEventWatch().
1076
 *
1077
 * This function takes the same input as SDL_AddEventWatch() to identify and
1078
 * delete the corresponding callback.
1079
 *
1080
 * \param filter the function originally passed to SDL_AddEventWatch()
1081
 * \param userdata the pointer originally passed to SDL_AddEventWatch()
1082
 *
1083
 * \since This function is available since SDL 2.0.0.
1084
 *
1085
 * \sa SDL_AddEventWatch
1086
 */
1087
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
1088
                                               void *userdata);
1089
 
1090
/**
1091
 * Run a specific filter function on the current event queue, removing any
1092
 * events for which the filter returns 0.
1093
 *
1094
 * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
1095
 * this function does not change the filter permanently, it only uses the
1096
 * supplied filter until this function returns.
1097
 *
1098
 * \param filter the SDL_EventFilter function to call when an event happens
1099
 * \param userdata a pointer that is passed to `filter`
1100
 *
1101
 * \since This function is available since SDL 2.0.0.
1102
 *
1103
 * \sa SDL_GetEventFilter
1104
 * \sa SDL_SetEventFilter
1105
 */
1106
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
1107
                                              void *userdata);
1108
 
1109
/* @{ */
1110
#define SDL_QUERY   -1
1111
#define SDL_IGNORE   0
1112
#define SDL_DISABLE  0
1113
#define SDL_ENABLE   1
1114
 
1115
/**
1116
 * Set the state of processing events by type.
1117
 *
1118
 * `state` may be any of the following:
1119
 *
1120
 * - `SDL_QUERY`: returns the current processing state of the specified event
1121
 * - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped
1122
 *   from the event queue and will not be filtered
1123
 * - `SDL_ENABLE`: the event will be processed normally
1124
 *
1125
 * \param type the type of event; see SDL_EventType for details
1126
 * \param state how to process the event
1127
 * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
1128
 *          of the event before this function makes any changes to it.
1129
 *
1130
 * \since This function is available since SDL 2.0.0.
1131
 *
1132
 * \sa SDL_GetEventState
1133
 */
1134
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
1135
/* @} */
1136
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
1137
 
1138
/**
1139
 * Allocate a set of user-defined events, and return the beginning event
1140
 * number for that set of events.
1141
 *
1142
 * Calling this function with `numevents` <= 0 is an error and will return
1143
 * (Uint32)-1.
1144
 *
1145
 * Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
1146
 * 0xFFFFFFFF), but is clearer to write.
1147
 *
1148
 * \param numevents the number of events to be allocated
1149
 * \returns the beginning event number, or (Uint32)-1 if there are not enough
1150
 *          user-defined events left.
1151
 *
1152
 * \since This function is available since SDL 2.0.0.
1153
 *
1154
 * \sa SDL_PushEvent
1155
 */
1156
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
1157
 
1158
/* Ends C function definitions when using C++ */
1159
#ifdef __cplusplus
1160
}
1161
#endif
1162
#include "close_code.h"
1163
 
1164
#endif /* SDL_events_h_ */
1165
 
1166
/* vi: set ts=4 sw=4 expandtab: */