usbkeyboardmap.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //*****************************************************************************
  2. //
  3. // usbkeyboardmap.c - This file holds the table to enable USB keyboard usage
  4. // identifiers to be mapped to printable characters.
  5. //
  6. // Copyright (c) 2008-2011 Texas Instruments Incorporated. All rights reserved.
  7. // Software License Agreement
  8. //
  9. // Texas Instruments (TI) is supplying this software for use solely and
  10. // exclusively on TI's microcontroller products. The software is owned by
  11. // TI and/or its suppliers, and is protected under applicable copyright
  12. // laws. You may not combine this software with "viral" open-source
  13. // software in order to form a larger program.
  14. //
  15. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  16. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  17. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  19. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  20. // DAMAGES, FOR ANY REASON WHATSOEVER.
  21. //
  22. // This is part of revision 8049 of the Stellaris USB Library.
  23. //
  24. //*****************************************************************************
  25. #include "hw_types.h"
  26. #include "usblib.h"
  27. #include "usbhid.h"
  28. //*****************************************************************************
  29. //
  30. // This is the array that hold the unshifted and shifted ASCII character for
  31. // each usage ID.
  32. //
  33. //*****************************************************************************
  34. const unsigned char g_pucKeyBoardMap[USBH_HID_MAX_USAGE][2] =
  35. {
  36. //
  37. // Usage ID to character mapping Usage ID CAPS Lock
  38. //
  39. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 0 - 3 0
  40. {'a', 'A'}, {'b', 'B'}, {'c', 'C'}, {'d', 'D'}, // 4 - 7 f
  41. {'e', 'E'}, {'f', 'F'}, {'g', 'G'}, {'h', 'H'}, // 8 - 11 f
  42. {'i', 'I'}, {'j', 'J'}, {'k', 'K'}, {'l', 'L'}, // 12 - 15 f
  43. {'m', 'M'}, {'n', 'N'}, {'o', 'O'}, {'p', 'P'}, // 16 - 19 f
  44. {'q', 'Q'}, {'r', 'R'}, {'s', 'S'}, {'t', 'T'}, // 20 - 23 f
  45. {'u', 'U'}, {'v', 'V'}, {'w', 'W'}, {'x', 'X'}, // 24 - 27 f
  46. {'y', 'Y'}, {'z', 'Z'}, {'1', '!'}, {'2', '@'}, // 28 - 31 3
  47. {'3', '#'}, {'4', '$'}, {'5', '%'}, {'6', '^'}, // 32 - 35 0
  48. {'7', '&'}, {'8', '*'}, {'9', '('}, {'0', ')'}, // 36 - 39 0
  49. {'\n', '\n'}, {0, 0}, {0, 0}, {'\t', '\t'}, // 40 - 43 0
  50. {' ', ' '}, {'-', '_'}, {'=', '+'}, {'[', '{'}, // 44 - 47 0
  51. {']', '}'}, {'\\', '|'},{'`', '~'}, {';', ':'}, // 48 - 51 0
  52. {'\'', '"'}, {'`', '~'}, {',', '<'}, {'.', '>'},// 52 - 55 0
  53. {'/', '?'}, {0, 0}, {0, 0}, {0, 0}, // 56 - 59 0
  54. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 60 - 63 0
  55. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 64 - 67 0
  56. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 68 - 71 0
  57. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 72 - 75 0
  58. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 76 - 79 0
  59. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 80 - 83 0
  60. {'/', '/'}, {'*', '*'}, {'-', '-'}, {'+', '+'}, // 84 - 87 0
  61. {'\n', '\n'}, {'1', 0}, {'2', 0}, {'3', 0}, // 88 - 91 0
  62. {'4', 0}, {'5', 0}, {'6', 0}, {'7', 0}, // 92 - 95 0
  63. {'8', 0}, {'9', 0}, {'0', 0}, {'.', 0}, // 96 - 99 0
  64. {'\\', '|'},{0, 0}, {0, 0}, {'=', '+'}, // 100 - 103 0
  65. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 104 - 107 0
  66. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 108 - 111 0
  67. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 112 - 115 0
  68. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 116 - 119 0
  69. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 120 - 123 0
  70. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 124 - 127 0
  71. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 128 - 131 0
  72. {0, 0}, {',', ','}, {'=', '='}, {0, 0}, // 132 - 135 0
  73. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 136 - 139 0
  74. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 140 - 143 0
  75. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 144 - 147 0
  76. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 148 - 151 0
  77. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 152 - 155 0
  78. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 156 - 159 0
  79. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 160 - 163 0
  80. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 164 - 167 0
  81. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 168 - 171 0
  82. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 172 - 175 0
  83. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 174 - 179 0
  84. {0, 0}, {0, 0}, {'(', '('}, {')', ')'}, // 180 - 183 0
  85. {'{', '{'}, {'}', '}'}, {'\t', '\t'}, {0, 0}, // 184 - 187 0
  86. {'A', 'A'}, {'B', 'B'}, {'C', 'C'}, {'D', 'D'}, // 188 - 191 0
  87. {'E', 'E'}, {'F', 'F'}, {0, 0}, {'^', '^'}, // 192 - 195 0
  88. {'%', '%'}, {'<', '<'}, {'>', '>'}, {'&', '&'}, // 196 - 199 0
  89. {'&', '&'}, {'|', '|'}, {'|', '|'}, {':', ':'}, // 200 - 203 0
  90. {'#', '#'}, {' ', ' '}, {'@', '@'}, {'!', '!'}, // 204 - 207 0
  91. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 208 - 211 0
  92. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 212 - 215 0
  93. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 216 - 219 0
  94. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 220 - 223 0
  95. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 224 - 227 0
  96. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 228 - 231 0
  97. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 232 - 235 0
  98. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 236 - 239 0
  99. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 240 - 243 0
  100. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 244 - 247 0
  101. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 248 - 251 0
  102. {0, 0}, {0, 0}, {0, 0}, {0, 0}, // 252 - 255 0
  103. };
  104. //*****************************************************************************
  105. //
  106. // This is the structure that defines the mapping of USB usage IDs to ASCII
  107. // values for printing.
  108. //
  109. //*****************************************************************************
  110. const tHIDKeyboardUsageTable g_sUSKeyboardMap =
  111. {
  112. //
  113. // One byte per character.
  114. //
  115. 1,
  116. //
  117. // Packed bit array of usages codes that are effected by Caps Lock state.
  118. //
  119. {
  120. 0x3ffffff0, // Alpha characters are only one affected by CAPS LOCK
  121. 0x00000000,
  122. 0x00000000,
  123. 0x00000000,
  124. 0x00000000,
  125. 0x00000000,
  126. 0x00000000,
  127. 0x00000000,
  128. },
  129. //
  130. // The large table of the direct mapping of usage id's to ascii characters.
  131. //
  132. (void *)g_pucKeyBoardMap
  133. };