OVR_KeyCodes.h 6.4 KB

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