You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

454 lines
21KB

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