include/SDL_events.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 20 Nov 2011 19:38:18 -0500
changeset 6091 61fa4f3238c5
parent 6053 4d7b69e575f9
child 6114 d166819bf2b3
permissions -rw-r--r--
First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@5535
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_events.h
slouken@3407
    24
 *  
slouken@3407
    25
 *  Include file for SDL event handling.
slouken@1895
    26
 */
slouken@0
    27
slouken@0
    28
#ifndef _SDL_events_h
slouken@0
    29
#define _SDL_events_h
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1358
    32
#include "SDL_error.h"
slouken@1895
    33
#include "SDL_video.h"
slouken@0
    34
#include "SDL_keyboard.h"
slouken@0
    35
#include "SDL_mouse.h"
slouken@0
    36
#include "SDL_joystick.h"
slouken@0
    37
#include "SDL_quit.h"
jim@4659
    38
#include "SDL_gesture.h"
jim@4659
    39
#include "SDL_touch.h"
slouken@0
    40
slouken@0
    41
#include "begin_code.h"
slouken@0
    42
/* Set up for C function definitions, even when using C++ */
slouken@0
    43
#ifdef __cplusplus
slouken@1895
    44
/* *INDENT-OFF* */
slouken@0
    45
extern "C" {
slouken@1895
    46
/* *INDENT-ON* */
slouken@0
    47
#endif
slouken@0
    48
slouken@1330
    49
/* General keyboard/mouse state definitions */
slouken@1330
    50
#define SDL_RELEASED	0
slouken@1330
    51
#define SDL_PRESSED	1
slouken@1330
    52
slouken@1895
    53
/**
slouken@3407
    54
 * \brief The types of events that can be delivered.
slouken@1895
    55
 */
slouken@1895
    56
typedef enum
slouken@1895
    57
{
slouken@4429
    58
    SDL_FIRSTEVENT     = 0,     /**< Unused (do not remove) */
slouken@4429
    59
slouken@4429
    60
    /* Application events */
slouken@4429
    61
    SDL_QUIT           = 0x100, /**< User-requested quit */
slouken@4429
    62
slouken@4429
    63
    /* Window events */
slouken@4429
    64
    SDL_WINDOWEVENT    = 0x200, /**< Window state change */
slouken@4429
    65
    SDL_SYSWMEVENT,             /**< System specific event */
slouken@4429
    66
slouken@4429
    67
    /* Keyboard events */
slouken@4971
    68
    SDL_KEYDOWN        = 0x300, /**< Key pressed */
slouken@4971
    69
    SDL_KEYUP,                  /**< Key released */
slouken@3280
    70
    SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
slouken@1957
    71
    SDL_TEXTINPUT,              /**< Keyboard text input */
slouken@4429
    72
slouken@4429
    73
    /* Mouse events */
slouken@4429
    74
    SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
slouken@1895
    75
    SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
slouken@1895
    76
    SDL_MOUSEBUTTONUP,          /**< Mouse button released */
slouken@1957
    77
    SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
slouken@4429
    78
slouken@4465
    79
    /* Tablet or multiple mice input device events */
slouken@4465
    80
    SDL_INPUTMOTION    = 0x500, /**< Input moved */
slouken@4465
    81
    SDL_INPUTBUTTONDOWN,        /**< Input button pressed */
slouken@4465
    82
    SDL_INPUTBUTTONUP,          /**< Input button released */
slouken@4465
    83
    SDL_INPUTWHEEL,             /**< Input wheel motion */
slouken@4465
    84
    SDL_INPUTPROXIMITYIN,       /**< Input pen entered proximity */
slouken@4465
    85
    SDL_INPUTPROXIMITYOUT,      /**< Input pen left proximity */
slouken@4429
    86
slouken@4429
    87
    /* Joystick events */
slouken@4429
    88
    SDL_JOYAXISMOTION  = 0x600, /**< Joystick axis motion */
slouken@1895
    89
    SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
slouken@1895
    90
    SDL_JOYHATMOTION,           /**< Joystick hat position change */
slouken@1895
    91
    SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
slouken@1895
    92
    SDL_JOYBUTTONUP,            /**< Joystick button released */
slouken@4429
    93
slouken@4661
    94
    /* Touch events */
slouken@4661
    95
    SDL_FINGERDOWN      = 0x700,
jim@4641
    96
    SDL_FINGERUP,
jim@4641
    97
    SDL_FINGERMOTION,
jim@4641
    98
    SDL_TOUCHBUTTONDOWN,
jim@4641
    99
    SDL_TOUCHBUTTONUP,    
jim@4641
   100
slouken@4661
   101
    /* Gesture events */
slouken@4661
   102
    SDL_DOLLARGESTURE   = 0x800,
jim@4659
   103
    SDL_DOLLARRECORD,
jim@4657
   104
    SDL_MULTIGESTURE,
jim@4657
   105
slouken@4503
   106
    /* Clipboard events */
slouken@6091
   107
    SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
jim@4662
   108
slouken@6091
   109
    /* Drag and drop events */
slouken@6091
   110
    SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
slouken@4503
   111
slouken@4429
   112
    /* Obsolete events */
slouken@4429
   113
    SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
slouken@4429
   114
    SDL_EVENT_COMPAT2,
slouken@4429
   115
    SDL_EVENT_COMPAT3,
slouken@4429
   116
jim@4641
   117
slouken@4429
   118
    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
slouken@4429
   119
     *  and should be allocated with SDL_RegisterEvents()
slouken@4429
   120
     */
slouken@4429
   121
    SDL_USEREVENT    = 0x8000,
slouken@4429
   122
slouken@3407
   123
    /**
slouken@3407
   124
     *  This last event is only for bounding internal arrays
slouken@1895
   125
     */
slouken@4429
   126
    SDL_LASTEVENT    = 0xFFFF
slouken@1294
   127
} SDL_EventType;
slouken@0
   128
slouken@1895
   129
/**
slouken@3407
   130
 *  \brief Window state change event data (event.window.*)
slouken@1895
   131
 */
slouken@1895
   132
typedef struct SDL_WindowEvent
slouken@1895
   133
{
slouken@4429
   134
    Uint32 type;        /**< ::SDL_WINDOWEVENT */
slouken@4429
   135
    Uint32 windowID;    /**< The associated window */
slouken@4429
   136
    Uint8 event;        /**< ::SDL_WindowEventID */
slouken@4429
   137
    Uint8 padding1;
slouken@4429
   138
    Uint8 padding2;
slouken@4429
   139
    Uint8 padding3;
slouken@4429
   140
    int data1;          /**< event dependent data */
slouken@4429
   141
    int data2;          /**< event dependent data */
slouken@1895
   142
} SDL_WindowEvent;
slouken@0
   143
slouken@1895
   144
/**
slouken@3407
   145
 *  \brief Keyboard button event structure (event.key.*)
slouken@1895
   146
 */
slouken@1895
   147
typedef struct SDL_KeyboardEvent
slouken@1895
   148
{
slouken@4429
   149
    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
slouken@4429
   150
    Uint32 windowID;    /**< The window with keyboard focus, if any */
slouken@4429
   151
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4560
   152
    Uint8 repeat;       /**< Non-zero if this is a key repeat */
slouken@4429
   153
    Uint8 padding2;
slouken@4465
   154
    Uint8 padding3;
slouken@5218
   155
    SDL_Keysym keysym;  /**< The key that was pressed or released */
slouken@0
   156
} SDL_KeyboardEvent;
slouken@0
   157
slouken@3407
   158
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
slouken@1895
   159
/**
slouken@3407
   160
 *  \brief Keyboard text editing event structure (event.edit.*)
slouken@3280
   161
 */
slouken@3280
   162
typedef struct SDL_TextEditingEvent
slouken@3280
   163
{
slouken@4429
   164
    Uint32 type;                                /**< ::SDL_TEXTEDITING */
slouken@4434
   165
    Uint32 windowID;                            /**< The window with keyboard focus, if any */
slouken@3280
   166
    char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
slouken@3280
   167
    int start;                                  /**< The start cursor of selected editing text */
slouken@3280
   168
    int length;                                 /**< The length of selected editing text */
slouken@3280
   169
} SDL_TextEditingEvent;
slouken@3280
   170
slouken@3407
   171
slouken@3407
   172
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
slouken@3280
   173
/**
slouken@3407
   174
 *  \brief Keyboard text input event structure (event.text.*)
slouken@1895
   175
 */
slouken@1895
   176
typedef struct SDL_TextInputEvent
slouken@1895
   177
{
slouken@4429
   178
    Uint32 type;                              /**< ::SDL_TEXTINPUT */
slouken@3685
   179
    Uint32 windowID;                          /**< The window with keyboard focus, if any */
bob@2300
   180
    char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
slouken@1895
   181
} SDL_TextInputEvent;
slouken@1895
   182
slouken@1895
   183
/**
slouken@3407
   184
 *  \brief Mouse motion event structure (event.motion.*)
slouken@1895
   185
 */
slouken@1895
   186
typedef struct SDL_MouseMotionEvent
slouken@1895
   187
{
slouken@4429
   188
    Uint32 type;        /**< ::SDL_MOUSEMOTION */
slouken@4429
   189
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   190
    Uint8 state;        /**< The current button state */
slouken@4429
   191
    Uint8 padding1;
slouken@4429
   192
    Uint8 padding2;
slouken@4465
   193
    Uint8 padding3;
slouken@4429
   194
    int x;              /**< X coordinate, relative to window */
slouken@4429
   195
    int y;              /**< Y coordinate, relative to window */
slouken@4429
   196
    int xrel;           /**< The relative motion in the X direction */
slouken@4429
   197
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   198
} SDL_MouseMotionEvent;
slouken@0
   199
slouken@1895
   200
/**
slouken@3407
   201
 *  \brief Mouse button event structure (event.button.*)
slouken@1895
   202
 */
slouken@1895
   203
typedef struct SDL_MouseButtonEvent
slouken@1895
   204
{
slouken@4429
   205
    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
slouken@4429
   206
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   207
    Uint8 button;       /**< The mouse button index */
slouken@4429
   208
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   209
    Uint8 padding1;
slouken@4465
   210
    Uint8 padding2;
slouken@4429
   211
    int x;              /**< X coordinate, relative to window */
slouken@4429
   212
    int y;              /**< Y coordinate, relative to window */
slouken@0
   213
} SDL_MouseButtonEvent;
slouken@0
   214
slouken@1895
   215
/**
slouken@3407
   216
 *  \brief Mouse wheel event structure (event.wheel.*)
slouken@1895
   217
 */
slouken@1895
   218
typedef struct SDL_MouseWheelEvent
slouken@1895
   219
{
slouken@4429
   220
    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
slouken@4429
   221
    Uint32 windowID;    /**< The window with mouse focus, if any */
slouken@4429
   222
    int x;              /**< The amount scrolled horizontally */
slouken@4429
   223
    int y;              /**< The amount scrolled vertically */
slouken@1895
   224
} SDL_MouseWheelEvent;
slouken@1895
   225
slouken@1895
   226
/**
slouken@3407
   227
 *  \brief Joystick axis motion event structure (event.jaxis.*)
slouken@1895
   228
 */
slouken@1895
   229
typedef struct SDL_JoyAxisEvent
slouken@1895
   230
{
slouken@4429
   231
    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
slouken@1895
   232
    Uint8 which;        /**< The joystick device index */
slouken@1895
   233
    Uint8 axis;         /**< The joystick axis index */
slouken@4429
   234
    Uint8 padding1;
slouken@4429
   235
    Uint8 padding2;
slouken@1895
   236
    int value;          /**< The axis value (range: -32768 to 32767) */
slouken@0
   237
} SDL_JoyAxisEvent;
slouken@0
   238
slouken@1895
   239
/**
slouken@3407
   240
 *  \brief Joystick trackball motion event structure (event.jball.*)
slouken@1895
   241
 */
slouken@1895
   242
typedef struct SDL_JoyBallEvent
slouken@1895
   243
{
slouken@4429
   244
    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
slouken@1895
   245
    Uint8 which;        /**< The joystick device index */
slouken@1895
   246
    Uint8 ball;         /**< The joystick trackball index */
slouken@4429
   247
    Uint8 padding1;
slouken@4429
   248
    Uint8 padding2;
slouken@1895
   249
    int xrel;           /**< The relative motion in the X direction */
slouken@1895
   250
    int yrel;           /**< The relative motion in the Y direction */
slouken@0
   251
} SDL_JoyBallEvent;
slouken@0
   252
slouken@1895
   253
/**
slouken@3407
   254
 *  \brief Joystick hat position change event structure (event.jhat.*)
slouken@1895
   255
 */
slouken@1895
   256
typedef struct SDL_JoyHatEvent
slouken@1895
   257
{
slouken@4429
   258
    Uint32 type;        /**< ::SDL_JOYHATMOTION */
slouken@1895
   259
    Uint8 which;        /**< The joystick device index */
slouken@1895
   260
    Uint8 hat;          /**< The joystick hat index */
slouken@3407
   261
    Uint8 value;        /**< The hat position value.
slouken@3407
   262
                         *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
slouken@3407
   263
                         *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
slouken@3407
   264
                         *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
slouken@3407
   265
                         *   
slouken@3407
   266
                         *   Note that zero means the POV is centered.
slouken@1895
   267
                         */
slouken@4429
   268
    Uint8 padding1;
slouken@0
   269
} SDL_JoyHatEvent;
slouken@0
   270
slouken@1895
   271
/**
slouken@3407
   272
 *  \brief Joystick button event structure (event.jbutton.*)
slouken@1895
   273
 */
slouken@1895
   274
typedef struct SDL_JoyButtonEvent
slouken@1895
   275
{
slouken@4429
   276
    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
slouken@1895
   277
    Uint8 which;        /**< The joystick device index */
slouken@1895
   278
    Uint8 button;       /**< The joystick button index */
slouken@3407
   279
    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
slouken@4429
   280
    Uint8 padding1;
slouken@0
   281
} SDL_JoyButtonEvent;
slouken@0
   282
jim@4641
   283
jim@4641
   284
/**
slouken@6053
   285
 *  \brief Touch finger motion/finger event structure (event.tfinger.*)
jim@4641
   286
 */
jim@4641
   287
typedef struct SDL_TouchFingerEvent
jim@4641
   288
{
jim@4641
   289
    Uint32 type;        /**< ::SDL_FINGERMOTION OR 
jim@4641
   290
			   SDL_FINGERDOWN OR SDL_FINGERUP*/
jim@4641
   291
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   292
    SDL_TouchID touchId;        /**< The touch device id */
jimtla@4678
   293
    SDL_FingerID fingerId;
jim@4641
   294
    Uint8 state;        /**< The current button state */
jim@4641
   295
    Uint8 padding1;
jimtla@4676
   296
    Uint8 padding2;
jimtla@4676
   297
    Uint8 padding3;
jimtla@4678
   298
    Uint16 x;
jimtla@4678
   299
    Uint16 y;
jim@4683
   300
    Sint16 dx;
jim@4683
   301
    Sint16 dy;
jimtla@4678
   302
    Uint16 pressure;
jim@4641
   303
} SDL_TouchFingerEvent;
jim@4641
   304
jim@4641
   305
jim@4641
   306
/**
slouken@6053
   307
 *  \brief Touch finger motion/finger event structure (event.tbutton.*)
jim@4641
   308
 */
jim@4641
   309
typedef struct SDL_TouchButtonEvent
jim@4641
   310
{
jim@4641
   311
    Uint32 type;        /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
jim@4641
   312
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   313
    SDL_TouchID touchId;        /**< The touch device index */
jim@4641
   314
    Uint8 state;        /**< The current button state */
jim@4641
   315
    Uint8 button;        /**< The button changing state */
jim@4641
   316
    Uint8 padding1;
jimtla@4676
   317
    Uint8 padding2;
jim@4641
   318
} SDL_TouchButtonEvent;
jim@4641
   319
jim@4641
   320
jim@4657
   321
/**
slouken@5009
   322
 *  \brief Multiple Finger Gesture Event (event.mgesture.*)
jim@4657
   323
 */
jim@4657
   324
typedef struct SDL_MultiGestureEvent
jim@4657
   325
{
jim@4657
   326
    Uint32 type;        /**< ::SDL_MULTIGESTURE */
jim@4657
   327
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   328
    SDL_TouchID touchId;        /**< The touch device index */
jim@4657
   329
    float dTheta;
jim@4657
   330
    float dDist;
jim@4657
   331
    float x;  //currently 0...1. Change to screen coords?
jim@4657
   332
    float y;  
jim@4683
   333
    Uint16 numFingers;
jim@4683
   334
    Uint16 padding;
jim@4657
   335
} SDL_MultiGestureEvent;
jim@4657
   336
slouken@5014
   337
/* (event.dgesture.*) */
slouken@5014
   338
typedef struct SDL_DollarGestureEvent
jim@4658
   339
{
jim@4658
   340
    Uint32 type;        /**< ::SDL_DOLLARGESTURE */
jim@4658
   341
    Uint32 windowID;    /**< The window with mouse focus, if any */
jimtla@4678
   342
    SDL_TouchID touchId;        /**< The touch device index */
jimtla@4678
   343
    SDL_GestureID gestureId;
jim@4689
   344
    Uint32 numFingers;
jim@4658
   345
    float error;
jim@4658
   346
  /*
jim@4658
   347
    //TODO: Enable to give location?
jim@4658
   348
    float x;  //currently 0...1. Change to screen coords?
jim@4658
   349
    float y;  
jim@4658
   350
  */
jim@4658
   351
} SDL_DollarGestureEvent;
jim@4658
   352
jim@4657
   353
slouken@1895
   354
/**
slouken@6091
   355
 *  \brief An event used to request a file open by the system (event.drop.*)
slouken@6091
   356
 *         This event is disabled by default, you can enable it with SDL_EventState()
slouken@6091
   357
 *  \note If you enable this event, you must free the filename in the event.
slouken@6091
   358
 */
slouken@6091
   359
typedef struct SDL_DropEvent
slouken@6091
   360
{
slouken@6091
   361
    Uint32 type;        /**< ::SDL_DROPFILE */
slouken@6091
   362
    char *file;         /**< The file name, which should be freed with SDL_free() */
slouken@6091
   363
} SDL_DropEvent;
slouken@6091
   364
slouken@6091
   365
slouken@6091
   366
/**
slouken@3407
   367
 *  \brief The "quit requested" event
slouken@0
   368
 */
slouken@1895
   369
typedef struct SDL_QuitEvent
slouken@1895
   370
{
slouken@4429
   371
    Uint32 type;        /**< ::SDL_QUIT */
slouken@1895
   372
} SDL_QuitEvent;
slouken@1895
   373
slouken@5009
   374
slouken@1895
   375
/**
slouken@3407
   376
 *  \brief A user-defined event type (event.user.*)
slouken@1895
   377
 */
slouken@1895
   378
typedef struct SDL_UserEvent
slouken@1895
   379
{
slouken@4429
   380
    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
slouken@4429
   381
    Uint32 windowID;    /**< The associated window if any */
slouken@4429
   382
    int code;           /**< User defined event code */
slouken@4429
   383
    void *data1;        /**< User defined data pointer */
slouken@4429
   384
    void *data2;        /**< User defined data pointer */
slouken@1895
   385
} SDL_UserEvent;
slouken@1895
   386
slouken@5009
   387
slouken@1895
   388
struct SDL_SysWMmsg;
slouken@1895
   389
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
slouken@3407
   390
slouken@3407
   391
/**
slouken@3407
   392
 *  \brief A video driver dependent system event (event.syswm.*)
slouken@6091
   393
 *         This event is disabled by default, you can enable it with SDL_EventState()
slouken@6091
   394
 *
slouken@3407
   395
 *  \note If you want to use this event, you should include SDL_syswm.h.
slouken@3407
   396
 */
slouken@1895
   397
typedef struct SDL_SysWMEvent
slouken@1895
   398
{
slouken@4429
   399
    Uint32 type;        /**< ::SDL_SYSWMEVENT */
slouken@1895
   400
    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
slouken@1895
   401
} SDL_SysWMEvent;
slouken@1895
   402
bob@3167
   403
#ifndef SDL_NO_COMPAT
slouken@3407
   404
/**
slouken@3407
   405
 *  \addtogroup Compatibility 
slouken@3407
   406
 */
slouken@3407
   407
/*@{*/
slouken@3407
   408
slouken@3407
   409
/**
slouken@3407
   410
 *  \name Typedefs for backwards compatibility
slouken@3407
   411
 */
slouken@3407
   412
/*@{*/
bob@3167
   413
typedef struct SDL_ActiveEvent
bob@3167
   414
{
slouken@4429
   415
    Uint32 type;
bob@3167
   416
    Uint8 gain;
bob@3167
   417
    Uint8 state;
bob@3167
   418
} SDL_ActiveEvent;
bob@3167
   419
bob@3167
   420
typedef struct SDL_ResizeEvent
bob@3167
   421
{
slouken@4429
   422
    Uint32 type;
bob@3167
   423
    int w;
bob@3167
   424
    int h;
bob@3167
   425
} SDL_ResizeEvent;
slouken@3407
   426
/*@}*/
slouken@3407
   427
slouken@3407
   428
/*@}*//*Compatibility*/
bob@3167
   429
#endif
bob@3167
   430
slouken@1895
   431
/**
slouken@3407
   432
 *  \brief General event structure
slouken@1895
   433
 */
slouken@1895
   434
typedef union SDL_Event
slouken@1895
   435
{
slouken@4429
   436
    Uint32 type;                    /**< Event type, shared with all events */
slouken@1895
   437
    SDL_WindowEvent window;         /**< Window event data */
slouken@1895
   438
    SDL_KeyboardEvent key;          /**< Keyboard event data */
slouken@3280
   439
    SDL_TextEditingEvent edit;      /**< Text editing event data */
bob@2300
   440
    SDL_TextInputEvent text;        /**< Text input event data */
slouken@1895
   441
    SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
slouken@1895
   442
    SDL_MouseButtonEvent button;    /**< Mouse button event data */
bob@2300
   443
    SDL_MouseWheelEvent wheel;      /**< Mouse wheel event data */
slouken@1895
   444
    SDL_JoyAxisEvent jaxis;         /**< Joystick axis event data */
slouken@1895
   445
    SDL_JoyBallEvent jball;         /**< Joystick ball event data */
slouken@1895
   446
    SDL_JoyHatEvent jhat;           /**< Joystick hat event data */
slouken@1895
   447
    SDL_JoyButtonEvent jbutton;     /**< Joystick button event data */
slouken@1895
   448
    SDL_QuitEvent quit;             /**< Quit request event data */
slouken@1895
   449
    SDL_UserEvent user;             /**< Custom event data */
slouken@1895
   450
    SDL_SysWMEvent syswm;           /**< System dependent window event data */
jim@4641
   451
    SDL_TouchFingerEvent tfinger;   /**< Touch finger event data */
jim@4641
   452
    SDL_TouchButtonEvent tbutton;   /**< Touch button event data */
slouken@4972
   453
    SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
slouken@4972
   454
    SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
slouken@6091
   455
    SDL_DropEvent drop;             /**< Drag and drop event data */
slouken@0
   456
slouken@3407
   457
    /** Temporarily here for backwards compatibility */
slouken@3407
   458
    /*@{*/
bob@3167
   459
#ifndef SDL_NO_COMPAT
slouken@1895
   460
    SDL_ActiveEvent active;
slouken@1895
   461
    SDL_ResizeEvent resize;
bob@3167
   462
#endif
slouken@3407
   463
    /*@}*/
slouken@0
   464
} SDL_Event;
slouken@0
   465
slouken@0
   466
slouken@0
   467
/* Function prototypes */
slouken@0
   468
slouken@3407
   469
/**
slouken@3407
   470
 *  Pumps the event loop, gathering events from the input devices.
slouken@3407
   471
 *  
slouken@3407
   472
 *  This function updates the event queue and internal input device state.
slouken@3407
   473
 *  
slouken@3407
   474
 *  This should only be run in the thread that sets the video mode.
slouken@3407
   475
 */
slouken@337
   476
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
slouken@0
   477
slouken@3407
   478
/*@{*/
slouken@1895
   479
typedef enum
slouken@1895
   480
{
slouken@1895
   481
    SDL_ADDEVENT,
slouken@1895
   482
    SDL_PEEKEVENT,
slouken@1895
   483
    SDL_GETEVENT
slouken@0
   484
} SDL_eventaction;
slouken@3407
   485
slouken@3407
   486
/**
slouken@3407
   487
 *  Checks the event queue for messages and optionally returns them.
slouken@3407
   488
 *  
slouken@3407
   489
 *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
slouken@3407
   490
 *  the back of the event queue.
slouken@3407
   491
 *  
slouken@3407
   492
 *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
slouken@4635
   493
 *  of the event queue, within the specified minimum and maximum type,
slouken@4635
   494
 *  will be returned and will not be removed from the queue.
slouken@3407
   495
 *  
slouken@3407
   496
 *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front 
slouken@4635
   497
 *  of the event queue, within the specified minimum and maximum type,
slouken@4635
   498
 *  will be returned and will be removed from the queue.
slouken@3407
   499
 *  
slouken@3407
   500
 *  \return The number of events actually stored, or -1 if there was an error.
slouken@3407
   501
 *  
slouken@3407
   502
 *  This function is thread-safe.
slouken@3407
   503
 */
slouken@1895
   504
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
slouken@1895
   505
                                           SDL_eventaction action,
slouken@4429
   506
                                           Uint32 minType, Uint32 maxType);
slouken@3407
   507
/*@}*/
slouken@1895
   508
slouken@3407
   509
/**
slouken@3407
   510
 *  Checks to see if certain event types are in the event queue.
slouken@1895
   511
 */
slouken@4429
   512
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
slouken@4429
   513
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
slouken@4429
   514
slouken@4429
   515
/**
slouken@4429
   516
 *  This function clears events from the event queue
slouken@4429
   517
 */
slouken@4429
   518
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
slouken@4429
   519
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
slouken@0
   520
slouken@3407
   521
/**
slouken@3407
   522
 *  \brief Polls for currently pending events.
slouken@3407
   523
 *  
slouken@3407
   524
 *  \return 1 if there are any pending events, or 0 if there are none available.
slouken@3407
   525
 *  
slouken@3407
   526
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   527
 *               stored in that area.
slouken@0
   528
 */
slouken@1895
   529
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
slouken@0
   530
slouken@3407
   531
/**
slouken@3407
   532
 *  \brief Waits indefinitely for the next available event.
slouken@3407
   533
 *  
slouken@3407
   534
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   535
 *   
slouken@3407
   536
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   537
 *               stored in that area.
slouken@0
   538
 */
slouken@1895
   539
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
slouken@0
   540
slouken@3407
   541
/**
slouken@3407
   542
 *  \brief Waits until the specified timeout (in milliseconds) for the next 
slouken@3407
   543
 *         available event.
slouken@3407
   544
 *  
slouken@3407
   545
 *  \return 1, or 0 if there was an error while waiting for events.
slouken@3407
   546
 *  
slouken@3407
   547
 *  \param event If not NULL, the next event is removed from the queue and 
slouken@3407
   548
 *               stored in that area.
slouken@3072
   549
 */
slouken@3072
   550
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
slouken@3072
   551
                                                 int timeout);
slouken@3072
   552
slouken@3407
   553
/**
slouken@3407
   554
 *  \brief Add an event to the event queue.
slouken@3407
   555
 *  
slouken@3407
   556
 *  \return 1 on success, 0 if the event was filtered, or -1 if the event queue 
slouken@3407
   557
 *          was full or there was some other error.
slouken@0
   558
 */
slouken@1895
   559
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
slouken@0
   560
slouken@3407
   561
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
slouken@0
   562
slouken@3407
   563
/**
slouken@3407
   564
 *  Sets up a filter to process all events before they change internal state and
slouken@3407
   565
 *  are posted to the internal event queue.
slouken@3407
   566
 *  
slouken@3407
   567
 *  The filter is protypted as:
slouken@3407
   568
 *  \code
slouken@3407
   569
 *      int SDL_EventFilter(void *userdata, SDL_Event * event);
slouken@3407
   570
 *  \endcode
slouken@3407
   571
 *
slouken@3407
   572
 *  If the filter returns 1, then the event will be added to the internal queue.
slouken@3407
   573
 *  If it returns 0, then the event will be dropped from the queue, but the 
slouken@3407
   574
 *  internal state will still be updated.  This allows selective filtering of
slouken@3407
   575
 *  dynamically arriving events.
slouken@3407
   576
 *  
slouken@3407
   577
 *  \warning  Be very careful of what you do in the event filter function, as 
slouken@3407
   578
 *            it may run in a different thread!
slouken@3407
   579
 *  
slouken@3407
   580
 *  There is one caveat when dealing with the ::SDL_QUITEVENT event type.  The
slouken@3407
   581
 *  event filter is only called when the window manager desires to close the
slouken@3407
   582
 *  application window.  If the event filter returns 1, then the window will
slouken@3407
   583
 *  be closed, otherwise the window will remain open if possible.
slouken@3407
   584
 *
slouken@3407
   585
 *  If the quit event is generated by an interrupt signal, it will bypass the
slouken@3407
   586
 *  internal queue and be delivered to the application at the next event poll.
slouken@3407
   587
 */
slouken@1895
   588
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
slouken@1895
   589
                                                void *userdata);
slouken@0
   590
slouken@3407
   591
/**
slouken@3407
   592
 *  Return the current event filter - can be used to "chain" filters.
slouken@3407
   593
 *  If there is no event filter set, this function returns SDL_FALSE.
slouken@3407
   594
 */
slouken@1895
   595
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
slouken@1895
   596
                                                    void **userdata);
slouken@1895
   597
slouken@3407
   598
/**
slouken@5146
   599
 *  Add a function which is called when an event is added to the queue.
slouken@5146
   600
 */
slouken@5146
   601
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
slouken@5146
   602
                                               void *userdata);
slouken@5146
   603
slouken@5146
   604
/**
slouken@5146
   605
 *  Remove an event watch function added with SDL_AddEventWatch()
slouken@5146
   606
 */
slouken@5146
   607
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
slouken@5146
   608
                                               void *userdata);
slouken@5146
   609
slouken@5146
   610
/**
slouken@3407
   611
 *  Run the filter function on the current event queue, removing any
slouken@3407
   612
 *  events for which the filter returns 0.
slouken@3407
   613
 */
slouken@1895
   614
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
slouken@1895
   615
                                              void *userdata);
slouken@0
   616
slouken@3407
   617
/*@{*/
slouken@0
   618
#define SDL_QUERY	-1
slouken@0
   619
#define SDL_IGNORE	 0
slouken@0
   620
#define SDL_DISABLE	 0
slouken@0
   621
#define SDL_ENABLE	 1
slouken@3407
   622
slouken@3407
   623
/**
slouken@3407
   624
 *  This function allows you to set the state of processing certain events.
slouken@3407
   625
 *   - If \c state is set to ::SDL_IGNORE, that event will be automatically 
slouken@3407
   626
 *     dropped from the event queue and will not event be filtered.
slouken@3407
   627
 *   - If \c state is set to ::SDL_ENABLE, that event will be processed 
slouken@3407
   628
 *     normally.
slouken@3407
   629
 *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 
slouken@3407
   630
 *     current processing state of the specified event.
slouken@3407
   631
 */
slouken@4429
   632
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
slouken@3407
   633
/*@}*/
slouken@4429
   634
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
slouken@4429
   635
slouken@4429
   636
/**
slouken@4429
   637
 *  This function allocates a set of user-defined events, and returns
slouken@4429
   638
 *  the beginning event number for that set of events.
slouken@4429
   639
 *
slouken@4429
   640
 *  If there aren't enough user-defined events left, this function
slouken@4429
   641
 *  returns (Uint32)-1
slouken@4429
   642
 */
slouken@4429
   643
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
slouken@0
   644
slouken@0
   645
/* Ends C function definitions when using C++ */
slouken@0
   646
#ifdef __cplusplus
slouken@1895
   647
/* *INDENT-OFF* */
slouken@0
   648
}
slouken@1895
   649
/* *INDENT-ON* */
slouken@0
   650
#endif
slouken@0
   651
#include "close_code.h"
slouken@0
   652
slouken@0
   653
#endif /* _SDL_events_h */
slouken@1895
   654
slouken@1895
   655
/* vi: set ts=4 sw=4 expandtab: */