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