]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/Window/Event.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / Window / Event.hpp
1 ////////////////////////////////////////////////////////////
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 //    you must not claim that you wrote the original software.
15 //    If you use this software in a product, an acknowledgment
16 //    in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 //    and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
23 ////////////////////////////////////////////////////////////
24
25 #ifndef SFML_EVENT_HPP
26 #define SFML_EVENT_HPP
27
28 ////////////////////////////////////////////////////////////
29 // Headers
30 ////////////////////////////////////////////////////////////
31 #include <SFML/Config.hpp>
32
33
34 namespace sf
35 {
36 ////////////////////////////////////////////////////////////
37 /// Definition of key codes for keyboard events
38 ////////////////////////////////////////////////////////////
39 namespace Key
40 {
41     enum Code
42     {
43         A = 'a',
44         B = 'b',
45         C = 'c',
46         D = 'd',
47         E = 'e',
48         F = 'f',
49         G = 'g',
50         H = 'h',
51         I = 'i',
52         J = 'j',
53         K = 'k',
54         L = 'l',
55         M = 'm',
56         N = 'n',
57         O = 'o',
58         P = 'p',
59         Q = 'q',
60         R = 'r',
61         S = 's',
62         T = 't',
63         U = 'u',
64         V = 'v',
65         W = 'w',
66         X = 'x',
67         Y = 'y',
68         Z = 'z',
69         Num0 = '0',
70         Num1 = '1',
71         Num2 = '2',
72         Num3 = '3',
73         Num4 = '4',
74         Num5 = '5',
75         Num6 = '6',
76         Num7 = '7',
77         Num8 = '8',
78         Num9 = '9', 
79         Escape = 256,
80         LControl,
81         LShift,
82         LAlt,
83         LSystem,      ///< OS specific key (left side) : windows (Win and Linux), apple (MacOS), ...
84         RControl,
85         RShift,
86         RAlt,
87         RSystem,      ///< OS specific key (right side) : windows (Win and Linux), apple (MacOS), ...
88         Menu,
89         LBracket,     ///< [
90         RBracket,     ///< ]
91         SemiColon,    ///< ;
92         Comma,        ///< ,
93         Period,       ///< .
94         Quote,        ///< '
95         Slash,        ///< /
96         BackSlash,
97         Tilde,        ///< ~
98         Equal,        ///< =
99         Dash,         ///< -
100         Space,
101         Return,
102         Back,
103         Tab,
104         PageUp,
105         PageDown,
106         End,
107         Home,
108         Insert,
109         Delete,
110         Add,          ///< +
111         Subtract,     ///< -
112         Multiply,     ///< *
113         Divide,       ///< /
114         Left,         ///< Left arrow
115         Right,        ///< Right arrow
116         Up,           ///< Up arrow
117         Down,         ///< Down arrow
118         Numpad0,
119         Numpad1,
120         Numpad2,
121         Numpad3,
122         Numpad4,
123         Numpad5,
124         Numpad6,
125         Numpad7,
126         Numpad8,
127         Numpad9,
128         F1,
129         F2,
130         F3,
131         F4,
132         F5,
133         F6,
134         F7,
135         F8,
136         F9,
137         F10,
138         F11,
139         F12,
140         F13,
141         F14,
142         F15,
143         Pause,
144
145         Count // Keep last -- total number of keyboard keys
146     };
147 }
148
149
150 ////////////////////////////////////////////////////////////
151 /// Definition of button codes for mouse events
152 ////////////////////////////////////////////////////////////
153 namespace Mouse
154 {
155     enum Button
156     {
157         Left,
158         Right,
159         Middle,
160         XButton1,
161         XButton2,
162
163         ButtonCount // Keep last -- total number of mouse buttons
164     };
165 }
166
167
168 ////////////////////////////////////////////////////////////
169 /// Definition of joystick axis for joystick events
170 ////////////////////////////////////////////////////////////
171 namespace Joy
172 {
173     enum Axis
174     {
175         AxisX,
176         AxisY,
177         AxisZ,
178         AxisR,
179         AxisU,
180         AxisV,
181         AxisPOV,
182
183         AxisCount // Keep last -- total number of joystick axis
184     };
185
186     enum
187     {
188         Count       = 4, ///< Total number of supported joysticks
189         ButtonCount = 32 ///< Total number of supported joystick buttons
190     };
191 }
192
193
194 ////////////////////////////////////////////////////////////
195 /// Event defines a system event and its parameters
196 ////////////////////////////////////////////////////////////
197 class Event
198 {
199 public :
200
201     ////////////////////////////////////////////////////////////
202     /// Keyboard event parameters
203     ////////////////////////////////////////////////////////////
204     struct KeyEvent
205     {
206         Key::Code Code;
207         bool      Alt;
208         bool      Control;
209         bool      Shift;
210     };
211
212     ////////////////////////////////////////////////////////////
213     /// Text event parameters
214     ////////////////////////////////////////////////////////////
215     struct TextEvent
216     {
217         Uint32 Unicode;
218     };
219
220     ////////////////////////////////////////////////////////////
221     /// Mouse move event parameters
222     ////////////////////////////////////////////////////////////
223     struct MouseMoveEvent
224     {
225         int X;
226         int Y;
227     };
228
229     ////////////////////////////////////////////////////////////
230     /// Mouse buttons events parameters
231     ////////////////////////////////////////////////////////////
232     struct MouseButtonEvent
233     {
234         Mouse::Button Button;
235         int           X;
236         int           Y;
237     };
238
239     ////////////////////////////////////////////////////////////
240     /// Mouse wheel events parameters
241     ////////////////////////////////////////////////////////////
242     struct MouseWheelEvent
243     {
244         int Delta;
245     };
246
247     ////////////////////////////////////////////////////////////
248     /// Joystick axis move event parameters
249     ////////////////////////////////////////////////////////////
250     struct JoyMoveEvent
251     {
252         unsigned int JoystickId;
253         Joy::Axis    Axis;
254         float        Position;
255     };
256
257     ////////////////////////////////////////////////////////////
258     /// Joystick buttons events parameters
259     ////////////////////////////////////////////////////////////
260     struct JoyButtonEvent
261     {
262         unsigned int JoystickId;
263         unsigned int Button;
264     };
265
266     ////////////////////////////////////////////////////////////
267     /// Size events parameters
268     ////////////////////////////////////////////////////////////
269     struct SizeEvent
270     {
271         unsigned int Width;
272         unsigned int Height;
273     };
274
275     ////////////////////////////////////////////////////////////
276     /// Enumeration of the different types of events
277     ////////////////////////////////////////////////////////////
278     enum EventType
279     {
280         Closed,
281         Resized,
282         LostFocus,
283         GainedFocus,
284         TextEntered,
285         KeyPressed,
286         KeyReleased,
287         MouseWheelMoved,
288         MouseButtonPressed,
289         MouseButtonReleased,
290         MouseMoved,
291         MouseEntered,
292         MouseLeft,
293         JoyButtonPressed,
294         JoyButtonReleased,
295         JoyMoved,
296
297         Count // Keep last -- total number of event types
298     };
299
300     ////////////////////////////////////////////////////////////
301     // Member data
302     ////////////////////////////////////////////////////////////
303     EventType Type; ///< Type of the event
304
305     union
306     {
307         KeyEvent         Key;
308         TextEvent        Text;
309         MouseMoveEvent   MouseMove;
310         MouseButtonEvent MouseButton;
311         MouseWheelEvent  MouseWheel;
312         JoyMoveEvent     JoyMove;
313         JoyButtonEvent   JoyButton;
314         SizeEvent        Size;
315     };
316 };
317
318 } // namespace sf
319
320
321 #endif // SFML_EVENT_HPP