ovr_sdk

view LibOVR/Src/Kernel/OVR_KeyCodes.h @ 0:1b39a1b46319

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