Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. // Simple test of USB Host Mouse/Keyboard
  2. //
  3. // This example is in the public domain
  4. #include "USBHost_t36.h"
  5. USBHost myusb;
  6. USBHub hub1(myusb);
  7. USBHub hub2(myusb);
  8. KeyboardController keyboard1(myusb);
  9. KeyboardController keyboard2(myusb);
  10. //KeyboardHIDExtrasController hidextras(myusb);
  11. USBHIDParser hid1(myusb);
  12. USBHIDParser hid2(myusb);
  13. USBHIDParser hid3(myusb);
  14. USBHIDParser hid4(myusb);
  15. USBHIDParser hid5(myusb);
  16. MouseController mouse1(myusb);
  17. JoystickController joystick1(myusb);
  18. RawHIDController rawhid1(myusb);
  19. RawHIDController rawhid2(myusb, 0xffc90004);
  20. USBDriver *drivers[] = {&hub1, &hub2,&keyboard1, &keyboard2, &joystick1, &hid1, &hid2, &hid3, &hid4, &hid5};
  21. #define CNT_DEVICES (sizeof(drivers)/sizeof(drivers[0]))
  22. const char * driver_names[CNT_DEVICES] = {"Hub1","Hub2", "KB1", "KB2", "JOY1D", "HID1", "HID2", "HID3", "HID4", "HID5"};
  23. bool driver_active[CNT_DEVICES] = {false, false, false, false};
  24. // Lets also look at HID Input devices
  25. USBHIDInput *hiddrivers[] = {&mouse1, &joystick1, &rawhid1, &rawhid2};
  26. #define CNT_HIDDEVICES (sizeof(hiddrivers)/sizeof(hiddrivers[0]))
  27. const char * hid_driver_names[CNT_DEVICES] = {"Mouse1","Joystick1", "RawHid1", "RawHid2"};
  28. bool hid_driver_active[CNT_DEVICES] = {false, false};
  29. void setup()
  30. {
  31. while (!Serial) ; // wait for Arduino Serial Monitor
  32. Serial.println("\n\nUSB Host Testing");
  33. Serial.println(sizeof(USBHub), DEC);
  34. myusb.begin();
  35. keyboard1.attachPress(OnPress);
  36. keyboard2.attachPress(OnPress);
  37. keyboard1.attachExtrasPress(OnHIDExtrasPress);
  38. keyboard1.attachExtrasRelease(OnHIDExtrasRelease);
  39. keyboard2.attachExtrasPress(OnHIDExtrasPress);
  40. keyboard2.attachExtrasRelease(OnHIDExtrasRelease);
  41. rawhid1.attachReceive(OnReceiveHidData);
  42. rawhid2.attachReceive(OnReceiveHidData);
  43. }
  44. void loop()
  45. {
  46. myusb.Task();
  47. for (uint8_t i = 0; i < CNT_DEVICES; i++) {
  48. if (*drivers[i] != driver_active[i]) {
  49. if (driver_active[i]) {
  50. Serial.printf("*** Device %s - disconnected ***\n", driver_names[i]);
  51. driver_active[i] = false;
  52. } else {
  53. Serial.printf("*** Device %s %x:%x - connected ***\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
  54. driver_active[i] = true;
  55. const uint8_t *psz = drivers[i]->manufacturer();
  56. if (psz && *psz) Serial.printf(" manufacturer: %s\n", psz);
  57. psz = drivers[i]->product();
  58. if (psz && *psz) Serial.printf(" product: %s\n", psz);
  59. psz = drivers[i]->serialNumber();
  60. if (psz && *psz) Serial.printf(" Serial: %s\n", psz);
  61. }
  62. }
  63. }
  64. for (uint8_t i = 0; i < CNT_HIDDEVICES; i++) {
  65. if (*hiddrivers[i] != hid_driver_active[i]) {
  66. if (hid_driver_active[i]) {
  67. Serial.printf("*** HID Device %s - disconnected ***\n", hid_driver_names[i]);
  68. hid_driver_active[i] = false;
  69. } else {
  70. Serial.printf("*** HID Device %s %x:%x - connected ***\n", hid_driver_names[i], hiddrivers[i]->idVendor(), hiddrivers[i]->idProduct());
  71. hid_driver_active[i] = true;
  72. const uint8_t *psz = hiddrivers[i]->manufacturer();
  73. if (psz && *psz) Serial.printf(" manufacturer: %s\n", psz);
  74. psz = hiddrivers[i]->product();
  75. if (psz && *psz) Serial.printf(" product: %s\n", psz);
  76. psz = hiddrivers[i]->serialNumber();
  77. if (psz && *psz) Serial.printf(" Serial: %s\n", psz);
  78. }
  79. }
  80. }
  81. if(mouse1.available()) {
  82. Serial.print("Mouse: buttons = ");
  83. Serial.print(mouse1.getButtons());
  84. Serial.print(", mouseX = ");
  85. Serial.print(mouse1.getMouseX());
  86. Serial.print(", mouseY = ");
  87. Serial.print(mouse1.getMouseY());
  88. Serial.print(", wheel = ");
  89. Serial.print(mouse1.getWheel());
  90. Serial.print(", wheelH = ");
  91. Serial.print(mouse1.getWheelH());
  92. Serial.println();
  93. mouse1.mouseDataClear();
  94. }
  95. if (joystick1.available()) {
  96. uint32_t axis_mask = joystick1.axisMask();
  97. Serial.print("Joystick: buttons = ");
  98. Serial.print(joystick1.getButtons(), HEX);
  99. for (uint8_t i = 0; axis_mask != 0; i++, axis_mask >>= 1) {
  100. if (axis_mask & 1) {
  101. Serial.printf(" %d:%d", i, joystick1.getAxis(i));
  102. }
  103. }
  104. Serial.println();
  105. joystick1.joystickDataClear();
  106. }
  107. // See if we have some RAW data
  108. if (rawhid1) {
  109. int ch;
  110. uint8_t buffer[64];
  111. uint8_t count_chars = 0;
  112. memset(buffer, 0, sizeof(buffer));
  113. if (Serial.available()) {
  114. while (((ch = Serial.read()) != -1) && (count_chars < sizeof(buffer))) {
  115. buffer[count_chars++] = ch;
  116. }
  117. rawhid1.sendPacket(buffer);
  118. }
  119. }
  120. }
  121. void OnPress(int key)
  122. {
  123. Serial.print("key '");
  124. switch (key) {
  125. case KEYD_UP : Serial.print("UP"); break;
  126. case KEYD_DOWN : Serial.print("DN"); break;
  127. case KEYD_LEFT : Serial.print("LEFT"); break;
  128. case KEYD_RIGHT : Serial.print("RIGHT"); break;
  129. case KEYD_INSERT : Serial.print("Ins"); break;
  130. case KEYD_DELETE : Serial.print("Del"); break;
  131. case KEYD_PAGE_UP : Serial.print("PUP"); break;
  132. case KEYD_PAGE_DOWN: Serial.print("PDN"); break;
  133. case KEYD_HOME : Serial.print("HOME"); break;
  134. case KEYD_END : Serial.print("END"); break;
  135. case KEYD_F1 : Serial.print("F1"); break;
  136. case KEYD_F2 : Serial.print("F2"); break;
  137. case KEYD_F3 : Serial.print("F3"); break;
  138. case KEYD_F4 : Serial.print("F4"); break;
  139. case KEYD_F5 : Serial.print("F5"); break;
  140. case KEYD_F6 : Serial.print("F6"); break;
  141. case KEYD_F7 : Serial.print("F7"); break;
  142. case KEYD_F8 : Serial.print("F8"); break;
  143. case KEYD_F9 : Serial.print("F9"); break;
  144. case KEYD_F10 : Serial.print("F10"); break;
  145. case KEYD_F11 : Serial.print("F11"); break;
  146. case KEYD_F12 : Serial.print("F12"); break;
  147. default: Serial.print((char)key); break;
  148. }
  149. Serial.print("' ");
  150. Serial.print(key);
  151. Serial.print(" MOD: ");
  152. if (keyboard1) {
  153. Serial.print(keyboard1.getModifiers(), HEX);
  154. Serial.print(" OEM: ");
  155. Serial.print(keyboard1.getOemKey(), HEX);
  156. Serial.print(" LEDS: ");
  157. Serial.println(keyboard1.LEDS(), HEX);
  158. } else {
  159. Serial.print(keyboard2.getModifiers(), HEX);
  160. Serial.print(" OEM: ");
  161. Serial.print(keyboard2.getOemKey(), HEX);
  162. Serial.print(" LEDS: ");
  163. Serial.println(keyboard2.LEDS(), HEX);
  164. }
  165. //Serial.print("key ");
  166. //Serial.print((char)keyboard1.getKey());
  167. //Serial.print(" ");
  168. //Serial.print((char)keyboard2.getKey());
  169. //Serial.println();
  170. }
  171. void OnHIDExtrasPress(uint32_t top, uint16_t key)
  172. {
  173. Serial.print("HID (");
  174. Serial.print(top, HEX);
  175. Serial.print(") key press:");
  176. Serial.print(key, HEX);
  177. if (top == 0xc0000) {
  178. switch (key) {
  179. case 0x20 : Serial.print(" - +10"); break;
  180. case 0x21 : Serial.print(" - +100"); break;
  181. case 0x22 : Serial.print(" - AM/PM"); break;
  182. case 0x30 : Serial.print(" - Power"); break;
  183. case 0x31 : Serial.print(" - Reset"); break;
  184. case 0x32 : Serial.print(" - Sleep"); break;
  185. case 0x33 : Serial.print(" - Sleep After"); break;
  186. case 0x34 : Serial.print(" - Sleep Mode"); break;
  187. case 0x35 : Serial.print(" - Illumination"); break;
  188. case 0x36 : Serial.print(" - Function Buttons"); break;
  189. case 0x40 : Serial.print(" - Menu"); break;
  190. case 0x41 : Serial.print(" - Menu Pick"); break;
  191. case 0x42 : Serial.print(" - Menu Up"); break;
  192. case 0x43 : Serial.print(" - Menu Down"); break;
  193. case 0x44 : Serial.print(" - Menu Left"); break;
  194. case 0x45 : Serial.print(" - Menu Right"); break;
  195. case 0x46 : Serial.print(" - Menu Escape"); break;
  196. case 0x47 : Serial.print(" - Menu Value Increase"); break;
  197. case 0x48 : Serial.print(" - Menu Value Decrease"); break;
  198. case 0x60 : Serial.print(" - Data On Screen"); break;
  199. case 0x61 : Serial.print(" - Closed Caption"); break;
  200. case 0x62 : Serial.print(" - Closed Caption Select"); break;
  201. case 0x63 : Serial.print(" - VCR/TV"); break;
  202. case 0x64 : Serial.print(" - Broadcast Mode"); break;
  203. case 0x65 : Serial.print(" - Snapshot"); break;
  204. case 0x66 : Serial.print(" - Still"); break;
  205. case 0x80 : Serial.print(" - Selection"); break;
  206. case 0x81 : Serial.print(" - Assign Selection"); break;
  207. case 0x82 : Serial.print(" - Mode Step"); break;
  208. case 0x83 : Serial.print(" - Recall Last"); break;
  209. case 0x84 : Serial.print(" - Enter Channel"); break;
  210. case 0x85 : Serial.print(" - Order Movie"); break;
  211. case 0x86 : Serial.print(" - Channel"); break;
  212. case 0x87 : Serial.print(" - Media Selection"); break;
  213. case 0x88 : Serial.print(" - Media Select Computer"); break;
  214. case 0x89 : Serial.print(" - Media Select TV"); break;
  215. case 0x8A : Serial.print(" - Media Select WWW"); break;
  216. case 0x8B : Serial.print(" - Media Select DVD"); break;
  217. case 0x8C : Serial.print(" - Media Select Telephone"); break;
  218. case 0x8D : Serial.print(" - Media Select Program Guide"); break;
  219. case 0x8E : Serial.print(" - Media Select Video Phone"); break;
  220. case 0x8F : Serial.print(" - Media Select Games"); break;
  221. case 0x90 : Serial.print(" - Media Select Messages"); break;
  222. case 0x91 : Serial.print(" - Media Select CD"); break;
  223. case 0x92 : Serial.print(" - Media Select VCR"); break;
  224. case 0x93 : Serial.print(" - Media Select Tuner"); break;
  225. case 0x94 : Serial.print(" - Quit"); break;
  226. case 0x95 : Serial.print(" - Help"); break;
  227. case 0x96 : Serial.print(" - Media Select Tape"); break;
  228. case 0x97 : Serial.print(" - Media Select Cable"); break;
  229. case 0x98 : Serial.print(" - Media Select Satellite"); break;
  230. case 0x99 : Serial.print(" - Media Select Security"); break;
  231. case 0x9A : Serial.print(" - Media Select Home"); break;
  232. case 0x9B : Serial.print(" - Media Select Call"); break;
  233. case 0x9C : Serial.print(" - Channel Increment"); break;
  234. case 0x9D : Serial.print(" - Channel Decrement"); break;
  235. case 0x9E : Serial.print(" - Media Select SAP"); break;
  236. case 0xA0 : Serial.print(" - VCR Plus"); break;
  237. case 0xA1 : Serial.print(" - Once"); break;
  238. case 0xA2 : Serial.print(" - Daily"); break;
  239. case 0xA3 : Serial.print(" - Weekly"); break;
  240. case 0xA4 : Serial.print(" - Monthly"); break;
  241. case 0xB0 : Serial.print(" - Play"); break;
  242. case 0xB1 : Serial.print(" - Pause"); break;
  243. case 0xB2 : Serial.print(" - Record"); break;
  244. case 0xB3 : Serial.print(" - Fast Forward"); break;
  245. case 0xB4 : Serial.print(" - Rewind"); break;
  246. case 0xB5 : Serial.print(" - Scan Next Track"); break;
  247. case 0xB6 : Serial.print(" - Scan Previous Track"); break;
  248. case 0xB7 : Serial.print(" - Stop"); break;
  249. case 0xB8 : Serial.print(" - Eject"); break;
  250. case 0xB9 : Serial.print(" - Random Play"); break;
  251. case 0xBA : Serial.print(" - Select DisC"); break;
  252. case 0xBB : Serial.print(" - Enter Disc"); break;
  253. case 0xBC : Serial.print(" - Repeat"); break;
  254. case 0xBD : Serial.print(" - Tracking"); break;
  255. case 0xBE : Serial.print(" - Track Normal"); break;
  256. case 0xBF : Serial.print(" - Slow Tracking"); break;
  257. case 0xC0 : Serial.print(" - Frame Forward"); break;
  258. case 0xC1 : Serial.print(" - Frame Back"); break;
  259. case 0xC2 : Serial.print(" - Mark"); break;
  260. case 0xC3 : Serial.print(" - Clear Mark"); break;
  261. case 0xC4 : Serial.print(" - Repeat From Mark"); break;
  262. case 0xC5 : Serial.print(" - Return To Mark"); break;
  263. case 0xC6 : Serial.print(" - Search Mark Forward"); break;
  264. case 0xC7 : Serial.print(" - Search Mark Backwards"); break;
  265. case 0xC8 : Serial.print(" - Counter Reset"); break;
  266. case 0xC9 : Serial.print(" - Show Counter"); break;
  267. case 0xCA : Serial.print(" - Tracking Increment"); break;
  268. case 0xCB : Serial.print(" - Tracking Decrement"); break;
  269. case 0xCD : Serial.print(" - Pause/Continue"); break;
  270. case 0xE0 : Serial.print(" - Volume"); break;
  271. case 0xE1 : Serial.print(" - Balance"); break;
  272. case 0xE2 : Serial.print(" - Mute"); break;
  273. case 0xE3 : Serial.print(" - Bass"); break;
  274. case 0xE4 : Serial.print(" - Treble"); break;
  275. case 0xE5 : Serial.print(" - Bass Boost"); break;
  276. case 0xE6 : Serial.print(" - Surround Mode"); break;
  277. case 0xE7 : Serial.print(" - Loudness"); break;
  278. case 0xE8 : Serial.print(" - MPX"); break;
  279. case 0xE9 : Serial.print(" - Volume Up"); break;
  280. case 0xEA : Serial.print(" - Volume Down"); break;
  281. case 0xF0 : Serial.print(" - Speed Select"); break;
  282. case 0xF1 : Serial.print(" - Playback Speed"); break;
  283. case 0xF2 : Serial.print(" - Standard Play"); break;
  284. case 0xF3 : Serial.print(" - Long Play"); break;
  285. case 0xF4 : Serial.print(" - Extended Play"); break;
  286. case 0xF5 : Serial.print(" - Slow"); break;
  287. case 0x100: Serial.print(" - Fan Enable"); break;
  288. case 0x101: Serial.print(" - Fan Speed"); break;
  289. case 0x102: Serial.print(" - Light"); break;
  290. case 0x103: Serial.print(" - Light Illumination Level"); break;
  291. case 0x104: Serial.print(" - Climate Control Enable"); break;
  292. case 0x105: Serial.print(" - Room Temperature"); break;
  293. case 0x106: Serial.print(" - Security Enable"); break;
  294. case 0x107: Serial.print(" - Fire Alarm"); break;
  295. case 0x108: Serial.print(" - Police Alarm"); break;
  296. case 0x150: Serial.print(" - Balance Right"); break;
  297. case 0x151: Serial.print(" - Balance Left"); break;
  298. case 0x152: Serial.print(" - Bass Increment"); break;
  299. case 0x153: Serial.print(" - Bass Decrement"); break;
  300. case 0x154: Serial.print(" - Treble Increment"); break;
  301. case 0x155: Serial.print(" - Treble Decrement"); break;
  302. case 0x160: Serial.print(" - Speaker System"); break;
  303. case 0x161: Serial.print(" - Channel Left"); break;
  304. case 0x162: Serial.print(" - Channel Right"); break;
  305. case 0x163: Serial.print(" - Channel Center"); break;
  306. case 0x164: Serial.print(" - Channel Front"); break;
  307. case 0x165: Serial.print(" - Channel Center Front"); break;
  308. case 0x166: Serial.print(" - Channel Side"); break;
  309. case 0x167: Serial.print(" - Channel Surround"); break;
  310. case 0x168: Serial.print(" - Channel Low Frequency Enhancement"); break;
  311. case 0x169: Serial.print(" - Channel Top"); break;
  312. case 0x16A: Serial.print(" - Channel Unknown"); break;
  313. case 0x170: Serial.print(" - Sub-channel"); break;
  314. case 0x171: Serial.print(" - Sub-channel Increment"); break;
  315. case 0x172: Serial.print(" - Sub-channel Decrement"); break;
  316. case 0x173: Serial.print(" - Alternate Audio Increment"); break;
  317. case 0x174: Serial.print(" - Alternate Audio Decrement"); break;
  318. case 0x180: Serial.print(" - Application Launch Buttons"); break;
  319. case 0x181: Serial.print(" - AL Launch Button Configuration Tool"); break;
  320. case 0x182: Serial.print(" - AL Programmable Button Configuration"); break;
  321. case 0x183: Serial.print(" - AL Consumer Control Configuration"); break;
  322. case 0x184: Serial.print(" - AL Word Processor"); break;
  323. case 0x185: Serial.print(" - AL Text Editor"); break;
  324. case 0x186: Serial.print(" - AL Spreadsheet"); break;
  325. case 0x187: Serial.print(" - AL Graphics Editor"); break;
  326. case 0x188: Serial.print(" - AL Presentation App"); break;
  327. case 0x189: Serial.print(" - AL Database App"); break;
  328. case 0x18A: Serial.print(" - AL Email Reader"); break;
  329. case 0x18B: Serial.print(" - AL Newsreader"); break;
  330. case 0x18C: Serial.print(" - AL Voicemail"); break;
  331. case 0x18D: Serial.print(" - AL Contacts/Address Book"); break;
  332. case 0x18E: Serial.print(" - AL Calendar/Schedule"); break;
  333. case 0x18F: Serial.print(" - AL Task/Project Manager"); break;
  334. case 0x190: Serial.print(" - AL Log/Journal/Timecard"); break;
  335. case 0x191: Serial.print(" - AL Checkbook/Finance"); break;
  336. case 0x192: Serial.print(" - AL Calculator"); break;
  337. case 0x193: Serial.print(" - AL A/V Capture/Playback"); break;
  338. case 0x194: Serial.print(" - AL Local Machine Browser"); break;
  339. case 0x195: Serial.print(" - AL LAN/WAN Browser"); break;
  340. case 0x196: Serial.print(" - AL Internet Browser"); break;
  341. case 0x197: Serial.print(" - AL Remote Networking/ISP Connect"); break;
  342. case 0x198: Serial.print(" - AL Network Conference"); break;
  343. case 0x199: Serial.print(" - AL Network Chat"); break;
  344. case 0x19A: Serial.print(" - AL Telephony/Dialer"); break;
  345. case 0x19B: Serial.print(" - AL Logon"); break;
  346. case 0x19C: Serial.print(" - AL Logoff"); break;
  347. case 0x19D: Serial.print(" - AL Logon/Logoff"); break;
  348. case 0x19E: Serial.print(" - AL Terminal Lock/Screensaver"); break;
  349. case 0x19F: Serial.print(" - AL Control Panel"); break;
  350. case 0x1A0: Serial.print(" - AL Command Line Processor/Run"); break;
  351. case 0x1A1: Serial.print(" - AL Process/Task Manager"); break;
  352. case 0x1A2: Serial.print(" - AL Select Tast/Application"); break;
  353. case 0x1A3: Serial.print(" - AL Next Task/Application"); break;
  354. case 0x1A4: Serial.print(" - AL Previous Task/Application"); break;
  355. case 0x1A5: Serial.print(" - AL Preemptive Halt Task/Application"); break;
  356. case 0x200: Serial.print(" - Generic GUI Application Controls"); break;
  357. case 0x201: Serial.print(" - AC New"); break;
  358. case 0x202: Serial.print(" - AC Open"); break;
  359. case 0x203: Serial.print(" - AC Close"); break;
  360. case 0x204: Serial.print(" - AC Exit"); break;
  361. case 0x205: Serial.print(" - AC Maximize"); break;
  362. case 0x206: Serial.print(" - AC Minimize"); break;
  363. case 0x207: Serial.print(" - AC Save"); break;
  364. case 0x208: Serial.print(" - AC Print"); break;
  365. case 0x209: Serial.print(" - AC Properties"); break;
  366. case 0x21A: Serial.print(" - AC Undo"); break;
  367. case 0x21B: Serial.print(" - AC Copy"); break;
  368. case 0x21C: Serial.print(" - AC Cut"); break;
  369. case 0x21D: Serial.print(" - AC Paste"); break;
  370. case 0x21E: Serial.print(" - AC Select All"); break;
  371. case 0x21F: Serial.print(" - AC Find"); break;
  372. case 0x220: Serial.print(" - AC Find and Replace"); break;
  373. case 0x221: Serial.print(" - AC Search"); break;
  374. case 0x222: Serial.print(" - AC Go To"); break;
  375. case 0x223: Serial.print(" - AC Home"); break;
  376. case 0x224: Serial.print(" - AC Back"); break;
  377. case 0x225: Serial.print(" - AC Forward"); break;
  378. case 0x226: Serial.print(" - AC Stop"); break;
  379. case 0x227: Serial.print(" - AC Refresh"); break;
  380. case 0x228: Serial.print(" - AC Previous Link"); break;
  381. case 0x229: Serial.print(" - AC Next Link"); break;
  382. case 0x22A: Serial.print(" - AC Bookmarks"); break;
  383. case 0x22B: Serial.print(" - AC History"); break;
  384. case 0x22C: Serial.print(" - AC Subscriptions"); break;
  385. case 0x22D: Serial.print(" - AC Zoom In"); break;
  386. case 0x22E: Serial.print(" - AC Zoom Out"); break;
  387. case 0x22F: Serial.print(" - AC Zoom"); break;
  388. case 0x230: Serial.print(" - AC Full Screen View"); break;
  389. case 0x231: Serial.print(" - AC Normal View"); break;
  390. case 0x232: Serial.print(" - AC View Toggle"); break;
  391. case 0x233: Serial.print(" - AC Scroll Up"); break;
  392. case 0x234: Serial.print(" - AC Scroll Down"); break;
  393. case 0x235: Serial.print(" - AC Scroll"); break;
  394. case 0x236: Serial.print(" - AC Pan Left"); break;
  395. case 0x237: Serial.print(" - AC Pan Right"); break;
  396. case 0x238: Serial.print(" - AC Pan"); break;
  397. case 0x239: Serial.print(" - AC New Window"); break;
  398. case 0x23A: Serial.print(" - AC Tile Horizontally"); break;
  399. case 0x23B: Serial.print(" - AC Tile Vertically"); break;
  400. case 0x23C: Serial.print(" - AC Format"); break;
  401. }
  402. }
  403. Serial.println();
  404. }
  405. void OnHIDExtrasRelease(uint32_t top, uint16_t key)
  406. {
  407. Serial.print("HID (");
  408. Serial.print(top, HEX);
  409. Serial.print(") key release:");
  410. Serial.println(key, HEX);
  411. }
  412. bool OnReceiveHidData(uint32_t usage, const uint8_t *data, uint32_t len) {
  413. // Called for maybe both HIDS for rawhid basic test. One is for the Teensy
  414. // to output to Serial. while still having Raw Hid...
  415. if (usage == 0xffc90004) {
  416. // Lets trim off trailing null characters.
  417. while ((len > 0) && (data[len-1] == 0)) {
  418. len--;
  419. }
  420. if (len) {
  421. Serial.print("RawHid Serial: ");
  422. Serial.write(data, len);
  423. }
  424. } else {
  425. Serial.print("RawHID data: ");
  426. Serial.println(usage, HEX);
  427. while (len) {
  428. uint8_t cb = (len > 16)? 16 : len;
  429. const uint8_t *p = data;
  430. uint8_t i;
  431. for (i = 0; i < cb; i++) {
  432. Serial.printf("%02x ", *p++);
  433. }
  434. Serial.print(": ");
  435. for (i = 0; i < cb; i++) {
  436. Serial.write(((*data >= ' ')&&(*data <= '~'))? *data : '.');
  437. data++;
  438. }
  439. len -= cb;
  440. Serial.println();
  441. }
  442. }
  443. return true;
  444. }