OVR_KeyCodes.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 PublicHeader:   OVR.h
00004 Filename    :   OVR_KeyCodes.h
00005 Content     :   Common keyboard constants
00006 Created     :   September 19, 2012
00007 
00008 Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
00009 
00010 Use of this software is subject to the terms of the Oculus license
00011 agreement provided at the time of installation or download, or which
00012 otherwise accompanies this software in either electronic or hard copy form.
00013 
00014 ************************************************************************************/
00015 
00016 #ifndef OVR_KeyCodes_h
00017 #define OVR_KeyCodes_h
00018 
00019 namespace OVR {
00020 
00021 //-----------------------------------------------------------------------------------
00022 // ***** KeyCode
00023 
00024 // KeyCode enumeration defines platform-independent keyboard key constants.
00025 // Note that Key_A through Key_Z are mapped to capital ascii constants.
00026 
00027 enum KeyCode
00028 {
00029     // Key_None indicates that no key was specified.
00030     Key_None            = 0, 
00031 
00032     // A through Z and numbers 0 through 9.
00033     Key_A               = 65,
00034     Key_B,
00035     Key_C,
00036     Key_D,
00037     Key_E,
00038     Key_F,
00039     Key_G,
00040     Key_H,
00041     Key_I,
00042     Key_J,
00043     Key_K,
00044     Key_L,
00045     Key_M,
00046     Key_N,
00047     Key_O,
00048     Key_P,
00049     Key_Q,
00050     Key_R,
00051     Key_S,
00052     Key_T,
00053     Key_U,
00054     Key_V,
00055     Key_W,
00056     Key_X,
00057     Key_Y,
00058     Key_Z,
00059     Key_Num0            = 48,
00060     Key_Num1,
00061     Key_Num2,
00062     Key_Num3,
00063     Key_Num4,
00064     Key_Num5,
00065     Key_Num6,
00066     Key_Num7,
00067     Key_Num8,
00068     Key_Num9,
00069 
00070     // Numeric keypad.
00071     Key_KP_0            = 0xa0,
00072     Key_KP_1,
00073     Key_KP_2,
00074     Key_KP_3,
00075     Key_KP_4,
00076     Key_KP_5,
00077     Key_KP_6,
00078     Key_KP_7,
00079     Key_KP_8,
00080     Key_KP_9,
00081     Key_KP_Multiply,
00082     Key_KP_Add,
00083     Key_KP_Enter,
00084     Key_KP_Subtract,
00085     Key_KP_Decimal,
00086     Key_KP_Divide,
00087     
00088     // Function keys.
00089     Key_F1              = 0xb0,
00090     Key_F2,
00091     Key_F3,
00092     Key_F4,
00093     Key_F5,
00094     Key_F6,
00095     Key_F7,
00096     Key_F8,
00097     Key_F9,
00098     Key_F10,
00099     Key_F11,
00100     Key_F12,
00101     Key_F13,
00102     Key_F14,
00103     Key_F15,
00104     
00105     // Other keys.
00106     Key_Backspace       = 8,
00107     Key_Tab,
00108     Key_Clear           = 12,
00109     Key_Return,
00110     Key_Shift           = 16,
00111     Key_Control,
00112     Key_Alt,
00113     Key_Pause,
00114     Key_CapsLock        = 20, // Toggle
00115     Key_Escape          = 27,
00116     Key_Space           = 32,
00117     Key_Quote           = 39,
00118     Key_PageUp          = 0xc0,
00119     Key_PageDown,
00120     Key_End,
00121     Key_Home,
00122     Key_Left,
00123     Key_Up,
00124     Key_Right,
00125     Key_Down,
00126     Key_Insert,
00127     Key_Delete,
00128     Key_Help,
00129     
00130     Key_Comma           = 44,
00131     Key_Minus,
00132     Key_Slash           = 47,
00133     Key_Period,
00134     Key_NumLock         = 144, // Toggle
00135     Key_ScrollLock      = 145, // Toggle
00136     
00137     Key_Semicolon       = 59,
00138     Key_Equal           = 61,
00139     Key_Bar             = 192,
00140     Key_BracketLeft     = 91,
00141     Key_Backslash,
00142     Key_BracketRight,
00143 
00144     Key_OEM_AX          = 0xE1,  //  'AX' key on Japanese AX keyboard
00145     Key_OEM_102         = 0xE2,  //  "<>" or "\|" on RT 102-key keyboard.
00146     Key_ICO_HELP        = 0xE3,  //  Help key on ICO
00147     Key_ICO_00          = 0xE4,  //  00 key on ICO
00148 
00149     Key_Meta,
00150 
00151     // Total number of keys.
00152     Key_CodeCount
00153 };
00154 
00155 
00156 //-----------------------------------------------------------------------------------
00157 
00158 class KeyModifiers 
00159 {
00160 public:
00161     enum
00162     {
00163         Key_ShiftPressed    = 0x01,
00164         Key_CtrlPressed     = 0x02,
00165         Key_AltPressed      = 0x04,
00166         Key_MetaPressed     = 0x08,
00167         Key_CapsToggled     = 0x10,
00168         Key_NumToggled      = 0x20,
00169         Key_ScrollToggled   = 0x40,
00170 
00171         Initialized_Bit     = 0x80,
00172         Initialized_Mask    = 0xFF
00173     };
00174     unsigned char States;
00175 
00176     KeyModifiers() : States(0) { }
00177         KeyModifiers(unsigned char st) : States((unsigned char)(st | Initialized_Bit)) { }
00178 
00179     void Reset() { States = 0; }
00180 
00181     bool IsShiftPressed() const { return (States & Key_ShiftPressed) != 0; }
00182     bool IsCtrlPressed() const  { return (States & Key_CtrlPressed) != 0; }
00183     bool IsAltPressed() const   { return (States & Key_AltPressed) != 0; }
00184     bool IsMetaPressed() const  { return (States & Key_MetaPressed) != 0; }
00185     bool IsCapsToggled() const  { return (States & Key_CapsToggled) != 0; }
00186     bool IsNumToggled() const   { return (States & Key_NumToggled) != 0; }
00187     bool IsScrollToggled() const{ return (States & Key_ScrollToggled) != 0; }
00188 
00189     void SetShiftPressed(bool v = true)  { (v) ? States |= Key_ShiftPressed : States &= ~Key_ShiftPressed; }
00190     void SetCtrlPressed(bool v = true)   { (v) ? States |= Key_CtrlPressed  : States &= ~Key_CtrlPressed; }
00191     void SetAltPressed(bool v = true)    { (v) ? States |= Key_AltPressed   : States &= ~Key_AltPressed; }
00192     void SetMetaPressed(bool v = true)   { (v) ? States |= Key_MetaPressed  : States &= ~Key_MetaPressed; }
00193     void SetCapsToggled(bool v = true)   { (v) ? States |= Key_CapsToggled  : States &= ~Key_CapsToggled; }
00194     void SetNumToggled(bool v = true)    { (v) ? States |= Key_NumToggled   : States &= ~Key_NumToggled; }
00195     void SetScrollToggled(bool v = true) { (v) ? States |= Key_ScrollToggled: States &= ~Key_ScrollToggled; }
00196 
00197     bool IsInitialized() const { return (States & Initialized_Mask) != 0; }
00198 };
00199 
00200 
00201 //-----------------------------------------------------------------------------------
00202 
00203 /*
00204 enum PadKeyCode
00205 {
00206     Pad_None, // Indicates absence of key code.
00207     Pad_Back,
00208     Pad_Start,
00209     Pad_A,
00210     Pad_B,
00211     Pad_X,
00212     Pad_Y,
00213     Pad_R1,  // RightShoulder;
00214     Pad_L1,  // LeftShoulder;
00215     Pad_R2,  // RightTrigger;
00216     Pad_L2,  // LeftTrigger;
00217     Pad_Up,
00218     Pad_Down,
00219     Pad_Right,
00220     Pad_Left,
00221     Pad_Plus,
00222     Pad_Minus,
00223     Pad_1,
00224     Pad_2,
00225     Pad_H,
00226     Pad_C,
00227     Pad_Z,
00228     Pad_O,
00229     Pad_T,
00230     Pad_S,
00231     Pad_Select,
00232     Pad_Home,
00233     Pad_RT,  // RightThumb;
00234     Pad_LT   // LeftThumb;
00235 };
00236 */
00237 
00238 } // OVR
00239 
00240 #endif


oculus_sdk
Author(s):
autogenerated on Mon Oct 6 2014 03:01:18