arsa  2.7
SDL_events.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2019 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 
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 
55 typedef enum
56 {
59  /* Application events */
60  SDL_QUIT = 0x100,
62  /* These application events have special meaning on iOS, see README-ios.md for details */
88  /* Display events */
89  SDL_DISPLAYEVENT = 0x150,
91  /* Window events */
92  SDL_WINDOWEVENT = 0x200,
95  /* Keyboard events */
96  SDL_KEYDOWN = 0x300,
104  /* Mouse events */
105  SDL_MOUSEMOTION = 0x400,
110  /* Joystick events */
119  /* Game controller events */
127  /* Touch events */
128  SDL_FINGERDOWN = 0x700,
131 
132  /* Gesture events */
136 
137  /* Clipboard events */
140  /* Drag and drop events */
141  SDL_DROPFILE = 0x1000,
146  /* Audio hotplug events */
150  /* Sensor events */
151  SDL_SENSORUPDATE = 0x1200,
153  /* Render events */
160  SDL_USEREVENT = 0x8000,
161 
165  SDL_LASTEVENT = 0xFFFF
166 } SDL_EventType;
167 
171 typedef struct SDL_CommonEvent
172 {
176 
180 typedef struct SDL_DisplayEvent
181 {
191 
195 typedef struct SDL_WindowEvent
196 {
207 
211 typedef struct SDL_KeyboardEvent
212 {
222 
223 #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
224 
227 typedef struct SDL_TextEditingEvent
228 {
236 
237 
238 #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
239 
242 typedef struct SDL_TextInputEvent
243 {
249 
253 typedef struct SDL_MouseMotionEvent
254 {
265 
269 typedef struct SDL_MouseButtonEvent
270 {
282 
286 typedef struct SDL_MouseWheelEvent
287 {
296 
300 typedef struct SDL_JoyAxisEvent
301 {
312 
316 typedef struct SDL_JoyBallEvent
317 {
328 
332 typedef struct SDL_JoyHatEvent
333 {
348 
352 typedef struct SDL_JoyButtonEvent
353 {
362 
366 typedef struct SDL_JoyDeviceEvent
367 {
372 
373 
378 {
389 
390 
395 {
404 
405 
410 {
415 
419 typedef struct SDL_AudioDeviceEvent
420 {
429 
430 
434 typedef struct SDL_TouchFingerEvent
435 {
440  float x;
441  float y;
442  float dx;
443  float dy;
444  float pressure;
447 
448 
452 typedef struct SDL_MultiGestureEvent
453 {
457  float dTheta;
458  float dDist;
459  float x;
460  float y;
464 
465 
470 {
476  float error;
477  float x;
478  float y;
480 
481 
487 typedef struct SDL_DropEvent
488 {
491  char *file;
493 } SDL_DropEvent;
494 
495 
499 typedef struct SDL_SensorEvent
500 {
504  float data[6];
506 
510 typedef struct SDL_QuitEvent
511 {
514 } SDL_QuitEvent;
515 
519 typedef struct SDL_OSEvent
520 {
523 } SDL_OSEvent;
524 
528 typedef struct SDL_UserEvent
529 {
534  void *data1;
535  void *data2;
536 } SDL_UserEvent;
537 
538 
539 struct SDL_SysWMmsg;
540 typedef struct SDL_SysWMmsg SDL_SysWMmsg;
541 
548 typedef struct SDL_SysWMEvent
549 {
554 
558 typedef union SDL_Event
559 {
588  /* This is necessary for ABI compatibility between Visual C++ and GCC
589  Visual C++ will respect the push pack pragma and use 52 bytes for
590  this structure, and GCC will use the alignment of the largest datatype
591  within the union, which is 8 bytes.
592 
593  So... we'll add padding to force the size to be 56 bytes for both.
594  */
596 } SDL_Event;
597 
598 /* Make sure we haven't broken binary compatibility */
600 
601 
602 /* Function prototypes */
603 
611 extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
612 
613 /* @{ */
614 typedef enum
615 {
620 
639 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
640  SDL_eventaction action,
641  Uint32 minType, Uint32 maxType);
642 /* @} */
643 
648 extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
649 
657 extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
658 
668 
678 
690  int timeout);
691 
699 
700 typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
701 
728  void *userdata);
729 
735  void **userdata);
736 
741  void *userdata);
742 
747  void *userdata);
748 
754  void *userdata);
755 
756 /* @{ */
757 #define SDL_QUERY -1
758 #define SDL_IGNORE 0
759 #define SDL_DISABLE 0
760 #define SDL_ENABLE 1
761 
771 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
772 /* @} */
773 #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
774 
782 extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
783 
784 /* Ends C function definitions when using C++ */
785 #ifdef __cplusplus
786 }
787 #endif
788 #include "close_code.h"
789 
790 #endif /* SDL_events_h_ */
791 
792 /* vi: set ts=4 sw=4 expandtab: */
void * data1
Definition: SDL_events.h:534
SDL_JoystickID which
Definition: SDL_events.h:381
SDL_eventaction
Definition: SDL_events.h:614
SDL_MouseMotionEvent motion
Definition: SDL_events.h:567
SDL_JoystickID which
Definition: SDL_events.h:356
struct SDL_DollarGestureEvent SDL_DollarGestureEvent
Dollar Gesture Event (event.dgesture.*)
DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType)
struct SDL_TouchFingerEvent SDL_TouchFingerEvent
Touch finger event structure (event.tfinger.*)
Uint8 padding[56]
Definition: SDL_events.h:595
SDL_ControllerAxisEvent caxis
Definition: SDL_events.h:575
DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
SDL_JoyDeviceEvent jdevice
Definition: SDL_events.h:574
Uint32 windowID
Definition: SDL_events.h:492
The "quit requested" event.
Definition: SDL_events.h:510
Controller device event structure (event.cdevice.*)
Definition: SDL_events.h:409
SDL_DollarGestureEvent dgesture
Definition: SDL_events.h:585
Joystick button event structure (event.jbutton.*)
Definition: SDL_events.h:352
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
void * data2
Definition: SDL_events.h:535
SDL_ControllerDeviceEvent cdevice
Definition: SDL_events.h:577
SDL_bool
Definition: SDL_stdinc.h:161
SDL_JoyButtonEvent jbutton
Definition: SDL_events.h:573
DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event)
Waits indefinitely for the next available event.
struct SDL_ControllerDeviceEvent SDL_ControllerDeviceEvent
Controller device event structure (event.cdevice.*)
Sint64 SDL_FingerID
Definition: SDL_touch.h:42
Joystick axis motion event structure (event.jaxis.*)
Definition: SDL_events.h:300
struct SDL_JoyDeviceEvent SDL_JoyDeviceEvent
Joystick device event structure (event.jdevice.*)
struct SDL_DisplayEvent SDL_DisplayEvent
Display state change event data (event.display.*)
SDL_SysWMmsg * msg
Definition: SDL_events.h:552
SDL_DisplayEvent display
Definition: SDL_events.h:562
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:81
struct SDL_UserEvent SDL_UserEvent
A user-defined event type (event.user.*)
struct SDL_ControllerAxisEvent SDL_ControllerAxisEvent
Game controller axis motion event structure (event.caxis.*)
DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event)
Polls for currently pending events.
SDL_JoyBallEvent jball
Definition: SDL_events.h:571
SDL_JoystickID which
Definition: SDL_events.h:304
SDL_TouchID touchId
Definition: SDL_events.h:438
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
Uint32 timestamp
Definition: SDL_events.h:513
struct SDL_MouseWheelEvent SDL_MouseWheelEvent
Mouse wheel event structure (event.wheel.*)
Keyboard text editing event structure (event.edit.*)
Definition: SDL_events.h:227
#define DECLSPEC
Definition: begin_code.h:74
struct SDL_AudioDeviceEvent SDL_AudioDeviceEvent
Audio device event structure (event.adevice.*)
int(SDLCALL * SDL_EventFilter)(void *userdata, SDL_Event *event)
Definition: SDL_events.h:700
The SDL keysym structure, used in key events.
Definition: SDL_keyboard.h:47
DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state)
DECLSPEC void SDLCALL SDL_PumpEvents(void)
uint32_t Uint32
Definition: SDL_stdinc.h:203
Game controller axis motion event structure (event.caxis.*)
Definition: SDL_events.h:377
SDL_QuitEvent quit
Definition: SDL_events.h:580
#define SDLCALL
Definition: begin_code.h:89
SDL_GestureID gestureId
Definition: SDL_events.h:474
Uint32 timestamp
Definition: SDL_events.h:531
struct SDL_MultiGestureEvent SDL_MultiGestureEvent
Multiple Finger Gesture Event (event.mgesture.*)
Dollar Gesture Event (event.dgesture.*)
Definition: SDL_events.h:469
SDL_JoystickID which
Definition: SDL_events.h:398
struct SDL_SensorEvent SDL_SensorEvent
Sensor event structure (event.sensor.*)
OS Specific event.
Definition: SDL_events.h:519
Keyboard text input event structure (event.text.*)
Definition: SDL_events.h:242
SDL_MouseWheelEvent wheel
Definition: SDL_events.h:569
Joystick trackball motion event structure (event.jball.*)
Definition: SDL_events.h:316
union SDL_Event SDL_Event
General event structure.
Uint32 timestamp
Definition: SDL_events.h:502
DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType)
SDL_WindowEvent window
Definition: SDL_events.h:563
Uint32 timestamp
Definition: SDL_events.h:551
A user-defined event type (event.user.*)
Definition: SDL_events.h:528
An event used to request a file open by the system (event.drop.*) This event is enabled by default,...
Definition: SDL_events.h:487
Fields shared by every event.
Definition: SDL_events.h:171
struct SDL_TextInputEvent SDL_TextInputEvent
Keyboard text input event structure (event.text.*)
SDL_SensorEvent sensor
Definition: SDL_events.h:579
struct SDL_WindowEvent SDL_WindowEvent
Window state change event data (event.window.*)
SDL_JoystickID which
Definition: SDL_events.h:320
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:211
SDL_TextInputEvent text
Definition: SDL_events.h:566
uint16_t Uint16
Definition: SDL_stdinc.h:191
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]
Definition: SDL_events.h:247
Uint32 timestamp
Definition: SDL_events.h:490
SDL_JoyAxisEvent jaxis
Definition: SDL_events.h:570
Touch finger event structure (event.tfinger.*)
Definition: SDL_events.h:434
SDL_MultiGestureEvent mgesture
Definition: SDL_events.h:584
Sint64 SDL_GestureID
Definition: SDL_gesture.h:44
struct _cl_event * event
struct SDL_ControllerButtonEvent SDL_ControllerButtonEvent
Game controller button event structure (event.cbutton.*)
struct SDL_SysWMEvent SDL_SysWMEvent
A video driver dependent system event (event.syswm.*) This event is disabled by default,...
struct SDL_JoyHatEvent SDL_JoyHatEvent
Joystick hat position change event structure (event.jhat.*)
struct SDL_TextEditingEvent SDL_TextEditingEvent
Keyboard text editing event structure (event.edit.*)
SDL_EventType
The types of events that can be delivered.
Definition: SDL_events.h:55
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]
Definition: SDL_events.h:232
struct SDL_KeyboardEvent SDL_KeyboardEvent
Keyboard button event structure (event.key.*)
Uint32 windowID
Definition: SDL_events.h:532
struct SDL_OSEvent SDL_OSEvent
OS Specific event.
Uint32 timestamp
Definition: SDL_events.h:335
Audio device event structure (event.adevice.*)
Definition: SDL_events.h:419
SDL_Keysym keysym
Definition: SDL_events.h:220
int32_t Sint32
Definition: SDL_stdinc.h:197
struct SDL_JoyBallEvent SDL_JoyBallEvent
Joystick trackball motion event structure (event.jball.*)
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:286
DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event *event, int timeout)
Waits until the specified timeout (in milliseconds) for the next available event.
DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
Window state change event data (event.window.*)
Definition: SDL_events.h:195
DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata)
Uint32 timestamp
Definition: SDL_events.h:198
Uint32 timestamp
Definition: SDL_events.h:522
DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type)
SDL_TextEditingEvent edit
Definition: SDL_events.h:565
DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
SDL_AudioDeviceEvent adevice
Definition: SDL_events.h:578
SDL_SysWMEvent syswm
Definition: SDL_events.h:582
DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, void *userdata)
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:253
DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType)
Game controller button event structure (event.cbutton.*)
Definition: SDL_events.h:394
SDL_KeyboardEvent key
Definition: SDL_events.h:564
Joystick hat position change event structure (event.jhat.*)
Definition: SDL_events.h:332
SDL_ControllerButtonEvent cbutton
Definition: SDL_events.h:576
Mouse button event structure (event.button.*)
Definition: SDL_events.h:269
GLbitfield GLuint64 timeout
A video driver dependent system event (event.syswm.*) This event is disabled by default,...
Definition: SDL_events.h:548
Uint32 timestamp
Definition: SDL_events.h:174
SDL_FingerID fingerId
Definition: SDL_events.h:439
SDL_MouseButtonEvent button
Definition: SDL_events.h:568
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event)==56)
DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents)
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type)
struct SDL_CommonEvent SDL_CommonEvent
Fields shared by every event.
General event structure.
Definition: SDL_events.h:558
SDL_UserEvent user
Definition: SDL_events.h:581
Display state change event data (event.display.*)
Definition: SDL_events.h:180
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
Definition: SDL_events.h:238
Uint32 type
Definition: SDL_events.h:521
struct SDL_JoyAxisEvent SDL_JoyAxisEvent
Joystick axis motion event structure (event.jaxis.*)
struct SDL_MouseMotionEvent SDL_MouseMotionEvent
Mouse motion event structure (event.motion.*)
SDL_JoyHatEvent jhat
Definition: SDL_events.h:572
SDL_CommonEvent common
Definition: SDL_events.h:561
DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
uint8_t Uint8
Definition: SDL_stdinc.h:179
Joystick device event structure (event.jdevice.*)
Definition: SDL_events.h:366
struct SDL_DropEvent SDL_DropEvent
An event used to request a file open by the system (event.drop.*) This event is enabled by default,...
SDL_JoystickID which
Definition: SDL_events.h:336
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
int16_t Sint16
Definition: SDL_stdinc.h:185
SDL_TouchID touchId
Definition: SDL_events.h:456
SDL_DropEvent drop
Definition: SDL_events.h:586
Uint32 type
Definition: SDL_events.h:560
struct SDL_MouseButtonEvent SDL_MouseButtonEvent
Mouse button event structure (event.button.*)
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE
Definition: SDL_events.h:223
struct SDL_JoyButtonEvent SDL_JoyButtonEvent
Joystick button event structure (event.jbutton.*)
struct SDL_QuitEvent SDL_QuitEvent
The "quit requested" event.
Multiple Finger Gesture Event (event.mgesture.*)
Definition: SDL_events.h:452
SDL_TouchFingerEvent tfinger
Definition: SDL_events.h:583
Sensor event structure (event.sensor.*)
Definition: SDL_events.h:499