rev |
line source |
nuclear@0
|
1 /************************************************************************************
|
nuclear@0
|
2
|
nuclear@0
|
3 PublicHeader: OVR_Kernel.h
|
nuclear@0
|
4 Filename : OVR_KeyCodes.h
|
nuclear@0
|
5 Content : Common keyboard constants
|
nuclear@0
|
6 Created : September 19, 2012
|
nuclear@0
|
7
|
nuclear@0
|
8 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
|
nuclear@0
|
9
|
nuclear@0
|
10 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
|
nuclear@0
|
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
|
nuclear@0
|
12 which is provided at the time of installation or download, or which
|
nuclear@0
|
13 otherwise accompanies this software in either electronic or hard copy form.
|
nuclear@0
|
14
|
nuclear@0
|
15 You may obtain a copy of the License at
|
nuclear@0
|
16
|
nuclear@0
|
17 http://www.oculusvr.com/licenses/LICENSE-3.2
|
nuclear@0
|
18
|
nuclear@0
|
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
|
nuclear@0
|
20 distributed under the License is distributed on an "AS IS" BASIS,
|
nuclear@0
|
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
nuclear@0
|
22 See the License for the specific language governing permissions and
|
nuclear@0
|
23 limitations under the License.
|
nuclear@0
|
24
|
nuclear@0
|
25 ************************************************************************************/
|
nuclear@0
|
26
|
nuclear@0
|
27 #ifndef OVR_KeyCodes_h
|
nuclear@0
|
28 #define OVR_KeyCodes_h
|
nuclear@0
|
29
|
nuclear@0
|
30 namespace OVR {
|
nuclear@0
|
31
|
nuclear@0
|
32 //-----------------------------------------------------------------------------------
|
nuclear@0
|
33 // ***** KeyCode
|
nuclear@0
|
34
|
nuclear@0
|
35 // KeyCode enumeration defines platform-independent keyboard key constants.
|
nuclear@0
|
36 // Note that Key_A through Key_Z are mapped to capital ascii constants.
|
nuclear@0
|
37
|
nuclear@0
|
38 enum KeyCode
|
nuclear@0
|
39 {
|
nuclear@0
|
40 // Key_None indicates that no key was specified.
|
nuclear@0
|
41 Key_None = 0,
|
nuclear@0
|
42
|
nuclear@0
|
43 // A through Z and numbers 0 through 9.
|
nuclear@0
|
44 Key_A = 65,
|
nuclear@0
|
45 Key_B,
|
nuclear@0
|
46 Key_C,
|
nuclear@0
|
47 Key_D,
|
nuclear@0
|
48 Key_E,
|
nuclear@0
|
49 Key_F,
|
nuclear@0
|
50 Key_G,
|
nuclear@0
|
51 Key_H,
|
nuclear@0
|
52 Key_I,
|
nuclear@0
|
53 Key_J,
|
nuclear@0
|
54 Key_K,
|
nuclear@0
|
55 Key_L,
|
nuclear@0
|
56 Key_M,
|
nuclear@0
|
57 Key_N,
|
nuclear@0
|
58 Key_O,
|
nuclear@0
|
59 Key_P,
|
nuclear@0
|
60 Key_Q,
|
nuclear@0
|
61 Key_R,
|
nuclear@0
|
62 Key_S,
|
nuclear@0
|
63 Key_T,
|
nuclear@0
|
64 Key_U,
|
nuclear@0
|
65 Key_V,
|
nuclear@0
|
66 Key_W,
|
nuclear@0
|
67 Key_X,
|
nuclear@0
|
68 Key_Y,
|
nuclear@0
|
69 Key_Z,
|
nuclear@0
|
70 Key_Num0 = 48,
|
nuclear@0
|
71 Key_Num1,
|
nuclear@0
|
72 Key_Num2,
|
nuclear@0
|
73 Key_Num3,
|
nuclear@0
|
74 Key_Num4,
|
nuclear@0
|
75 Key_Num5,
|
nuclear@0
|
76 Key_Num6,
|
nuclear@0
|
77 Key_Num7,
|
nuclear@0
|
78 Key_Num8,
|
nuclear@0
|
79 Key_Num9,
|
nuclear@0
|
80
|
nuclear@0
|
81 // Numeric keypad.
|
nuclear@0
|
82 Key_KP_0 = 0xa0,
|
nuclear@0
|
83 Key_KP_1,
|
nuclear@0
|
84 Key_KP_2,
|
nuclear@0
|
85 Key_KP_3,
|
nuclear@0
|
86 Key_KP_4,
|
nuclear@0
|
87 Key_KP_5,
|
nuclear@0
|
88 Key_KP_6,
|
nuclear@0
|
89 Key_KP_7,
|
nuclear@0
|
90 Key_KP_8,
|
nuclear@0
|
91 Key_KP_9,
|
nuclear@0
|
92 Key_KP_Multiply,
|
nuclear@0
|
93 Key_KP_Add,
|
nuclear@0
|
94 Key_KP_Enter,
|
nuclear@0
|
95 Key_KP_Subtract,
|
nuclear@0
|
96 Key_KP_Decimal,
|
nuclear@0
|
97 Key_KP_Divide,
|
nuclear@0
|
98
|
nuclear@0
|
99 // Function keys.
|
nuclear@0
|
100 Key_F1 = 0xb0,
|
nuclear@0
|
101 Key_F2,
|
nuclear@0
|
102 Key_F3,
|
nuclear@0
|
103 Key_F4,
|
nuclear@0
|
104 Key_F5,
|
nuclear@0
|
105 Key_F6,
|
nuclear@0
|
106 Key_F7,
|
nuclear@0
|
107 Key_F8,
|
nuclear@0
|
108 Key_F9,
|
nuclear@0
|
109 Key_F10,
|
nuclear@0
|
110 Key_F11,
|
nuclear@0
|
111 Key_F12,
|
nuclear@0
|
112 Key_F13,
|
nuclear@0
|
113 Key_F14,
|
nuclear@0
|
114 Key_F15,
|
nuclear@0
|
115
|
nuclear@0
|
116 // Other keys.
|
nuclear@0
|
117 Key_Backspace = 8,
|
nuclear@0
|
118 Key_Tab,
|
nuclear@0
|
119 Key_Clear = 12,
|
nuclear@0
|
120 Key_Return,
|
nuclear@0
|
121 Key_Shift = 16,
|
nuclear@0
|
122 Key_Control,
|
nuclear@0
|
123 Key_Alt,
|
nuclear@0
|
124 Key_Pause,
|
nuclear@0
|
125 Key_CapsLock = 20, // Toggle
|
nuclear@0
|
126 Key_Escape = 27,
|
nuclear@0
|
127 Key_Space = 32,
|
nuclear@0
|
128 Key_Quote = 39,
|
nuclear@0
|
129 Key_PageUp = 0xc0,
|
nuclear@0
|
130 Key_PageDown,
|
nuclear@0
|
131 Key_End,
|
nuclear@0
|
132 Key_Home,
|
nuclear@0
|
133 Key_Left,
|
nuclear@0
|
134 Key_Up,
|
nuclear@0
|
135 Key_Right,
|
nuclear@0
|
136 Key_Down,
|
nuclear@0
|
137 Key_Insert,
|
nuclear@0
|
138 Key_Delete,
|
nuclear@0
|
139 Key_Help,
|
nuclear@0
|
140
|
nuclear@0
|
141 Key_Comma = 44,
|
nuclear@0
|
142 Key_Minus,
|
nuclear@0
|
143 Key_Slash = 47,
|
nuclear@0
|
144 Key_Period,
|
nuclear@0
|
145 Key_NumLock = 144, // Toggle
|
nuclear@0
|
146 Key_ScrollLock = 145, // Toggle
|
nuclear@0
|
147
|
nuclear@0
|
148 Key_Semicolon = 59,
|
nuclear@0
|
149 Key_Equal = 61,
|
nuclear@0
|
150 Key_Backtick = 96, // ` and tilda~ when shifted (US keyboard)
|
nuclear@0
|
151 Key_BracketLeft = 91,
|
nuclear@0
|
152 Key_Backslash,
|
nuclear@0
|
153 Key_BracketRight,
|
nuclear@0
|
154
|
nuclear@0
|
155 Key_OEM_AX = 0xE1, // 'AX' key on Japanese AX keyboard
|
nuclear@0
|
156 Key_OEM_102 = 0xE2, // "<>" or "\|" on RT 102-key keyboard.
|
nuclear@0
|
157 Key_ICO_HELP = 0xE3, // Help key on ICO
|
nuclear@0
|
158 Key_ICO_00 = 0xE4, // 00 key on ICO
|
nuclear@0
|
159
|
nuclear@0
|
160 Key_Meta,
|
nuclear@0
|
161
|
nuclear@0
|
162 // Total number of keys.
|
nuclear@0
|
163 Key_CodeCount
|
nuclear@0
|
164 };
|
nuclear@0
|
165
|
nuclear@0
|
166
|
nuclear@0
|
167 //-----------------------------------------------------------------------------------
|
nuclear@0
|
168
|
nuclear@0
|
169 class KeyModifiers
|
nuclear@0
|
170 {
|
nuclear@0
|
171 public:
|
nuclear@0
|
172 enum
|
nuclear@0
|
173 {
|
nuclear@0
|
174 Key_ShiftPressed = 0x01,
|
nuclear@0
|
175 Key_CtrlPressed = 0x02,
|
nuclear@0
|
176 Key_AltPressed = 0x04,
|
nuclear@0
|
177 Key_MetaPressed = 0x08,
|
nuclear@0
|
178 Key_CapsToggled = 0x10,
|
nuclear@0
|
179 Key_NumToggled = 0x20,
|
nuclear@0
|
180 Key_ScrollToggled = 0x40,
|
nuclear@0
|
181
|
nuclear@0
|
182 Initialized_Bit = 0x80,
|
nuclear@0
|
183 Initialized_Mask = 0xFF
|
nuclear@0
|
184 };
|
nuclear@0
|
185 unsigned char States;
|
nuclear@0
|
186
|
nuclear@0
|
187 KeyModifiers() : States(0) { }
|
nuclear@0
|
188 KeyModifiers(unsigned char st) : States((unsigned char)(st | Initialized_Bit)) { }
|
nuclear@0
|
189
|
nuclear@0
|
190 void Reset() { States = 0; }
|
nuclear@0
|
191
|
nuclear@0
|
192 bool IsShiftPressed() const { return (States & Key_ShiftPressed) != 0; }
|
nuclear@0
|
193 bool IsCtrlPressed() const { return (States & Key_CtrlPressed) != 0; }
|
nuclear@0
|
194 bool IsAltPressed() const { return (States & Key_AltPressed) != 0; }
|
nuclear@0
|
195 bool IsMetaPressed() const { return (States & Key_MetaPressed) != 0; }
|
nuclear@0
|
196 bool IsCapsToggled() const { return (States & Key_CapsToggled) != 0; }
|
nuclear@0
|
197 bool IsNumToggled() const { return (States & Key_NumToggled) != 0; }
|
nuclear@0
|
198 bool IsScrollToggled() const{ return (States & Key_ScrollToggled) != 0; }
|
nuclear@0
|
199
|
nuclear@0
|
200 void SetShiftPressed(bool v = true) { (v) ? States |= Key_ShiftPressed : States &= ~Key_ShiftPressed; }
|
nuclear@0
|
201 void SetCtrlPressed(bool v = true) { (v) ? States |= Key_CtrlPressed : States &= ~Key_CtrlPressed; }
|
nuclear@0
|
202 void SetAltPressed(bool v = true) { (v) ? States |= Key_AltPressed : States &= ~Key_AltPressed; }
|
nuclear@0
|
203 void SetMetaPressed(bool v = true) { (v) ? States |= Key_MetaPressed : States &= ~Key_MetaPressed; }
|
nuclear@0
|
204 void SetCapsToggled(bool v = true) { (v) ? States |= Key_CapsToggled : States &= ~Key_CapsToggled; }
|
nuclear@0
|
205 void SetNumToggled(bool v = true) { (v) ? States |= Key_NumToggled : States &= ~Key_NumToggled; }
|
nuclear@0
|
206 void SetScrollToggled(bool v = true) { (v) ? States |= Key_ScrollToggled: States &= ~Key_ScrollToggled; }
|
nuclear@0
|
207
|
nuclear@0
|
208 bool IsInitialized() const { return (States & Initialized_Mask) != 0; }
|
nuclear@0
|
209 };
|
nuclear@0
|
210
|
nuclear@0
|
211
|
nuclear@0
|
212 //-----------------------------------------------------------------------------------
|
nuclear@0
|
213
|
nuclear@0
|
214 /*
|
nuclear@0
|
215 enum PadKeyCode
|
nuclear@0
|
216 {
|
nuclear@0
|
217 Pad_None, // Indicates absence of key code.
|
nuclear@0
|
218 Pad_Back,
|
nuclear@0
|
219 Pad_Start,
|
nuclear@0
|
220 Pad_A,
|
nuclear@0
|
221 Pad_B,
|
nuclear@0
|
222 Pad_X,
|
nuclear@0
|
223 Pad_Y,
|
nuclear@0
|
224 Pad_R1, // RightShoulder;
|
nuclear@0
|
225 Pad_L1, // LeftShoulder;
|
nuclear@0
|
226 Pad_R2, // RightTrigger;
|
nuclear@0
|
227 Pad_L2, // LeftTrigger;
|
nuclear@0
|
228 Pad_Up,
|
nuclear@0
|
229 Pad_Down,
|
nuclear@0
|
230 Pad_Right,
|
nuclear@0
|
231 Pad_Left,
|
nuclear@0
|
232 Pad_Plus,
|
nuclear@0
|
233 Pad_Minus,
|
nuclear@0
|
234 Pad_1,
|
nuclear@0
|
235 Pad_2,
|
nuclear@0
|
236 Pad_H,
|
nuclear@0
|
237 Pad_C,
|
nuclear@0
|
238 Pad_Z,
|
nuclear@0
|
239 Pad_O,
|
nuclear@0
|
240 Pad_T,
|
nuclear@0
|
241 Pad_S,
|
nuclear@0
|
242 Pad_Select,
|
nuclear@0
|
243 Pad_Home,
|
nuclear@0
|
244 Pad_RT, // RightThumb;
|
nuclear@0
|
245 Pad_LT // LeftThumb;
|
nuclear@0
|
246 };
|
nuclear@0
|
247 */
|
nuclear@0
|
248
|
nuclear@0
|
249 } // OVR
|
nuclear@0
|
250
|
nuclear@0
|
251 #endif
|