Merge pull request #4630 from Red-F/gotham-resume-pvr-lastplayedposition
[vuplus_xbmc] / xbmc / windowing / XBMC_events.h
1 /*
2  *      SDL - Simple DirectMedia Layer
3  *      Copyright (C) 1997-2009 Sam Lantinga
4  *      Sam Lantinga
5  *      slouken@libsdl.org
6  *  
7  *      Copyright (C) 2005-2013 Team XBMC
8  *      http://xbmc.org
9  *
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)
13  *  any later version.
14  *
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.
19  *
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/>.
23  *
24  */
25
26 /* Include file for SDL event handling */
27
28 #ifndef _XBMC_events_h
29 #define _XBMC_events_h
30
31 #include "input/XBMC_keyboard.h"
32 #include "input/XBMC_mouse.h"
33
34
35 /* General keyboard/mouse state definitions */
36 #define XBMC_RELEASED   0
37 #define XBMC_PRESSED    1
38
39 /* Hat definitions */
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
49
50 /* Event enumerations */
51 typedef enum {
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. */
70        XBMC_TOUCH,
71        XBMC_SETFOCUS,
72        XBMC_USEREVENT,
73
74        XBMC_MAXEVENT = 256      /* XBMC_EventType is represented as uchar */
75 } XBMC_EventType;
76
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 */
82 } XBMC_ActiveEvent;
83
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 */
89         XBMC_keysym keysym;
90 } XBMC_KeyboardEvent;
91
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;
101
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;
110
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) */
118 } XBMC_JoyAxisEvent;
119
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 */
127 } XBMC_JoyBallEvent;
128
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.
139                         */
140 } XBMC_JoyHatEvent;
141
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;
150
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.
154  */
155 typedef struct XBMC_ResizeEvent {
156         unsigned char type;     /* XBMC_VIDEORESIZE */
157         int w;          /* New width */
158         int h;          /* New height */
159 } XBMC_ResizeEvent;
160
161 typedef struct XBMC_MoveEvent {
162         unsigned char type;     /* XBMC_VIDEOMOVE */
163         int x;          /* New x position */
164         int y;          /* New y position */
165 } XBMC_MoveEvent;
166
167 /* The "screen redraw" event */
168 typedef struct XBMC_ExposeEvent {
169         unsigned char type;     /* XBMC_VIDEOEXPOSE */
170 } XBMC_ExposeEvent;
171
172 /* The "quit requested" event */
173 typedef struct XBMC_QuitEvent {
174         unsigned char type;     /* XBMC_QUIT */
175 } XBMC_QuitEvent;
176
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 */
183 } XBMC_UserEvent;
184
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 {
189         unsigned char type;
190         XBMC_SysWMmsg *msg;
191 } XBMC_SysWMEvent;
192
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;
198
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 */
206 } XBMC_TouchEvent;
207
208 typedef struct XBMC_SetFocusEvent {
209         unsigned char type;     /* XBMC_SETFOCUS */
210         int x;          /* x position */
211         int y;          /* y position */
212 } XBMC_SetFocusEvent;
213
214 /* General event structure */
215 typedef union XBMC_Event {
216   unsigned char type;
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;
226   XBMC_MoveEvent move;
227   XBMC_ExposeEvent expose;
228   XBMC_QuitEvent quit;
229   XBMC_UserEvent user;
230   XBMC_SysWMEvent syswm;
231   XBMC_AppCommandEvent appcommand;
232   XBMC_TouchEvent touch;
233   XBMC_SetFocusEvent focus;
234 } XBMC_Event;
235
236 #endif /* _XBMC_events_h */