2 * SDL - Simple DirectMedia Layer
3 * Copyright (C) 1997-2009 Sam Lantinga
7 * Copyright (C) 2005-2013 Team XBMC
10 * This Program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * This Program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with XBMC; see the file COPYING. If not, see
22 * <http://www.gnu.org/licenses/>.
26 /* Include file for SDL event handling */
28 #ifndef _XBMC_events_h
29 #define _XBMC_events_h
31 #include "input/XBMC_keyboard.h"
32 #include "input/XBMC_mouse.h"
35 /* General keyboard/mouse state definitions */
36 #define XBMC_RELEASED 0
37 #define XBMC_PRESSED 1
40 #define XBMC_HAT_CENTERED 0
41 #define XBMC_HAT_UP 0x01
42 #define XBMC_HAT_RIGHT 0x02
43 #define XBMC_HAT_DOWN 0x04
44 #define XBMC_HAT_LEFT 0x08
45 #define XBMC_HAT_LEFTUP XBMC_HAT_UP | XBMC_HAT_LEFT
46 #define XBMC_HAT_RIGHTUP XBMC_HAT_UP | XBMC_HAT_RIGHT
47 #define XBMC_HAT_LEFTDOWN XBMC_HAT_DOWN | XBMC_HAT_LEFT
48 #define XBMC_HAT_RIGHTDOWN XBMC_HAT_DOWN | XBMC_HAT_RIGHT
50 /* Event enumerations */
52 XBMC_NOEVENT = 0, /* Unused (do not remove) */
53 XBMC_ACTIVEEVENT, /* Application loses/gains visibility */
54 XBMC_KEYDOWN, /* Keys pressed */
55 XBMC_KEYUP, /* Keys released */
56 XBMC_MOUSEMOTION, /* Mouse moved */
57 XBMC_MOUSEBUTTONDOWN, /* Mouse button pressed */
58 XBMC_MOUSEBUTTONUP, /* Mouse button released */
59 XBMC_JOYAXISMOTION, /* Joystick axis motion */
60 XBMC_JOYBALLMOTION, /* Joystick trackball motion */
61 XBMC_JOYHATMOTION, /* Joystick hat position change */
62 XBMC_JOYBUTTONDOWN, /* Joystick button pressed */
63 XBMC_JOYBUTTONUP, /* Joystick button released */
64 XBMC_QUIT, /* User-requested quit */
65 XBMC_SYSWMEVENT, /* System specific event */
66 XBMC_VIDEORESIZE, /* User resized video mode */
67 XBMC_VIDEOMOVE, /* User moved the window */
68 XBMC_VIDEOEXPOSE, /* Screen needs to be redrawn */
69 XBMC_APPCOMMAND, /* Media commands, such as WM_APPCOMMAND on Windows for media keys. */
74 XBMC_MAXEVENT = 256 /* XBMC_EventType is represented as uchar */
77 /* Application visibility event structure */
78 typedef struct XBMC_ActiveEvent {
79 unsigned char type; /* XBMC_ACTIVEEVENT */
80 unsigned char gain; /* Whether given states were gained or lost (1/0) */
81 unsigned char state; /* A mask of the focus states */
84 /* Keyboard event structure */
85 typedef struct XBMC_KeyboardEvent {
86 unsigned char type; /* XBMC_KEYDOWN or XBMC_KEYUP */
87 unsigned char which; /* The keyboard device index */
88 unsigned char state; /* XBMC_PRESSED or XBMC_RELEASED */
92 /* Mouse motion event structure */
93 typedef struct XBMC_MouseMotionEvent {
94 unsigned char type; /* XBMC_MOUSEMOTION */
95 unsigned char which; /* The mouse device index */
96 unsigned char state; /* The current button state */
97 uint16_t x, y; /* The X/Y coordinates of the mouse */
98 int16_t xrel; /* The relative motion in the X direction */
99 int16_t yrel; /* The relative motion in the Y direction */
100 } XBMC_MouseMotionEvent;
102 /* Mouse button event structure */
103 typedef struct XBMC_MouseButtonEvent {
104 unsigned char type; /* XBMC_MOUSEBUTTONDOWN or XBMC_MOUSEBUTTONUP */
105 unsigned char which; /* The mouse device index */
106 unsigned char button; /* The mouse button index */
107 unsigned char state; /* XBMC_PRESSED or XBMC_RELEASED */
108 uint16_t x, y; /* The X/Y coordinates of the mouse at press time */
109 } XBMC_MouseButtonEvent;
111 /* Joystick axis motion event structure */
112 typedef struct XBMC_JoyAxisEvent {
113 unsigned char type; /* XBMC_JOYAXISMOTION */
114 unsigned char which; /* The joystick device index */
115 unsigned char axis; /* The joystick axis index */
116 int16_t value; /* The axis value (range: -32768 to 32767) */
117 float fvalue; /* The axis value (range: -1.0 to 1.0) */
120 /* Joystick trackball motion event structure */
121 typedef struct XBMC_JoyBallEvent {
122 unsigned char type; /* XBMC_JOYBALLMOTION */
123 unsigned char which; /* The joystick device index */
124 unsigned char ball; /* The joystick trackball index */
125 int16_t xrel; /* The relative motion in the X direction */
126 int16_t yrel; /* The relative motion in the Y direction */
129 /* Joystick hat position change event structure */
130 typedef struct XBMC_JoyHatEvent {
131 unsigned char type; /* XBMC_JOYHATMOTION */
132 unsigned char which; /* The joystick device index */
133 unsigned char hat; /* The joystick hat index */
134 unsigned char value; /* The hat position value:
135 XBMC_HAT_LEFTUP XBMC_HAT_UP XBMC_HAT_RIGHTUP
136 XBMC_HAT_LEFT XBMC_HAT_CENTERED XBMC_HAT_RIGHT
137 XBMC_HAT_LEFTDOWN XBMC_HAT_DOWN XBMC_HAT_RIGHTDOWN
138 Note that zero means the POV is centered.
142 /* Joystick button event structure */
143 typedef struct XBMC_JoyButtonEvent {
144 unsigned char type; /* XBMC_JOYBUTTONDOWN or XBMC_JOYBUTTONUP */
145 unsigned char which; /* The joystick device index */
146 unsigned char button; /* The joystick button index */
147 unsigned char state; /* XBMC_PRESSED or XBMC_RELEASED */
148 uint32_t holdTime; /*holdTime of the pressed button*/
149 } XBMC_JoyButtonEvent;
151 /* The "window resized" event
152 When you get this event, you are responsible for setting a new video
153 mode with the new width and height.
155 typedef struct XBMC_ResizeEvent {
156 unsigned char type; /* XBMC_VIDEORESIZE */
157 int w; /* New width */
158 int h; /* New height */
161 typedef struct XBMC_MoveEvent {
162 unsigned char type; /* XBMC_VIDEOMOVE */
163 int x; /* New x position */
164 int y; /* New y position */
167 /* The "screen redraw" event */
168 typedef struct XBMC_ExposeEvent {
169 unsigned char type; /* XBMC_VIDEOEXPOSE */
172 /* The "quit requested" event */
173 typedef struct XBMC_QuitEvent {
174 unsigned char type; /* XBMC_QUIT */
177 /* A user-defined event type */
178 typedef struct XBMC_UserEvent {
179 unsigned char type; /* XBMC_USEREVENT */
180 int code; /* User defined event code */
181 void *data1; /* User defined data pointer */
182 void *data2; /* User defined data pointer */
185 /* If you want to use this event, you should include XBMC_syswm.h */
186 struct XBMC_SysWMmsg;
187 typedef struct XBMC_SysWMmsg XBMC_SysWMmsg;
188 typedef struct XBMC_SysWMEvent {
193 /* Multimedia keys on keyboards / remotes are mapped to APPCOMMAND events */
194 typedef struct XBMC_AppCommandEvent {
195 unsigned char type; /* XBMC_APPCOMMAND */
196 unsigned int action; /* One of ACTION_... */
197 } XBMC_AppCommandEvent;
199 /* Mouse motion event structure */
200 typedef struct XBMC_TouchEvent {
201 unsigned char type; /* XBMC_TOUCH */
202 int action; /* action ID */
203 float x, y; /* The X/Y coordinates of the mouse */
204 float x2, y2; /* Additional X/Y coordinates */
205 int pointers; /* number of touch pointers */
208 typedef struct XBMC_SetFocusEvent {
209 unsigned char type; /* XBMC_SETFOCUS */
210 int x; /* x position */
211 int y; /* y position */
212 } XBMC_SetFocusEvent;
214 /* General event structure */
215 typedef union XBMC_Event {
217 XBMC_ActiveEvent active;
218 XBMC_KeyboardEvent key;
219 XBMC_MouseMotionEvent motion;
220 XBMC_MouseButtonEvent button;
221 XBMC_JoyAxisEvent jaxis;
222 XBMC_JoyBallEvent jball;
223 XBMC_JoyHatEvent jhat;
224 XBMC_JoyButtonEvent jbutton;
225 XBMC_ResizeEvent resize;
227 XBMC_ExposeEvent expose;
230 XBMC_SysWMEvent syswm;
231 XBMC_AppCommandEvent appcommand;
232 XBMC_TouchEvent touch;
233 XBMC_SetFocusEvent focus;
236 #endif /* _XBMC_events_h */