19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * @file SDL_events.h 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Include file for SDL event handling 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _SDL_events_h 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _SDL_events_h 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_stdinc.h" 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_error.h" 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_active.h" 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_keyboard.h" 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mouse.h" 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_joystick.h" 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_quit.h" 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "begin_code.h" 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Set up for C function definitions, even when using C++ */ 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __cplusplus 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" { 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** @name General keyboard/mouse state definitions */ 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/ 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_RELEASED 0 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_PRESSED 1 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/ 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Event enumerations */ 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef enum { 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_NOEVENT = 0, /**< Unused (do not remove) */ 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ACTIVEEVENT, /**< Application loses/gains visibility */ 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_KEYDOWN, /**< Keys pressed */ 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_KEYUP, /**< Keys released */ 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEMOTION, /**< Mouse moved */ 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEBUTTONUP, /**< Mouse button released */ 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYAXISMOTION, /**< Joystick axis motion */ 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYBALLMOTION, /**< Joystick trackball motion */ 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYHATMOTION, /**< Joystick hat position change */ 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYBUTTONUP, /**< Joystick button released */ 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_QUIT, /**< User-requested quit */ 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SYSWMEVENT, /**< System specific event */ 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVEDA, /**< Reserved for future use.. */ 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVEDB, /**< Reserved for future use.. */ 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VIDEORESIZE, /**< User resized video mode */ 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VIDEOEXPOSE, /**< Screen needs to be redrawn */ 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVED2, /**< Reserved for future use.. */ 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVED3, /**< Reserved for future use.. */ 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVED4, /**< Reserved for future use.. */ 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVED5, /**< Reserved for future use.. */ 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVED6, /**< Reserved for future use.. */ 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENT_RESERVED7, /**< Reserved for future use.. */ 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /** Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_USEREVENT = 24, 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /** This last event is only for bounding internal arrays 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * It is the number of bits in the event mask datatype -- Uint32 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_NUMEVENTS = 32 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_EventType; 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** @name Predefined event masks */ 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/ 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_EVENTMASK(X) (1<<(X)) 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef enum { 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_KEYUP), 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_MOUSEBUTTONUP), 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_JOYBALLMOTION)| 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_JOYHATMOTION)| 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_EVENTMASK(SDL_JOYBUTTONUP), 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_EventMask ; 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_ALLEVENTS 0xFFFFFFFF 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/ 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Application visibility event structure */ 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_ActiveEvent { 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_ACTIVEEVENT */ 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 gain; /**< Whether given states were gained or lost (1/0) */ 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 state; /**< A mask of the focus states */ 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_ActiveEvent; 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Keyboard event structure */ 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_KeyboardEvent { 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The keyboard device index */ 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_keysym keysym; 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_KeyboardEvent; 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Mouse motion event structure */ 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_MouseMotionEvent { 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_MOUSEMOTION */ 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The mouse device index */ 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 state; /**< The current button state */ 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint16 x, y; /**< The X/Y coordinates of the mouse */ 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sint16 xrel; /**< The relative motion in the X direction */ 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sint16 yrel; /**< The relative motion in the Y direction */ 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_MouseMotionEvent; 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Mouse button event structure */ 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_MouseButtonEvent { 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The mouse device index */ 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 button; /**< The mouse button index */ 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint16 x, y; /**< The X/Y coordinates of the mouse at press time */ 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_MouseButtonEvent; 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Joystick axis motion event structure */ 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_JoyAxisEvent { 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_JOYAXISMOTION */ 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The joystick device index */ 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 axis; /**< The joystick axis index */ 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sint16 value; /**< The axis value (range: -32768 to 32767) */ 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_JoyAxisEvent; 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Joystick trackball motion event structure */ 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_JoyBallEvent { 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_JOYBALLMOTION */ 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The joystick device index */ 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 ball; /**< The joystick trackball index */ 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sint16 xrel; /**< The relative motion in the X direction */ 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sint16 yrel; /**< The relative motion in the Y direction */ 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_JoyBallEvent; 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Joystick hat position change event structure */ 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_JoyHatEvent { 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_JOYHATMOTION */ 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The joystick device index */ 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 hat; /**< The joystick hat index */ 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 value; /**< The hat position value: 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Note that zero means the POV is centered. 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_JoyHatEvent; 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Joystick button event structure */ 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_JoyButtonEvent { 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 which; /**< The joystick device index */ 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 button; /**< The joystick button index */ 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_JoyButtonEvent; 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** The "window resized" event 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * When you get this event, you are responsible for setting a new video 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * mode with the new width and height. 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_ResizeEvent { 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_VIDEORESIZE */ 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w; /**< New width */ 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int h; /**< New height */ 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_ResizeEvent; 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** The "screen redraw" event */ 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_ExposeEvent { 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_VIDEOEXPOSE */ 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_ExposeEvent; 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** The "quit requested" event */ 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_QuitEvent { 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_QUIT */ 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_QuitEvent; 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** A user-defined event type */ 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_UserEvent { 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int code; /**< User defined event code */ 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void *data1; /**< User defined data pointer */ 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void *data2; /**< User defined data pointer */ 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_UserEvent; 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** If you want to use this event, you should include SDL_syswm.h */ 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct SDL_SysWMmsg; 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_SysWMmsg SDL_SysWMmsg; 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct SDL_SysWMEvent { 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SysWMmsg *msg; 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_SysWMEvent; 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** General event structure */ 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef union SDL_Event { 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 type; 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ActiveEvent active; 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_KeyboardEvent key; 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MouseMotionEvent motion; 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_MouseButtonEvent button; 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JoyAxisEvent jaxis; 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JoyBallEvent jball; 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JoyHatEvent jhat; 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_JoyButtonEvent jbutton; 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ResizeEvent resize; 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ExposeEvent expose; 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_QuitEvent quit; 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_UserEvent user; 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SysWMEvent syswm; 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_Event; 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function prototypes */ 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Pumps the event loop, gathering events from the input devices. 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function updates the event queue and internal input device state. 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This should only be run in the thread that sets the video mode. 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC void SDLCALL SDL_PumpEvents(void); 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef enum { 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ADDEVENT, 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PEEKEVENT, 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GETEVENT 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} SDL_eventaction; 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Checks the event queue for messages and optionally returns them. 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * the back of the event queue. 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * of the event queue, matching 'mask', will be returned and will not 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * be removed from the queue. 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If 'action' is SDL_GETEVENT, up to 'numevents' events at the front 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * of the event queue, matching 'mask', will be returned and will be 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * removed from the queue. 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * @return 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function returns the number of events actually stored, or -1 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * if there was an error. 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function is thread-safe. 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_eventaction action, Uint32 mask); 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Polls for currently pending events, and returns 1 if there are any pending 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * events, or 0 if there are none available. If 'event' is not NULL, the next 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * event is removed from the queue and stored in that area. 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Waits indefinitely for the next available event, returning 1, or 0 if there 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * was an error while waiting for events. If 'event' is not NULL, the next 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * event is removed from the queue and stored in that area. 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** Add an event to the event queue. 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function returns 0 on success, or -1 if the event queue was full 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * or there was some other error. 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** @name Event Filtering */ 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/ 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function sets up a filter to process all events before they 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * change internal state and are posted to the internal event queue. 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * The filter is protypted as: 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * @code typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); @endcode 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If the filter returns 1, then the event will be added to the internal queue. 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If it returns 0, then the event will be dropped from the queue, but the 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * internal state will still be updated. This allows selective filtering of 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * dynamically arriving events. 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * @warning Be very careful of what you do in the event filter function, as 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * it may run in a different thread! 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * There is one caveat when dealing with the SDL_QUITEVENT event type. The 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * event filter is only called when the window manager desires to close the 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * application window. If the event filter returns 1, then the window will 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * be closed, otherwise the window will remain open if possible. 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If the quit event is generated by an interrupt signal, it will bypass the 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * internal queue and be delivered to the application at the next event poll. 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Return the current event filter - can be used to "chain" filters. 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If there is no event filter set, this function returns NULL. 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/ 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** @name Event State */ 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/ 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_QUERY -1 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_IGNORE 0 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_DISABLE 0 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_ENABLE 1 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/ 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall* This function allows you to set the state of processing certain events. 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall* If 'state' is set to SDL_IGNORE, that event will be automatically dropped 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall* from the event queue and will not event be filtered. 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall* If 'state' is set to SDL_ENABLE, that event will be processed normally. 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall* If 'state' is set to SDL_QUERY, SDL_EventState() will return the 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall* current processing state of the specified event. 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Ends C function definitions when using C++ */ 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __cplusplus 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "close_code.h" 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* _SDL_events_h */ 357