UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
keycode.h
Go to the documentation of this file.
1 /*
2  Header adapted from SDL_keycode.h
3  Original license is the following:
4 
5  Simple DirectMedia Layer
6  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
7 
8  This software is provided 'as-is', without any express or implied
9  warranty. In no event will the authors be held liable for any damages
10  arising from the use of this software.
11 
12  Permission is granted to anyone to use this software for any purpose,
13  including commercial applications, and to alter it and redistribute it
14  freely, subject to the following restrictions:
15 
16  1. The origin of this software must not be misrepresented; you must not
17  claim that you wrote the original software. If you use this software
18  in a product, an acknowledgment in the product documentation would be
19  appreciated but is not required.
20  2. Altered source versions must be plainly marked as such, and must not be
21  misrepresented as being the original software.
22  3. This notice may not be removed or altered from any source distribution.
23 */
24 
29 #ifndef UGDK_INPUT_KEYCODE_H_
30 #define UGDK_INPUT_KEYCODE_H_
31 
32 #include <ugdk/structure/types.h>
33 #include <ugdk/input/scancode.h>
34 
35 namespace ugdk {
36 namespace input {
37 
38 static const int SCANCODE_MASK = 1 << 30;
39 #define UGDK_SCANCODE_TO_KEYCODE(X) (static_cast<int>(X) | SCANCODE_MASK)
40 
49 enum class Keycode
50 {
51  UNKNOWN = 0,
52 
53  RETURN = '\r',
54  ESCAPE = '\033',
55  BACKSPACE = '\b',
56  TAB = '\t',
57  SPACE = ' ',
58  EXCLAIM = '!',
59  QUOTEDBL = '"',
60  HASH = '#',
61  PERCENT = '%',
62  DOLLAR = '$',
63  AMPERSAND = '&',
64  QUOTE = '\'',
65  LEFTPAREN = '(',
66  RIGHTPAREN = ')',
67  ASTERISK = '*',
68  PLUS = '+',
69  COMMA = ',',
70  MINUS = '-',
71  PERIOD = '.',
72  SLASH = '/',
73  ALPHANUMERIC_0 = '0',
74  ALPHANUMERIC_1 = '1',
75  ALPHANUMERIC_2 = '2',
76  ALPHANUMERIC_3 = '3',
77  ALPHANUMERIC_4 = '4',
78  ALPHANUMERIC_5 = '5',
79  ALPHANUMERIC_6 = '6',
80  ALPHANUMERIC_7 = '7',
81  ALPHANUMERIC_8 = '8',
82  ALPHANUMERIC_9 = '9',
83  COLON = ':',
84  SEMICOLON = ';',
85  LESS = '<',
86  EQUALS = '=',
87  GREATER = '>',
88  QUESTION = '?',
89  AT = '@',
90  /*
91  Skip uppercase letters
92  */
93  LEFTBRACKET = '[',
94  BACKSLASH = '\\',
95  RIGHTBRACKET = ']',
96  CARET = '^',
97  UNDERSCORE = '_',
98  BACKQUOTE = '`',
99  a = 'a',
100  b = 'b',
101  c = 'c',
102  d = 'd',
103  e = 'e',
104  f = 'f',
105  g = 'g',
106  h = 'h',
107  i = 'i',
108  j = 'j',
109  k = 'k',
110  l = 'l',
111  m = 'm',
112  n = 'n',
113  o = 'o',
114  p = 'p',
115  q = 'q',
116  r = 'r',
117  s = 's',
118  t = 't',
119  u = 'u',
120  v = 'v',
121  w = 'w',
122  x = 'x',
123  y = 'y',
124  z = 'z',
125 
127 
140 
147  DELETE = '\177',
154 
172 
205 
218 
274 
283 
285 
303 
314 };
315 
318 
319 #ifndef SWIG
320 
323 enum class Keymod
324 {
325  NONE = 0x0000,
326 
327  LSHIFT = 0x0001,
328  RSHIFT = 0x0002,
329  SHIFT = LSHIFT | RSHIFT,
330 
331  LCTRL = 0x0040,
332  RCTRL = 0x0080,
333  CTRL = LCTRL | RCTRL,
334 
335  LALT = 0x0100,
336  RALT = 0x0200,
337  ALT = LALT | RALT,
338 
339  LGUI = 0x0400,
340  RGUI = 0x0800,
341  GUI = LGUI | RGUI,
342 
343  NUM = 0x1000,
344  CAPS = 0x2000,
345  MODE = 0x4000,
346  RESERVED = 0x8000
347 };
348 inline bool operator&(const Keymod& left, const Keymod& right) {
349  return (static_cast<int>(left) & static_cast<int>(right)) != 0;
350 }
351 #endif // SWIG
352 
353 } // namespace input
354 } // namespace ugdk
355 
356 #endif // UGDK_INPUT_KEYCODE_H_
#define UGDK_SCANCODE_TO_KEYCODE(X)
Definition: keycode.h:39
Keymod
Enumeration of valid key mods (possibly OR'd together).
Definition: keycode.h:323
Definition: animation.h:11
Scancode
The SDL keyboard scancode representation.
Definition: scancode.h:45
Scancode CreateScancodeFromKeycode(const Keycode &)
Keycode CreateKeycodeFromScancode(const Scancode &)
Keycode
The SDL virtual key representation.
Definition: keycode.h:49
bool operator&(const Keymod &left, const Keymod &right)
Definition: keycode.h:348