oculus1
view libovr/Src/Kernel/OVR_KeyCodes.h @ 17:cfe4979ab3eb
ops, minor error in the last commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 21 Sep 2013 07:09:48 +0300 |
parents | e2f9e4603129 |
children |
line source
1 /************************************************************************************
3 PublicHeader: OVR.h
4 Filename : OVR_KeyCodes.h
5 Content : Common keyboard constants
6 Created : September 19, 2012
8 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
10 Use of this software is subject to the terms of the Oculus license
11 agreement provided at the time of installation or download, or which
12 otherwise accompanies this software in either electronic or hard copy form.
14 ************************************************************************************/
16 #ifndef OVR_KeyCodes_h
17 #define OVR_KeyCodes_h
19 namespace OVR {
21 //-----------------------------------------------------------------------------------
22 // ***** KeyCode
24 // KeyCode enumeration defines platform-independent keyboard key constants.
25 // Note that Key_A through Key_Z are mapped to capital ascii constants.
27 enum KeyCode
28 {
29 // Key_None indicates that no key was specified.
30 Key_None = 0,
32 // A through Z and numbers 0 through 9.
33 Key_A = 65,
34 Key_B,
35 Key_C,
36 Key_D,
37 Key_E,
38 Key_F,
39 Key_G,
40 Key_H,
41 Key_I,
42 Key_J,
43 Key_K,
44 Key_L,
45 Key_M,
46 Key_N,
47 Key_O,
48 Key_P,
49 Key_Q,
50 Key_R,
51 Key_S,
52 Key_T,
53 Key_U,
54 Key_V,
55 Key_W,
56 Key_X,
57 Key_Y,
58 Key_Z,
59 Key_Num0 = 48,
60 Key_Num1,
61 Key_Num2,
62 Key_Num3,
63 Key_Num4,
64 Key_Num5,
65 Key_Num6,
66 Key_Num7,
67 Key_Num8,
68 Key_Num9,
70 // Numeric keypad.
71 Key_KP_0 = 0xa0,
72 Key_KP_1,
73 Key_KP_2,
74 Key_KP_3,
75 Key_KP_4,
76 Key_KP_5,
77 Key_KP_6,
78 Key_KP_7,
79 Key_KP_8,
80 Key_KP_9,
81 Key_KP_Multiply,
82 Key_KP_Add,
83 Key_KP_Enter,
84 Key_KP_Subtract,
85 Key_KP_Decimal,
86 Key_KP_Divide,
88 // Function keys.
89 Key_F1 = 0xb0,
90 Key_F2,
91 Key_F3,
92 Key_F4,
93 Key_F5,
94 Key_F6,
95 Key_F7,
96 Key_F8,
97 Key_F9,
98 Key_F10,
99 Key_F11,
100 Key_F12,
101 Key_F13,
102 Key_F14,
103 Key_F15,
105 // Other keys.
106 Key_Backspace = 8,
107 Key_Tab,
108 Key_Clear = 12,
109 Key_Return,
110 Key_Shift = 16,
111 Key_Control,
112 Key_Alt,
113 Key_Pause,
114 Key_CapsLock = 20, // Toggle
115 Key_Escape = 27,
116 Key_Space = 32,
117 Key_Quote = 39,
118 Key_PageUp = 0xc0,
119 Key_PageDown,
120 Key_End,
121 Key_Home,
122 Key_Left,
123 Key_Up,
124 Key_Right,
125 Key_Down,
126 Key_Insert,
127 Key_Delete,
128 Key_Help,
130 Key_Comma = 44,
131 Key_Minus,
132 Key_Slash = 47,
133 Key_Period,
134 Key_NumLock = 144, // Toggle
135 Key_ScrollLock = 145, // Toggle
137 Key_Semicolon = 59,
138 Key_Equal = 61,
139 Key_Bar = 192,
140 Key_BracketLeft = 91,
141 Key_Backslash,
142 Key_BracketRight,
144 Key_OEM_AX = 0xE1, // 'AX' key on Japanese AX keyboard
145 Key_OEM_102 = 0xE2, // "<>" or "\|" on RT 102-key keyboard.
146 Key_ICO_HELP = 0xE3, // Help key on ICO
147 Key_ICO_00 = 0xE4, // 00 key on ICO
149 Key_Meta,
151 // Total number of keys.
152 Key_CodeCount
153 };
156 //-----------------------------------------------------------------------------------
158 class KeyModifiers
159 {
160 public:
161 enum
162 {
163 Key_ShiftPressed = 0x01,
164 Key_CtrlPressed = 0x02,
165 Key_AltPressed = 0x04,
166 Key_MetaPressed = 0x08,
167 Key_CapsToggled = 0x10,
168 Key_NumToggled = 0x20,
169 Key_ScrollToggled = 0x40,
171 Initialized_Bit = 0x80,
172 Initialized_Mask = 0xFF
173 };
174 unsigned char States;
176 KeyModifiers() : States(0) { }
177 KeyModifiers(unsigned char st) : States((unsigned char)(st | Initialized_Bit)) { }
179 void Reset() { States = 0; }
181 bool IsShiftPressed() const { return (States & Key_ShiftPressed) != 0; }
182 bool IsCtrlPressed() const { return (States & Key_CtrlPressed) != 0; }
183 bool IsAltPressed() const { return (States & Key_AltPressed) != 0; }
184 bool IsMetaPressed() const { return (States & Key_MetaPressed) != 0; }
185 bool IsCapsToggled() const { return (States & Key_CapsToggled) != 0; }
186 bool IsNumToggled() const { return (States & Key_NumToggled) != 0; }
187 bool IsScrollToggled() const{ return (States & Key_ScrollToggled) != 0; }
189 void SetShiftPressed(bool v = true) { (v) ? States |= Key_ShiftPressed : States &= ~Key_ShiftPressed; }
190 void SetCtrlPressed(bool v = true) { (v) ? States |= Key_CtrlPressed : States &= ~Key_CtrlPressed; }
191 void SetAltPressed(bool v = true) { (v) ? States |= Key_AltPressed : States &= ~Key_AltPressed; }
192 void SetMetaPressed(bool v = true) { (v) ? States |= Key_MetaPressed : States &= ~Key_MetaPressed; }
193 void SetCapsToggled(bool v = true) { (v) ? States |= Key_CapsToggled : States &= ~Key_CapsToggled; }
194 void SetNumToggled(bool v = true) { (v) ? States |= Key_NumToggled : States &= ~Key_NumToggled; }
195 void SetScrollToggled(bool v = true) { (v) ? States |= Key_ScrollToggled: States &= ~Key_ScrollToggled; }
197 bool IsInitialized() const { return (States & Initialized_Mask) != 0; }
198 };
201 //-----------------------------------------------------------------------------------
203 /*
204 enum PadKeyCode
205 {
206 Pad_None, // Indicates absence of key code.
207 Pad_Back,
208 Pad_Start,
209 Pad_A,
210 Pad_B,
211 Pad_X,
212 Pad_Y,
213 Pad_R1, // RightShoulder;
214 Pad_L1, // LeftShoulder;
215 Pad_R2, // RightTrigger;
216 Pad_L2, // LeftTrigger;
217 Pad_Up,
218 Pad_Down,
219 Pad_Right,
220 Pad_Left,
221 Pad_Plus,
222 Pad_Minus,
223 Pad_1,
224 Pad_2,
225 Pad_H,
226 Pad_C,
227 Pad_Z,
228 Pad_O,
229 Pad_T,
230 Pad_S,
231 Pad_Select,
232 Pad_Home,
233 Pad_RT, // RightThumb;
234 Pad_LT // LeftThumb;
235 };
236 */
238 } // OVR
240 #endif