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