/* SDL - Simple DirectMedia Layer Copyright (C) 1997-2006 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Sam Lantinga slouken@libsdl.org */ /** * \file SDL_events.h * * Include file for SDL event handling */ #ifndef _SDL_events_h #define _SDL_events_h #include "SDL_stdinc.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_keyboard.h" #include "SDL_mouse.h" #include "SDL_joystick.h" #include "SDL_quit.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif /* General keyboard/mouse state definitions */ #define SDL_RELEASED 0 #define SDL_PRESSED 1 /** * \enum SDL_EventType * * \brief The types of events that can be delivered */ typedef enum { SDL_NOEVENT = 0, /**< Unused (do not remove) */ SDL_WINDOWEVENT, /**< Window state change */ SDL_KEYDOWN, /**< Keys pressed */ SDL_KEYUP, /**< Keys released */ SDL_TEXTINPUT, /**< Keyboard text input */ SDL_MOUSEMOTION, /**< Mouse moved */ SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ SDL_MOUSEBUTTONUP, /**< Mouse button released */ SDL_MOUSEWHEEL, /**< Mouse wheel motion */ SDL_JOYAXISMOTION, /**< Joystick axis motion */ SDL_JOYBALLMOTION, /**< Joystick trackball motion */ SDL_JOYHATMOTION, /**< Joystick hat position change */ SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ SDL_JOYBUTTONUP, /**< Joystick button released */ SDL_QUIT, /**< User-requested quit */ SDL_SYSWMEVENT, /**< System specific event */ SDL_PROXIMITYIN, /**< Proximity In event */ SDL_PROXIMITYOUT, /**< Proximity Out event */ SDL_EVENT_RESERVED1, /**< Reserved for future use... */ SDL_EVENT_RESERVED2, SDL_EVENT_RESERVED3, /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ SDL_USEREVENT = 24, /* This last event is only for bounding internal arrays It is the number of bits in the event mask datatype -- Uint32 */ SDL_NUMEVENTS = 32 } SDL_EventType; /** * \enum SDL_EventMask * * \brief Predefined event masks */ #define SDL_EVENTMASK(X) (1<<(X)) typedef enum { SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT), SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP), SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT), SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL), SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) | SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP), SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) | SDL_EVENTMASK(SDL_JOYBALLMOTION) | SDL_EVENTMASK(SDL_JOYHATMOTION) | SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP), SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT), SDL_PROXIMITYINMASK = SDL_EVENTMASK(SDL_PROXIMITYIN), SDL_PROXIMITYOUTMASK = SDL_EVENTMASK(SDL_PROXIMITYOUT) } SDL_EventMask; #define SDL_ALLEVENTS 0xFFFFFFFF /** * \struct SDL_WindowEvent * * \brief Window state change event data (event.window.*) */ typedef struct SDL_WindowEvent { Uint8 type; /**< SDL_WINDOWEVENT */ Uint8 event; /**< SDL_WindowEventID */ int data1; /**< event dependent data */ int data2; /**< event dependent data */ SDL_WindowID windowID; /**< The associated window */ } SDL_WindowEvent; /** * \struct SDL_KeyboardEvent * * \brief Keyboard button event structure (event.key.*) */ typedef struct SDL_KeyboardEvent { Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ Uint8 which; /**< The keyboard device index */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ SDL_keysym keysym; /**< The key that was pressed or released */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */ } SDL_KeyboardEvent; /** * \struct SDL_TextInputEvent * * \brief Keyboard text input event structure (event.text.*) */ #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) typedef struct SDL_TextInputEvent { Uint8 type; /**< SDL_TEXTINPUT */ Uint8 which; /**< The keyboard device index */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */ } SDL_TextInputEvent; /** * \struct SDL_MouseMotionEvent * * \brief Mouse motion event structure (event.motion.*) */ typedef struct SDL_MouseMotionEvent { Uint8 type; /**< SDL_MOUSEMOTION */ Uint8 which; /**< The mouse device index */ Uint8 state; /**< The current button state */ int x; /**< X coordinate, relative to window */ int y; /**< Y coordinate, relative to window */ int z; /**< Z coordinate, for future use*/ int pressure; /**< Pressure reported by tablets */ int pressure_max; /**< Maximum value of the pressure reported by the device*/ int pressure_min; /**< Minimum value of the pressure reported by the device*/ int rotation; /**