KeyCode.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation
  6. files (the "Software"), to deal in the Software without
  7. restriction, including without limitation the rights to use,
  8. copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following
  11. conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #pragma once
  24. namespace crown
  25. {
  26. /// Uniquely identifies a button on the keyboard.
  27. struct KeyboardButton
  28. {
  29. enum Enum
  30. {
  31. NONE = 0x00,
  32. TAB = 0x09, // ASCII value
  33. ENTER = 0x0D, // ASCII value
  34. ESCAPE = 0x1B, // ASCII value
  35. SPACE = 0x20, // ASCII value
  36. BACKSPACE = 0x7F, // ASCII value
  37. /* KeyPad */
  38. KP_0 = 0x80,
  39. KP_1 = 0x81,
  40. KP_2 = 0x82,
  41. KP_3 = 0x83,
  42. KP_4 = 0x84,
  43. KP_5 = 0x85,
  44. KP_6 = 0x86,
  45. KP_7 = 0x87,
  46. KP_8 = 0x88,
  47. KP_9 = 0x89,
  48. /* Function keys */
  49. F1 = 0x90,
  50. F2 = 0x91,
  51. F3 = 0x92,
  52. F4 = 0x93,
  53. F5 = 0x94,
  54. F6 = 0x95,
  55. F7 = 0x96,
  56. F8 = 0x97,
  57. F9 = 0x98,
  58. F10 = 0x99,
  59. F11 = 0x9A,
  60. F12 = 0x9B,
  61. /* Other keys */
  62. HOME = 0xA0,
  63. LEFT = 0xA1,
  64. UP = 0xA2,
  65. RIGHT = 0xA3,
  66. DOWN = 0xA4,
  67. PAGE_UP = 0xA5,
  68. PAGE_DOWN = 0xA6,
  69. /* Modifier keys */
  70. LCONTROL = 0xB0,
  71. RCONTROL = 0xB1,
  72. LSHIFT = 0xB2,
  73. RSHIFT = 0xB3,
  74. CAPS_LOCK = 0xB4,
  75. LALT = 0xB5,
  76. RALT = 0xB6,
  77. LSUPER = 0xB7,
  78. RSUPER = 0xB8,
  79. /* [0x30, 0x39] reserved for ASCII digits */
  80. NUM_0 = 0x30,
  81. NUM_1 = 0x31,
  82. NUM_2 = 0x32,
  83. NUM_3 = 0x33,
  84. NUM_4 = 0x34,
  85. NUM_5 = 0x35,
  86. NUM_6 = 0x36,
  87. NUM_7 = 0x37,
  88. NUM_8 = 0x38,
  89. NUM_9 = 0x39,
  90. /* [0x41, 0x5A] reserved for ASCII alphabet */
  91. A = 0x41,
  92. B = 0x42,
  93. C = 0x43,
  94. D = 0x44,
  95. E = 0x45,
  96. F = 0x46,
  97. G = 0x47,
  98. H = 0x48,
  99. I = 0x49,
  100. J = 0x4A,
  101. K = 0x4B,
  102. L = 0x4C,
  103. M = 0x4D,
  104. N = 0x4E,
  105. O = 0x4F,
  106. P = 0x50,
  107. Q = 0x51,
  108. R = 0x52,
  109. S = 0x53,
  110. T = 0x54,
  111. U = 0x55,
  112. V = 0x56,
  113. W = 0x57,
  114. X = 0x58,
  115. Y = 0x59,
  116. Z = 0x5A,
  117. /* [0x61, 0x7A] reserved for ASCII alphabet */
  118. a = 0x61,
  119. b = 0x62,
  120. c = 0x63,
  121. d = 0x64,
  122. e = 0x65,
  123. f = 0x66,
  124. g = 0x67,
  125. h = 0x68,
  126. i = 0x69,
  127. j = 0x6A,
  128. k = 0x6B,
  129. l = 0x6C,
  130. m = 0x6D,
  131. n = 0x6E,
  132. o = 0x6F,
  133. p = 0x70,
  134. q = 0x71,
  135. r = 0x72,
  136. s = 0x73,
  137. t = 0x74,
  138. u = 0x75,
  139. v = 0x76,
  140. w = 0x77,
  141. x = 0x78,
  142. y = 0x79,
  143. z = 0x7A,
  144. // The last key _must_ be <= 0xFF
  145. COUNT = 0xFF
  146. };
  147. };
  148. } // namespace crown