Sleeping Wombat GUI  0.100
swGUI
InputDeviceEvent.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "KeyState.h"
10 
11 
12 
13 
14 namespace sw {
15 namespace input
16 {
17 
18 
19 typedef uint16 Timestamp;
20 
21 
22 struct Keyboard
23 {
24 
30  {
31  KEY_NONE = 0x00
32  , KEY_ESCAPE = 0x01
33  , KEY_1 = 0x02
34  , KEY_2 = 0x03
35  , KEY_3 = 0x04
36  , KEY_4 = 0x05
37  , KEY_5 = 0x06
38  , KEY_6 = 0x07
39  , KEY_7 = 0x08
40  , KEY_8 = 0x09
41  , KEY_9 = 0x0A
42  , KEY_0 = 0x0B
43  , KEY_MINUS = 0x0C /* - on main keyboard */
44  , KEY_EQUALS = 0x0D
45  , KEY_BACK = 0x0E /* backspace */
46  , KEY_TAB = 0x0F
47  , KEY_Q = 0x10
48  , KEY_W = 0x11
49  , KEY_E = 0x12
50  , KEY_R = 0x13
51  , KEY_T = 0x14
52  , KEY_Y = 0x15
53  , KEY_U = 0x16
54  , KEY_I = 0x17
55  , KEY_O = 0x18
56  , KEY_P = 0x19
57  , KEY_LBRACKET = 0x1A
58  , KEY_RBRACKET = 0x1B
59  , KEY_RETURN = 0x1C /* Enter on main keyboard */
60  , KEY_LCONTROL = 0x1D
61  , KEY_A = 0x1E
62  , KEY_S = 0x1F
63  , KEY_D = 0x20
64  , KEY_F = 0x21
65  , KEY_G = 0x22
66  , KEY_H = 0x23
67  , KEY_J = 0x24
68  , KEY_K = 0x25
69  , KEY_L = 0x26
70  , KEY_SEMICOLON = 0x27
71  , KEY_APOSTROPHE = 0x28
72  , KEY_GRAVE = 0x29 /* accent grave */
73  , KEY_LSHIFT = 0x2A
74  , KEY_BACKSLASH = 0x2B
75  , KEY_Z = 0x2C
76  , KEY_X = 0x2D
77  , KEY_C = 0x2E
78  , KEY_V = 0x2F
79  , KEY_B = 0x30
80  , KEY_N = 0x31
81  , KEY_M = 0x32
82  , KEY_COMMA = 0x33
83  , KEY_PERIOD = 0x34 /* . on main keyboard */
84  , KEY_SLASH = 0x35 /* / on main keyboard */
85  , KEY_RSHIFT = 0x36
86  , KEY_MULTIPLY = 0x37 /* * on numeric keypad */
87  , KEY_LMENU = 0x38 /* left Alt */
88  , KEY_SPACE = 0x39
89  , KEY_CAPITAL = 0x3A
90  , KEY_F1 = 0x3B
91  , KEY_F2 = 0x3C
92  , KEY_F3 = 0x3D
93  , KEY_F4 = 0x3E
94  , KEY_F5 = 0x3F
95  , KEY_F6 = 0x40
96  , KEY_F7 = 0x41
97  , KEY_F8 = 0x42
98  , KEY_F9 = 0x43
99  , KEY_F10 = 0x44
100  , KEY_NUMLOCK = 0x45
101  , KEY_SCROLL = 0x46 /* Scroll Lock */
102  , KEY_NUMPAD7 = 0x47
103  , KEY_NUMPAD8 = 0x48
104  , KEY_NUMPAD9 = 0x49
105  , KEY_SUBTRACT = 0x4A /* - on numeric keypad */
106  , KEY_NUMPAD4 = 0x4B
107  , KEY_NUMPAD5 = 0x4C
108  , KEY_NUMPAD6 = 0x4D
109  , KEY_ADD = 0x4E /* + on numeric keypad */
110  , KEY_NUMPAD1 = 0x4F
111  , KEY_NUMPAD2 = 0x50
112  , KEY_NUMPAD3 = 0x51
113  , KEY_NUMPAD0 = 0x52
114  , KEY_DECIMAL = 0x53 /* . on numeric keypad */
115  , KEY_OEM_102 = 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */
116  , KEY_F11 = 0x57
117  , KEY_F12 = 0x58
118  , KEY_F13 = 0x64 /* (NEC PC98) */
119  , KEY_F14 = 0x65 /* (NEC PC98) */
120  , KEY_F15 = 0x66 /* (NEC PC98) */
121  , KEY_KANA = 0x70 /* (Japanese keyboard) */
122  , KEY_ABNT_C1 = 0x73 /* /? on Brazilian keyboard */
123  , KEY_CONVERT = 0x79 /* (Japanese keyboard) */
124  , KEY_NOCONVERT = 0x7B /* (Japanese keyboard) */
125  , KEY_YEN = 0x7D /* (Japanese keyboard) */
126  , KEY_ABNT_C2 = 0x7E /* Numpad . on Brazilian keyboard */
127  , KEY_NUMPADEQUALS = 0x8D /* = on numeric keypad (NEC PC98) */
128  , KEY_PREVTRACK = 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */
129  , KEY_AT = 0x91 /* (NEC PC98) */
130  , KEY_COLON = 0x92 /* (NEC PC98) */
131  , KEY_UNDERLINE = 0x93 /* (NEC PC98) */
132  , KEY_KANJI = 0x94 /* (Japanese keyboard) */
133  , KEY_STOP = 0x95 /* (NEC PC98) */
134  , KEY_AX = 0x96 /* (Japan AX) */
135  , KEY_UNLABELED = 0x97 /* (J3100) */
136  , KEY_NEXTTRACK = 0x99 /* Next Track */
137  , KEY_NUMPADENTER = 0x9C /* Enter on numeric keypad */
138  , KEY_RCONTROL = 0x9D
139  , KEY_MUTE = 0xA0 /* Mute */
140  , KEY_CALCULATOR = 0xA1 /* Calculator */
141  , KEY_PLAYPAUSE = 0xA2 /* Play / Pause */
142  , KEY_MEDIASTOP = 0xA4 /* Media Stop */
143  , KEY_VOLUMEDOWN = 0xAE /* Volume - */
144  , KEY_VOLUMEUP = 0xB0 /* Volume + */
145  , KEY_WEBHOME = 0xB2 /* Web home */
146  , KEY_NUMPADCOMMA = 0xB3 /* , on numeric keypad (NEC PC98) */
147  , KEY_DIVIDE = 0xB5 /* / on numeric keypad */
148  , KEY_SYSRQ = 0xB7
149  , KEY_RMENU = 0xB8 /* right Alt */
150  , KEY_PAUSE = 0xC5 /* Pause */
151  , KEY_HOME = 0xC7 /* Home on arrow keypad */
152  , KEY_UP = 0xC8 /* UpArrow on arrow keypad */
153  , KEY_PRIOR = 0xC9 /* PgUp on arrow keypad */
154  , KEY_LEFT = 0xCB /* LeftArrow on arrow keypad */
155  , KEY_RIGHT = 0xCD /* RightArrow on arrow keypad */
156  , KEY_END = 0xCF /* End on arrow keypad */
157  , KEY_DOWN = 0xD0 /* DownArrow on arrow keypad */
158  , KEY_NEXT = 0xD1 /* PgDn on arrow keypad */
159  , KEY_INSERT = 0xD2 /* Insert on arrow keypad */
160  , KEY_DELETE = 0xD3 /* Delete on arrow keypad */
161  , KEY_LWIN = 0xDB /* Left Windows key */
162  , KEY_RWIN = 0xDC /* Right Windows key */
163  , KEY_APPS = 0xDD /* AppMenu key */
164  , KEY_POWER = 0xDE /* System Power */
165  , KEY_SLEEP = 0xDF /* System Sleep */
166  , KEY_WAKE = 0xE3 /* System Wake */
167  , KEY_WEBSEARCH = 0xE5 /* Web Search */
168  , KEY_WEBFAVORITES = 0xE6 /* Web Favorites */
169  , KEY_WEBREFRESH = 0xE7 /* Web Refresh */
170  , KEY_WEBSTOP = 0xE8 /* Web Stop */
171  , KEY_WEBFORWARD = 0xE9 /* Web Forward */
172  , KEY_WEBBACK = 0xEA /* Web Back */
173  , KEY_MYCOMPUTER = 0xEB /* My Computer */
174  , KEY_MAIL = 0xEC /* Mail */
175  , KEY_MEDIASELECT = 0xED /* Media Select */
176 
177  /*
178  * Alternate names for keys, to facilitate transition from DOS.
179  */
180  , KEY_BACKSPACE = KEY_BACK /* backspace */
181  , KEY_NUMPADSTAR = KEY_MULTIPLY /* * on numeric keypad */
182  , KEY_LALT = KEY_LMENU /* left Alt */
183  , KEY_CAPSLOCK = KEY_CAPITAL /* CapsLock */
184  , KEY_NUMPADMINUS = KEY_SUBTRACT /* - on numeric keypad */
185  , KEY_NUMPADPLUS = KEY_ADD /* + on numeric keypad */
186  , KEY_NUMPADPERIOD = KEY_DECIMAL /* . on numeric keypad */
187  , KEY_NUMPADSLASH = KEY_DIVIDE /* / on numeric keypad */
188  , KEY_RALT = KEY_RMENU /* right Alt */
189  , KEY_UPARROW = KEY_UP /* UpArrow on arrow keypad */
190  , KEY_PGUP = KEY_PRIOR /* PgUp on arrow keypad */
191  , KEY_LEFTARROW = KEY_LEFT /* LeftArrow on arrow keypad */
192  , KEY_RIGHTARROW = KEY_RIGHT /* RightArrow on arrow keypad */
193  , KEY_DOWNARROW = KEY_DOWN /* DownArrow on arrow keypad */
194  , KEY_PGDN = KEY_NEXT /* PgDn on arrow keypad */
195 
199  };
200 
201 };
202 
203 
204 struct Mouse
205 {
206 
216  {
217  BUTTON0 = 0,
218  BUTTON1 = 1,
219  BUTTON2 = 2,
220  BUTTON3 = 3,
221  BUTTON4 = 4,
222  BUTTON5 = 5,
223  BUTTON6 = 6,
224  BUTTON7 = 7,
225 
231 
232  NONE = 8,
233  };
234 
238  {
239  X_AXIS = 0,
240  Y_AXIS = 1,
241  Z_AXIS = 2,
242  W_AXIS = 3,
244  };
245 
246 };
247 
248 
251 enum class DeviceEventType : uint8
252 {
255  ButtonEvent,
256  AxisEvent,
257  CursorEvent,
258 
260 };
261 
264 enum class DeviceType : uint8
265 {
266  Keyboard,
267  Mouse,
268  Joystick
269 };
270 
271 
274 struct KeyEvent
275 {
278 };
279 
283 {
284  wchar_t Character;
285 };
286 
290 {
293 };
294 
297 struct AxisEvent
298 {
299  float Delta;
301 };
302 
306 {
307  short OffsetX;
308  short OffsetY;
309 };
310 
314 {
315  union
316  {
322  };
323 
325  Timestamp LogicalTime;
326 
328 
329 // ================================ //
330 //
332  {
334  LogicalTime = std::numeric_limits< Timestamp >::max();
335  }
336 
337  DeviceEvent( KeyEvent evt, Timestamp timestamp )
338  {
340  Key = evt;
341  LogicalTime = timestamp;
342  }
343 
344  DeviceEvent( CharacterEvent evt, Timestamp timestamp )
345  {
347  Character = evt;
348  LogicalTime = timestamp;
349  }
350 
351  DeviceEvent( ButtonEvent evt, Timestamp timestamp )
352  {
354  Button = evt;
355  LogicalTime = timestamp;
356  }
357 
358  DeviceEvent( AxisEvent evt, Timestamp timestamp )
359  {
361  Axis = evt;
362  LogicalTime = timestamp;
363  }
364 
365  DeviceEvent( CursorEvent evt, Timestamp timestamp )
366  {
368  Cursor = evt;
369  LogicalTime = timestamp;
370  }
371 
372  DeviceEvent( const DeviceEvent& second )
373  {
374  memcpy( this, &second, sizeof( DeviceEvent ) );
375  }
376 
377  void operator=( const DeviceEvent& second )
378  {
379  memcpy( this, &second, sizeof( DeviceEvent ) );
380  }
381 };
382 
383 
384 
385 
386 
387 
388 
389 } // input
390 } // sw
391 
392 
Definition: InputDeviceEvent.h:164
PhysicalButtons
Physical buttons.
Definition: InputDeviceEvent.h:215
Definition: InputDeviceEvent.h:38
Definition: InputDeviceEvent.h:73
Keyboard event after translation to character.
Definition: InputDeviceEvent.h:282
uint16_t uint16
Definition: TypesDefinitions.h:29
void operator=(const DeviceEvent &second)
Definition: InputDeviceEvent.h:377
Definition: InputDeviceEvent.h:124
Definition: InputDeviceEvent.h:80
Definition: InputDeviceEvent.h:125
Definition: InputDeviceEvent.h:163
Definition: InputDeviceEvent.h:98
Definition: InputDeviceEvent.h:184
Definition: InputDeviceEvent.h:83
Definition: InputDeviceEvent.h:166
Definition: InputDeviceEvent.h:50
Definition: InputDeviceEvent.h:54
Definition: InputDeviceEvent.h:87
Definition: InputDeviceEvent.h:226
Definition: InputDeviceEvent.h:113
Definition: InputDeviceEvent.h:149
Timestamp LogicalTime
Definition: InputDeviceEvent.h:325
Definition: InputDeviceEvent.h:79
Definition: InputDeviceEvent.h:121
uint16 Timestamp
Definition: InputDeviceEvent.h:19
Definition: InputDeviceEvent.h:232
Definition: InputDeviceEvent.h:40
Definition: InputDeviceEvent.h:95
Definition: InputDeviceEvent.h:111
Definition: InputDeviceEvent.h:228
Definition: InputDeviceEvent.h:173
Definition: InputDeviceEvent.h:114
Definition: InputDeviceEvent.h:62
Definition: InputDeviceEvent.h:134
Definition: InputDeviceEvent.h:96
CharacterEvent Character
Definition: InputDeviceEvent.h:318
Definition: InputDeviceEvent.h:90
Definition: InputDeviceEvent.h:155
Definition: InputDeviceEvent.h:99
Definition: InputDeviceEvent.h:51
Definition: InputDeviceEvent.h:55
Definition: InputDeviceEvent.h:174
Definition: InputDeviceEvent.h:129
Definition: InputDeviceEvent.h:198
Definition: InputDeviceEvent.h:123
Definition: InputDeviceEvent.h:189
Definition: InputDeviceEvent.h:119
Definition: InputDeviceEvent.h:162
Definition: InputDeviceEvent.h:71
Definition: InputDeviceEvent.h:118
Mouse::PhysicalButtons Button
Definition: InputDeviceEvent.h:292
int8_t int8
Definition: TypesDefinitions.h:26
Definition: DirectInputModule.cpp:11
short OffsetY
Definition: InputDeviceEvent.h:308
Definition: InputDeviceEvent.h:180
KeyState State
Only up or down state.
Definition: InputDeviceEvent.h:276
Definition: InputDeviceEvent.h:167
Keyboard::PhysicalKeys Key
Definition: InputDeviceEvent.h:277
Definition: InputDeviceEvent.h:100
Definition: InputDeviceEvent.h:72
DeviceEvent(const DeviceEvent &second)
Definition: InputDeviceEvent.h:372
wchar_t Character
Definition: InputDeviceEvent.h:284
Definition: InputDeviceEvent.h:115
Definition: InputDeviceEvent.h:160
Definition: InputDeviceEvent.h:97
Definition: InputDeviceEvent.h:42
Definition: InputDeviceEvent.h:44
Definition: InputDeviceEvent.h:217
short OffsetX
Definition: InputDeviceEvent.h:307
Definition: InputDeviceEvent.h:190
KeyStates changed events.
Definition: InputDeviceEvent.h:313
Definition: InputDeviceEvent.h:84
Definition: InputDeviceEvent.h:240
Definition: InputDeviceEvent.h:140
Definition: InputDeviceEvent.h:78
Definition: InputDeviceEvent.h:130
Definition: InputDeviceEvent.h:185
Definition: InputDeviceEvent.h:136
Definition: InputDeviceEvent.h:223
Definition: InputDeviceEvent.h:88
DeviceEvent(ButtonEvent evt, Timestamp timestamp)
Definition: InputDeviceEvent.h:351
Definition: InputDeviceEvent.h:132
Definition: InputDeviceEvent.h:57
Definition: InputDeviceEvent.h:168
Mouse::PhysicalAxes Axis
Definition: InputDeviceEvent.h:300
Definition: InputDeviceEvent.h:137
Definition: InputDeviceEvent.h:186
Definition: InputDeviceEvent.h:106
Definition: InputDeviceEvent.h:112
Definition: InputDeviceEvent.h:133
Plik zawiera definicje podstawowych typów zmiennych.
Definition: InputDeviceEvent.h:126
Definition: InputDeviceEvent.h:161
Definition: InputDeviceEvent.h:204
Definition: InputDeviceEvent.h:165
Definition: InputDeviceEvent.h:94
Mouse button Change event.
Definition: InputDeviceEvent.h:289
Definition: InputDeviceEvent.h:146
Definition: InputDeviceEvent.h:36
Definition: InputDeviceEvent.h:194
Definition: InputDeviceEvent.h:191
DeviceEvent(CursorEvent evt, Timestamp timestamp)
Definition: InputDeviceEvent.h:365
Definition: InputDeviceEvent.h:151
Definition: InputDeviceEvent.h:101
Definition: InputDeviceEvent.h:104
Definition: InputDeviceEvent.h:141
Definition: InputDeviceEvent.h:170
Definition: InputDeviceEvent.h:81
Definition: InputDeviceEvent.h:74
Cursor position changed event.
Definition: InputDeviceEvent.h:305
Definition: InputDeviceEvent.h:243
Definition: InputDeviceEvent.h:181
Definition: InputDeviceEvent.h:139
DeviceEvent(KeyEvent evt, Timestamp timestamp)
Definition: InputDeviceEvent.h:337
Definition: InputDeviceEvent.h:239
Definition: InputDeviceEvent.h:56
Definition: InputDeviceEvent.h:221
Definition: InputDeviceEvent.h:182
Definition: InputDeviceEvent.h:148
Definition: InputDeviceEvent.h:153
Definition: InputDeviceEvent.h:172
Definition: InputDeviceEvent.h:242
Definition: InputDeviceEvent.h:145
Definition: InputDeviceEvent.h:127
Definition: InputDeviceEvent.h:171
AxisEvent Axis
Definition: InputDeviceEvent.h:320
DeviceEventType
Input device event types.
Definition: InputDeviceEvent.h:251
Definition: InputDeviceEvent.h:75
Definition: InputDeviceEvent.h:120
Animation key.
Definition: IInterpolator.h:21
Definition: InputDeviceEvent.h:156
Definition: InputDeviceEvent.h:69
Definition: InputDeviceEvent.h:92
Definition: InputDeviceEvent.h:22
Definition: InputDeviceEvent.h:103
Button state structure..
Definition: KeyState.h:26
Definition: InputDeviceEvent.h:158
uint8_t uint8
Definition: TypesDefinitions.h:27
DeviceType
Input device types.
Definition: InputDeviceEvent.h:264
Definition: InputDeviceEvent.h:64
Definition: InputDeviceEvent.h:39
Definition: InputDeviceEvent.h:192
Definition: InputDeviceEvent.h:193
Definition: InputDeviceEvent.h:135
Definition: InputDeviceEvent.h:108
PhysicalAxes
Physical axes of mouse.
Definition: InputDeviceEvent.h:237
Definition: InputDeviceEvent.h:102
Definition: InputDeviceEvent.h:187
Definition: InputDeviceEvent.h:85
Definition: InputDeviceEvent.h:142
Definition: InputDeviceEvent.h:33
Definition: InputDeviceEvent.h:86
Definition: InputDeviceEvent.h:76
Definition: InputDeviceEvent.h:105
Definition: InputDeviceEvent.h:67
Definition: InputDeviceEvent.h:58
Definition: InputDeviceEvent.h:34
Mouse or joystick axis value changed event.
Definition: InputDeviceEvent.h:297
ButtonEvent Button
Definition: InputDeviceEvent.h:319
Definition: InputDeviceEvent.h:154
Definition: InputDeviceEvent.h:77
Definition: InputDeviceEvent.h:183
Definition: InputDeviceEvent.h:152
Definition: InputDeviceEvent.h:175
Definition: InputDeviceEvent.h:91
DeviceEvent(CharacterEvent evt, Timestamp timestamp)
Definition: InputDeviceEvent.h:344
Definition: InputDeviceEvent.h:131
Definition: InputDeviceEvent.h:52
Definition: InputDeviceEvent.h:218
Definition: InputDeviceEvent.h:49
Definition: InputDeviceEvent.h:169
Definition: InputDeviceEvent.h:122
Definition: InputDeviceEvent.h:31
Definition: InputDeviceEvent.h:48
Definition: InputDeviceEvent.h:45
float Delta
Axis delta.
Definition: InputDeviceEvent.h:299
Definition: InputDeviceEvent.h:229
Definition: InputDeviceEvent.h:224
Definition: InputDeviceEvent.h:70
Definition: InputDeviceEvent.h:220
Definition: InputDeviceEvent.h:143
Definition: InputDeviceEvent.h:109
Definition: InputDeviceEvent.h:65
Definition: InputDeviceEvent.h:196
Definition: InputDeviceEvent.h:61
Definition: InputDeviceEvent.h:60
Definition: InputDeviceEvent.h:138
Definition: InputDeviceEvent.h:222
Definition: InputDeviceEvent.h:150
Definition: InputDeviceEvent.h:157
Definition: InputDeviceEvent.h:43
Definition: InputDeviceEvent.h:32
Definition: InputDeviceEvent.h:66
Definition: InputDeviceEvent.h:53
Definition: InputDeviceEvent.h:35
Definition: InputDeviceEvent.h:46
Definition: InputDeviceEvent.h:89
Definition: InputDeviceEvent.h:188
Definition: InputDeviceEvent.h:107
CursorEvent Cursor
Definition: InputDeviceEvent.h:321
Definition: InputDeviceEvent.h:159
Definition: InputDeviceEvent.h:128
Definition: InputDeviceEvent.h:197
Definition: InputDeviceEvent.h:82
Keyboard key change event.
Definition: InputDeviceEvent.h:274
DeviceEventType Type
Definition: InputDeviceEvent.h:324
Definition: InputDeviceEvent.h:93
DeviceEvent()
Definition: InputDeviceEvent.h:331
Definition: InputDeviceEvent.h:241
KeyState State
Only up or down state.
Definition: InputDeviceEvent.h:291
Definition: InputDeviceEvent.h:37
KeyEvent Key
Definition: InputDeviceEvent.h:317
Definition: InputDeviceEvent.h:68
Definition: InputDeviceEvent.h:219
DeviceEvent(AxisEvent evt, Timestamp timestamp)
Definition: InputDeviceEvent.h:358
Definition: InputDeviceEvent.h:47
Definition: InputDeviceEvent.h:63
Definition: InputDeviceEvent.h:117
PhysicalKeys
Physical keys numbers. Numbers are the same as in DirectInput.
Definition: InputDeviceEvent.h:29
Definition: InputDeviceEvent.h:144
Definition: InputDeviceEvent.h:227
Definition: InputDeviceEvent.h:110
Definition: InputDeviceEvent.h:41
Definition: InputDeviceEvent.h:59
Definition: InputDeviceEvent.h:116
Definition: InputDeviceEvent.h:147
Definition: InputDeviceEvent.h:230