Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

USBHost_viewer.ino 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. //=============================================================================
  2. // Simple test viewer app for several of the USB devices on ili9341 display
  3. //
  4. // Currently requires the libraries
  5. // ili9341_t3n that can be located: https://github.com/KurtE/ILI9341_t3n
  6. // spin: https://github.com/KurtE/SPIN
  7. //
  8. // Teensy 3.6 Pins
  9. // 8 = RST
  10. // 9 = D/C
  11. // 10 = CS
  12. //
  13. // Teensy 4.0 Beta Pins
  14. // 23 = RST (Marked MCLK on T4 beta breakout)
  15. // 10 = CS (Marked CS)
  16. // 9 = DC (Marked MEMCS)
  17. //
  18. // This example is in the public domain
  19. //=============================================================================
  20. #include "USBHost_t36.h"
  21. #include <ili9341_t3n_font_Arial.h>
  22. #define TEENSY64
  23. //=============================================================================
  24. // Connection configuration of ILI9341 LCD TFT
  25. //=============================================================================
  26. DMAMEM uint16_t frame_buffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
  27. #if defined(__MK66FX1M0__) && !defined(TEENSY64)
  28. #define TFT_RST 255
  29. #define TFT_DC 20
  30. #define TFT_CS 21
  31. ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
  32. #elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
  33. // On Teensy 4 beta with Paul's breakout out:
  34. // Using pins (MOSI, MISO, SCK which are labeled on Audio board breakout location
  35. // which are not in the Normal processor positions
  36. // Also DC=10(CS), CS=9(BCLK) and RST 23(MCLK)
  37. #define TFT_RST 23
  38. #define TFT_DC 9
  39. #define TFT_CS 10
  40. ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
  41. #elif defined(TEENSY64)
  42. #define TFT_RST 255
  43. #define TFT_DC 20
  44. #define TFT_CS 21
  45. #define TFT_SCK 14
  46. #define TFT_MISO 39
  47. #define TFT_MOSI 28
  48. ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);
  49. #else
  50. #error "This example App will only work with Teensy 3.6 or Teensy 4."
  51. #endif
  52. //=============================================================================
  53. // USB Host Ojbects
  54. //=============================================================================
  55. USBHost myusb;
  56. USBHub hub1(myusb);
  57. USBHub hub2(myusb);
  58. KeyboardController keyboard1(myusb);
  59. KeyboardController keyboard2(myusb);
  60. USBHIDParser hid1(myusb);
  61. USBHIDParser hid2(myusb);
  62. USBHIDParser hid3(myusb);
  63. USBHIDParser hid4(myusb);
  64. USBHIDParser hid5(myusb);
  65. MouseController mouse(myusb);
  66. DigitizerController tablet(myusb);
  67. JoystickController joystick(myusb);
  68. BluetoothController bluet(myusb, true, "0000"); // Version does pairing to device
  69. //BluetoothController bluet(myusb); // version assumes it already was paired
  70. RawHIDController rawhid2(myusb);
  71. // Lets only include in the lists The most top level type devices we wish to show information for.
  72. //USBDriver *drivers[] = {&keyboard1, &keyboard2, &joystick};
  73. USBDriver *drivers[] = {&keyboard1, &keyboard2, &joystick, &bluet, &hid1, &hid2};
  74. #define CNT_DEVICES (sizeof(drivers)/sizeof(drivers[0]))
  75. //const char * driver_names[CNT_DEVICES] = {"KB1", "KB2", "Joystick(device)"};
  76. const char * driver_names[CNT_DEVICES] = {"KB1", "KB2", "Joystick(device)", "Bluet", "HID1" , "HID2"};
  77. //bool driver_active[CNT_DEVICES] = {false, false, false};
  78. bool driver_active[CNT_DEVICES] = {false, false, false, false, false};
  79. // Lets also look at HID Input devices
  80. USBHIDInput *hiddrivers[] = {&tablet, &joystick, &mouse, &rawhid2};
  81. #define CNT_HIDDEVICES (sizeof(hiddrivers)/sizeof(hiddrivers[0]))
  82. const char * hid_driver_names[CNT_HIDDEVICES] = {"tablet", "joystick", "mouse", "RawHid2"};
  83. bool hid_driver_active[CNT_HIDDEVICES] = {false, false, false, false};
  84. BTHIDInput *bthiddrivers[] = {&joystick, &mouse};
  85. #define CNT_BTHIDDEVICES (sizeof(bthiddrivers)/sizeof(bthiddrivers[0]))
  86. const char * bthid_driver_names[CNT_HIDDEVICES] = {"joystick", "mouse"};
  87. bool bthid_driver_active[CNT_HIDDEVICES] = {false, false};
  88. //=============================================================================
  89. // Other state variables.
  90. //=============================================================================
  91. // Save away values for buttons, x, y, wheel, wheelh
  92. int buttons_cur = 0;
  93. int x_cur = 0,
  94. y_cur = 0,
  95. z_cur = 0;
  96. int x2_cur = 0,
  97. y2_cur = 0,
  98. z2_cur = 0,
  99. L1_cur = 0,
  100. R1_cur = 0;
  101. int wheel_cur = 0;
  102. int wheelH_cur = 0;
  103. int axis_cur[10];
  104. String p = "KB1";
  105. bool BT = 0;
  106. int user_axis[64];
  107. uint32_t buttons_prev = 0;
  108. uint32_t buttons;
  109. bool show_changed_only = false;
  110. bool new_device_detected = false;
  111. int16_t y_position_after_device_info = 0;
  112. uint8_t joystick_left_trigger_value = 0;
  113. uint8_t joystick_right_trigger_value = 0;
  114. uint64_t joystick_full_notify_mask = (uint64_t) - 1;
  115. //=============================================================================
  116. // Setup
  117. //=============================================================================
  118. void setup()
  119. {
  120. Serial1.begin(2000000);
  121. while (!Serial && millis() < 3000) ; // wait for Arduino Serial Monitor
  122. Serial.println("\n\nUSB Host Testing");
  123. myusb.begin();
  124. rawhid2.attachReceive(OnReceiveHidData);
  125. keyboard1.attachPress(OnPress);
  126. keyboard2.attachPress(OnPress);
  127. keyboard1.attachExtrasPress(OnHIDExtrasPress);
  128. keyboard1.attachExtrasRelease(OnHIDExtrasRelease);
  129. keyboard2.attachExtrasPress(OnHIDExtrasPress);
  130. keyboard2.attachExtrasRelease(OnHIDExtrasRelease);
  131. // The below forceBootProtocol will force which ever
  132. // next keyboard that attaches to this device to be in boot protocol
  133. // Only try this if you run into keyboard with issues. If this is a combined
  134. // device like wireless mouse and keyboard this can cause mouse problems.
  135. //keyboard1.forceBootProtocol();
  136. tft.begin();
  137. // explicitly set the frame buffer
  138. tft.setFrameBuffer(frame_buffer);
  139. delay(100);
  140. tft.setRotation(3); // 180
  141. delay(100);
  142. tft.fillScreen(ILI9341_BLACK);
  143. tft.setTextColor(ILI9341_YELLOW);
  144. tft.setTextSize(2);
  145. tft.println("Waiting for Device...");
  146. tft.useFrameBuffer(true);
  147. }
  148. //=============================================================================
  149. // Loop
  150. //=============================================================================
  151. void loop()
  152. {
  153. myusb.Task();
  154. // Update the display with
  155. UpdateActiveDeviceInfo();
  156. // Now lets try displaying Tablet data
  157. ProcessTabletData();
  158. // And joystick data
  159. ProcessJoystickData();
  160. // Process Mouse Data
  161. ProcessMouseData();
  162. }
  163. //=============================================================================
  164. // UpdateActiveDeviceInfo
  165. //=============================================================================
  166. //=============================================================================
  167. // UpdateActiveDeviceInfo
  168. //=============================================================================
  169. void UpdateActiveDeviceInfo() {
  170. // First see if any high level devices
  171. for (uint8_t i = 0; i < CNT_DEVICES; i++) {
  172. if (*drivers[i] != driver_active[i]) {
  173. if (driver_active[i]) {
  174. Serial.printf("*** Device %s - disconnected ***\n", driver_names[i]);
  175. driver_active[i] = false;
  176. } else {
  177. new_device_detected = true;
  178. Serial.printf("*** Device %s %x:%x - connected ***\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
  179. driver_active[i] = true;
  180. tft.fillScreen(ILI9341_BLACK); // clear the screen.
  181. tft.setCursor(0, 0);
  182. tft.setTextColor(ILI9341_YELLOW);
  183. tft.setFont(Arial_12);
  184. tft.printf("Device %s %x:%x\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
  185. const uint8_t *psz = drivers[i]->manufacturer();
  186. if (psz && *psz) tft.printf(" manufacturer: %s\n", psz);
  187. psz = drivers[i]->product();
  188. if (psz && *psz) tft.printf(" product: %s\n", psz);
  189. psz = drivers[i]->serialNumber();
  190. if (psz && *psz) tft.printf(" Serial: %s\n", psz);
  191. tft.updateScreen(); // update the screen now
  192. }
  193. }
  194. }
  195. // Then Hid Devices
  196. for (uint8_t i = 0; i < CNT_HIDDEVICES; i++) {
  197. if (*hiddrivers[i] != hid_driver_active[i]) {
  198. if (hid_driver_active[i]) {
  199. Serial.printf("*** HID Device %s - disconnected ***\n", hid_driver_names[i]);
  200. hid_driver_active[i] = false;
  201. } else {
  202. new_device_detected = true;
  203. Serial.printf("*** HID Device %s %x:%x - connected ***\n", hid_driver_names[i], hiddrivers[i]->idVendor(), hiddrivers[i]->idProduct());
  204. hid_driver_active[i] = true;
  205. tft.fillScreen(ILI9341_BLACK); // clear the screen.
  206. tft.setCursor(0, 0);
  207. tft.setTextColor(ILI9341_YELLOW);
  208. tft.setFont(Arial_12);
  209. tft.printf("HID Device %s %x:%x\n", hid_driver_names[i], hiddrivers[i]->idVendor(), hiddrivers[i]->idProduct());
  210. const uint8_t *psz = hiddrivers[i]->manufacturer();
  211. if (psz && *psz) tft.printf(" manufacturer: %s\n", psz);
  212. psz = hiddrivers[i]->product();
  213. if (psz && *psz) tft.printf(" product: %s\n", psz);
  214. psz = hiddrivers[i]->serialNumber();
  215. if (psz && *psz) tft.printf(" Serial: %s\n", psz);
  216. tft.updateScreen(); // update the screen now
  217. }
  218. }
  219. }
  220. // Then Bluetooth devices
  221. for (uint8_t i = 0; i < CNT_BTHIDDEVICES; i++) {
  222. if (*bthiddrivers[i] != bthid_driver_active[i]) {
  223. if (bthid_driver_active[i]) {
  224. Serial.printf("*** BTHID Device %s - disconnected ***\n", hid_driver_names[i]);
  225. bthid_driver_active[i] = false;
  226. } else {
  227. new_device_detected = true;
  228. Serial.printf("*** BTHID Device %s %x:%x - connected ***\n", hid_driver_names[i], hiddrivers[i]->idVendor(), hiddrivers[i]->idProduct());
  229. bthid_driver_active[i] = true;
  230. tft.fillScreen(ILI9341_BLACK); // clear the screen.
  231. tft.setCursor(0, 0);
  232. tft.setTextColor(ILI9341_YELLOW);
  233. tft.setFont(Arial_12);
  234. tft.printf("Bluetooth Device %s %x:%x\n", bthid_driver_names[i], bthiddrivers[i]->idVendor(), bthiddrivers[i]->idProduct());
  235. const uint8_t *psz = bthiddrivers[i]->manufacturer();
  236. if (psz && *psz) tft.printf(" manufacturer: %s\n", psz);
  237. psz = bthiddrivers[i]->product();
  238. if (psz && *psz) tft.printf(" product: %s\n", psz);
  239. psz = bthiddrivers[i]->serialNumber();
  240. if (psz && *psz) tft.printf(" Serial: %s\n", psz);
  241. tft.updateScreen(); // update the screen now
  242. }
  243. }
  244. }
  245. }
  246. //=============================================================================
  247. // ProcessTabletData
  248. //=============================================================================
  249. void ProcessTabletData() {
  250. if (tablet.available()) {
  251. if (new_device_detected) {
  252. // Lets display the titles.
  253. int16_t x;
  254. tft.getCursor(&x, &y_position_after_device_info);
  255. tft.setTextColor(ILI9341_YELLOW);
  256. tft.printf("Buttons:\nX:\nY:\nWheel:\nWheel H:\nAxis:");
  257. new_device_detected = false;
  258. }
  259. bool something_changed = false;
  260. if (tablet.getButtons() != buttons_cur) {
  261. buttons_cur = tablet.getButtons();
  262. something_changed = true;
  263. }
  264. if (tablet.getMouseX() != x_cur) {
  265. x_cur = tablet.getMouseX();
  266. something_changed = true;
  267. }
  268. if (tablet.getMouseY() != y_cur) {
  269. y_cur = tablet.getMouseY();
  270. something_changed = true;
  271. }
  272. if (tablet.getWheel() != wheel_cur) {
  273. wheel_cur = tablet.getWheel();
  274. something_changed = true;
  275. }
  276. if (tablet.getWheelH() != wheelH_cur) {
  277. wheelH_cur = tablet.getWheelH();
  278. something_changed = true;
  279. }
  280. // BUGBUG:: play with some Axis...
  281. for (uint8_t i = 0; i < 10; i++) {
  282. int axis = tablet.getAxis(i);
  283. if (axis != axis_cur[i]) {
  284. axis_cur[i] = axis;
  285. something_changed = true;
  286. }
  287. }
  288. if (something_changed) {
  289. #define TABLET_DATA_X 100
  290. int16_t x, y2;
  291. unsigned char line_space = Arial_12.line_space;
  292. tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
  293. //tft.setTextDatum(BR_DATUM);
  294. int16_t y = y_position_after_device_info;
  295. tft.setCursor(TABLET_DATA_X, y);
  296. tft.printf("%d(%x)", buttons_cur, buttons_cur);
  297. tft.getCursor(&x, &y2);
  298. tft.fillRect(x, y, 320, line_space, ILI9341_BLACK);
  299. y += line_space; OutputNumberField(TABLET_DATA_X, y, x_cur, 320);
  300. y += line_space; OutputNumberField(TABLET_DATA_X, y, y_cur, 320);
  301. y += line_space; OutputNumberField(TABLET_DATA_X, y, wheel_cur, 320);
  302. y += line_space; OutputNumberField(TABLET_DATA_X, y, wheelH_cur, 320);
  303. // Output other Axis data
  304. for (uint8_t i = 0; i < 9; i += 3) {
  305. y += line_space;
  306. OutputNumberField(TABLET_DATA_X, y, axis_cur[i], 75);
  307. OutputNumberField(TABLET_DATA_X + 75, y, axis_cur[i + 1], 75);
  308. OutputNumberField(TABLET_DATA_X + 150, y, axis_cur[i + 2], 75);
  309. }
  310. tft.updateScreen(); // update the screen now
  311. }
  312. tablet.digitizerDataClear();
  313. }
  314. }
  315. //=============================================================================
  316. // OutputNumberField
  317. //=============================================================================
  318. void OutputNumberField(int16_t x, int16_t y, int val, int16_t field_width) {
  319. int16_t x2, y2;
  320. tft.setCursor(x, y);
  321. tft.print(val, DEC); tft.getCursor(&x2, &y2);
  322. tft.fillRect(x2, y, field_width - (x2 - x), Arial_12.line_space, ILI9341_BLACK);
  323. }
  324. //=============================================================================
  325. // ProcessMouseData
  326. //=============================================================================
  327. void ProcessMouseData() {
  328. if (mouse.available()) {
  329. if (new_device_detected) {
  330. // Lets display the titles.
  331. int16_t x;
  332. tft.getCursor(&x, &y_position_after_device_info);
  333. tft.setTextColor(ILI9341_YELLOW);
  334. tft.printf("Buttons:\nX:\nY:\nWheel:\nWheel H:");
  335. new_device_detected = false;
  336. }
  337. bool something_changed = false;
  338. if (mouse.getButtons() != buttons_cur) {
  339. buttons_cur = mouse.getButtons();
  340. something_changed = true;
  341. }
  342. if (mouse.getMouseX() != x_cur) {
  343. x_cur = mouse.getMouseX();
  344. something_changed = true;
  345. }
  346. if (mouse.getMouseY() != y_cur) {
  347. y_cur = mouse.getMouseY();
  348. something_changed = true;
  349. }
  350. if (mouse.getWheel() != wheel_cur) {
  351. wheel_cur = mouse.getWheel();
  352. something_changed = true;
  353. }
  354. if (mouse.getWheelH() != wheelH_cur) {
  355. wheelH_cur = mouse.getWheelH();
  356. something_changed = true;
  357. }
  358. if (something_changed) {
  359. #define MOUSE_DATA_X 100
  360. int16_t x, y2;
  361. unsigned char line_space = Arial_12.line_space;
  362. tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
  363. //tft.setTextDatum(BR_DATUM);
  364. int16_t y = y_position_after_device_info;
  365. tft.setCursor(TABLET_DATA_X, y);
  366. tft.printf("%d(%x)", buttons_cur, buttons_cur);
  367. tft.getCursor(&x, &y2);
  368. tft.fillRect(x, y, 320, line_space, ILI9341_BLACK);
  369. y += line_space; OutputNumberField(MOUSE_DATA_X, y, x_cur, 320);
  370. y += line_space; OutputNumberField(MOUSE_DATA_X, y, y_cur, 320);
  371. y += line_space; OutputNumberField(MOUSE_DATA_X, y, wheel_cur, 320);
  372. y += line_space; OutputNumberField(MOUSE_DATA_X, y, wheelH_cur, 320);
  373. tft.updateScreen(); // update the screen now
  374. }
  375. mouse.mouseDataClear();
  376. }
  377. }
  378. //=============================================================================
  379. // ProcessJoystickData
  380. //=============================================================================
  381. void ProcessJoystickData() {
  382. if (joystick.available()) {
  383. uint64_t axis_mask = joystick.axisMask();
  384. uint64_t axis_changed_mask = joystick.axisChangedMask();
  385. Serial.print("Joystick: buttons = ");
  386. buttons = joystick.getButtons();
  387. Serial.print(buttons, HEX);
  388. //Serial.printf(" AMasks: %x %x:%x", axis_mask, (uint32_t)(user_axis_mask >> 32), (uint32_t)(user_axis_mask & 0xffffffff));
  389. //Serial.printf(" M: %lx %lx", axis_mask, joystick.axisChangedMask());
  390. if (show_changed_only) {
  391. for (uint8_t i = 0; axis_changed_mask != 0; i++, axis_changed_mask >>= 1) {
  392. if (axis_changed_mask & 1) {
  393. Serial.printf(" %d:%d", i, joystick.getAxis(i));
  394. }
  395. }
  396. } else {
  397. for (uint8_t i = 0; axis_mask != 0; i++, axis_mask >>= 1) {
  398. if (axis_mask & 1) {
  399. Serial.printf(" %d:%d", i, joystick.getAxis(i));
  400. }
  401. }
  402. }
  403. for (uint8_t i = 0; i < 64; i++) {
  404. user_axis[i] = joystick.getAxis(i);
  405. }
  406. uint8_t ltv;
  407. uint8_t rtv;
  408. switch (joystick.joystickType()) {
  409. default:
  410. break;
  411. case JoystickController::PS4:
  412. ltv = joystick.getAxis(3);
  413. rtv = joystick.getAxis(4);
  414. if ((ltv != joystick_left_trigger_value) || (rtv != joystick_right_trigger_value)) {
  415. joystick_left_trigger_value = ltv;
  416. joystick_right_trigger_value = rtv;
  417. joystick.setRumble(ltv, rtv);
  418. }
  419. break;
  420. case JoystickController::PS3:
  421. ltv = joystick.getAxis(18);
  422. rtv = joystick.getAxis(19);
  423. if ((ltv != joystick_left_trigger_value) || (rtv != joystick_right_trigger_value)) {
  424. joystick_left_trigger_value = ltv;
  425. joystick_right_trigger_value = rtv;
  426. joystick.setRumble(ltv, rtv, 50);
  427. }
  428. break;
  429. case JoystickController::XBOXONE:
  430. case JoystickController::XBOX360:
  431. ltv = joystick.getAxis(4);
  432. rtv = joystick.getAxis(5);
  433. if ((ltv != joystick_left_trigger_value) || (rtv != joystick_right_trigger_value)) {
  434. joystick_left_trigger_value = ltv;
  435. joystick_right_trigger_value = rtv;
  436. joystick.setRumble(ltv, rtv);
  437. Serial.printf(" Set Rumble %d %d", ltv, rtv);
  438. }
  439. break;
  440. }
  441. if (buttons != buttons_cur) {
  442. if (joystick.joystickType() == JoystickController::PS3) {
  443. joystick.setLEDs((buttons >> 12) & 0xf); // try to get to TRI/CIR/X/SQuare
  444. } else {
  445. uint8_t lr = (buttons & 1) ? 0xff : 0;
  446. uint8_t lg = (buttons & 2) ? 0xff : 0;
  447. uint8_t lb = (buttons & 4) ? 0xff : 0;
  448. joystick.setLEDs(lr, lg, lb);
  449. }
  450. buttons_cur = buttons;
  451. }
  452. Serial.println();
  453. tft_JoystickData();
  454. joystick.joystickDataClear();
  455. }
  456. }
  457. //=============================================================================
  458. // TFT_joystick
  459. //=============================================================================
  460. void tft_JoystickData() {
  461. if (new_device_detected) {
  462. // Lets display the titles.
  463. int16_t x;
  464. tft.getCursor(&x, &y_position_after_device_info);
  465. tft.setTextColor(ILI9341_YELLOW);
  466. tft.printf("Buttons:\nX:\nY:\nX2\nY2(Z):\nL1:\nR1:\nHAT:");
  467. new_device_detected = false;
  468. }
  469. bool something_changed = false;
  470. if (buttons != buttons_prev) { //buttons
  471. something_changed = true;
  472. }
  473. if (user_axis[0] != x_cur) { //xL
  474. x_cur = user_axis[0];
  475. something_changed = true;
  476. }
  477. if (user_axis[1] != y_cur) { //yL
  478. y_cur = user_axis[1];
  479. something_changed = true;
  480. }
  481. if (user_axis[9] != wheel_cur) { //Hat
  482. wheel_cur = user_axis[9];
  483. something_changed = true;
  484. }
  485. //Second Axis
  486. if (user_axis[2] != x2_cur) { //xR
  487. x2_cur = user_axis[2];
  488. something_changed = true;
  489. }
  490. if (user_axis[5] != y2_cur) { //yR or z-axis
  491. y2_cur = user_axis[5];
  492. something_changed = true;
  493. }
  494. //Rumble Axis
  495. switch (joystick.joystickType()) {
  496. case JoystickController::XBOXONE:
  497. case JoystickController::XBOX360:
  498. case JoystickController::PS4:
  499. if (user_axis[3] != L1_cur) { //xR
  500. L1_cur = user_axis[3];
  501. something_changed = true;
  502. }
  503. if (user_axis[4] != R1_cur) { //yR or z-axis
  504. R1_cur = user_axis[4];
  505. something_changed = true;
  506. }
  507. break;
  508. case JoystickController::PS3:
  509. if (user_axis[18] != L1_cur) { //xR
  510. L1_cur = user_axis[18];
  511. something_changed = true;
  512. }
  513. if (user_axis[19] != R1_cur) { //yR or z-axis
  514. R1_cur = user_axis[19];
  515. something_changed = true;
  516. }
  517. break;
  518. }
  519. if (something_changed) {
  520. #define MOUSE_DATA_X 100
  521. int16_t x, y2;
  522. unsigned char line_space = Arial_12.line_space;
  523. tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
  524. //tft.setTextDatum(BR_DATUM);
  525. int16_t y = y_position_after_device_info;
  526. tft.setCursor(TABLET_DATA_X, y);
  527. tft.printf("%d(%x)", buttons, buttons);
  528. tft.getCursor(&x, &y2);
  529. tft.fillRect(x, y, 320, line_space, ILI9341_BLACK);
  530. y += line_space; OutputNumberField(MOUSE_DATA_X, y, x_cur, 320); //x
  531. y += line_space; OutputNumberField(MOUSE_DATA_X, y, y_cur, 320); //y
  532. y += line_space; OutputNumberField(MOUSE_DATA_X, y, x2_cur, 320); //x2(z)
  533. y += line_space; OutputNumberField(MOUSE_DATA_X, y, y2_cur, 320); //y2
  534. switch (joystick.joystickType()) {
  535. case JoystickController::PS4:
  536. case JoystickController::PS3:
  537. case JoystickController::XBOXONE:
  538. case JoystickController::XBOX360:
  539. y += line_space; OutputNumberField(MOUSE_DATA_X, y, L1_cur, 320);
  540. y += line_space; OutputNumberField(MOUSE_DATA_X, y, R1_cur, 320);
  541. break;
  542. default:
  543. y += line_space; OutputNumberField(MOUSE_DATA_X, y, 0, 320);
  544. y += line_space; OutputNumberField(MOUSE_DATA_X, y, 0, 320);
  545. y += line_space; OutputNumberField(MOUSE_DATA_X, y, wheel_cur, 320); //hat
  546. break;
  547. }
  548. tft.updateScreen(); // update the screen now
  549. }
  550. }
  551. //=============================================================================
  552. // ProcessMouseData
  553. //=============================================================================
  554. bool OnReceiveHidData(uint32_t usage, const uint8_t *data, uint32_t len) {
  555. // Called for maybe both HIDS for rawhid basic test. One is for the Teensy
  556. // to output to Serial. while still having Raw Hid...
  557. if (usage == 0xFF000080
  558. ) {
  559. //Serial.print("RawHIDx data: ");
  560. //Serial.println(usage, HEX);
  561. for (uint32_t j = 0; j < len; j++) {
  562. user_axis[j] = data[j];
  563. }
  564. bool something_changed = false;
  565. if (user_axis[3] != buttons_cur) {
  566. buttons_cur = user_axis[3];
  567. something_changed = true;
  568. }
  569. if (user_axis[4] != x_cur) {
  570. x_cur = user_axis[4];
  571. something_changed = true;
  572. }
  573. if (user_axis[5] != y_cur) {
  574. y_cur = user_axis[5];
  575. something_changed = true;
  576. }
  577. if (tablet.getWheel() != wheel_cur) {
  578. wheel_cur = 0;
  579. something_changed = true;
  580. }
  581. if (tablet.getWheelH() != wheelH_cur) {
  582. wheelH_cur = 0;
  583. something_changed = true;
  584. }
  585. if (something_changed) {
  586. tft.fillRect(45, 197, 240, 20, ILI9341_RED);
  587. tft.drawNumber(buttons_cur, 50, 200);
  588. tft.drawNumber(x_cur, 100, 200);
  589. tft.drawNumber(y_cur, 150, 200);
  590. tft.drawNumber(wheel_cur, 200, 200);
  591. tft.drawNumber(wheelH_cur, 250, 200);
  592. tft.updateScreen(); // update the screen now
  593. }
  594. } else {
  595. // Lets trim off trailing null characters.
  596. while ((len > 0) && (data[len - 1] == 0)) {
  597. len--;
  598. }
  599. if (len) {
  600. //Serial.print("RawHid Serial: ");
  601. //Serial.write(data, len);
  602. }
  603. }
  604. return true;
  605. }
  606. void MaybeSetupTextScrollArea()
  607. {
  608. if (new_device_detected) {
  609. BT = 0;
  610. new_device_detected = false;
  611. }
  612. if (BT == 0) {
  613. tft.enableScroll();
  614. tft.setScrollTextArea(20, 70, 280, 140);
  615. tft.setScrollBackgroundColor(ILI9341_GREEN);
  616. tft.setFont(Arial_11);
  617. tft.setTextColor(ILI9341_BLACK);
  618. tft.setCursor(20, 70);
  619. BT = 1;
  620. }
  621. }
  622. void OnPress(int key)
  623. {
  624. MaybeSetupTextScrollArea();
  625. tft.print("key: ");
  626. switch (key) {
  627. case KEYD_UP : tft.print("UP"); break;
  628. case KEYD_DOWN : tft.print("DN"); break;
  629. case KEYD_LEFT : tft.print("LEFT"); break;
  630. case KEYD_RIGHT : tft.print("RIGHT"); break;
  631. case KEYD_INSERT : tft.print("Ins"); break;
  632. case KEYD_DELETE : tft.print("Del"); break;
  633. case KEYD_PAGE_UP : tft.print("PUP"); break;
  634. case KEYD_PAGE_DOWN: tft.print("PDN"); break;
  635. case KEYD_HOME : tft.print("HOME"); break;
  636. case KEYD_END : tft.print("END"); break;
  637. case KEYD_F1 : tft.print("F1"); break;
  638. case KEYD_F2 : tft.print("F2"); break;
  639. case KEYD_F3 : tft.print("F3"); break;
  640. case KEYD_F4 : tft.print("F4"); break;
  641. case KEYD_F5 : tft.print("F5"); break;
  642. case KEYD_F6 : tft.print("F6"); break;
  643. case KEYD_F7 : tft.print("F7"); break;
  644. case KEYD_F8 : tft.print("F8"); break;
  645. case KEYD_F9 : tft.print("F9"); break;
  646. case KEYD_F10 : tft.print("F10"); break;
  647. case KEYD_F11 : tft.print("F11"); break;
  648. case KEYD_F12 : tft.print("F12"); break;
  649. default: tft.print((char)key); break;
  650. }
  651. tft.print("' ");
  652. tft.print(key);
  653. tft.print(" MOD: ");
  654. if (keyboard1) {
  655. tft.print(keyboard1.getModifiers(), HEX);
  656. tft.print(" OEM: ");
  657. tft.print(keyboard1.getOemKey(), HEX);
  658. tft.print(" LEDS: ");
  659. tft.println(keyboard1.LEDS(), HEX);
  660. } else {
  661. tft.print(keyboard2.getModifiers(), HEX);
  662. tft.print(" OEM: ");
  663. tft.print(keyboard2.getOemKey(), HEX);
  664. tft.print(" LEDS: ");
  665. tft.println(keyboard2.LEDS(), HEX);
  666. }
  667. //Serial.print("key ");
  668. //Serial.print((char)keyboard1.getKey());
  669. //Serial.print(" ");
  670. //Serial.print((char)keyboard2.getKey());
  671. //Serial.println();
  672. tft.updateScreen(); // update the screen now
  673. }
  674. void OnHIDExtrasPress(uint32_t top, uint16_t key)
  675. {
  676. MaybeSetupTextScrollArea();
  677. tft.print("HID (");
  678. tft.print(top, HEX);
  679. tft.print(") key press:");
  680. tft.print(key, HEX);
  681. if (top == 0xc0000) {
  682. switch (key) {
  683. case 0x20 : tft.print(" - +10"); break;
  684. case 0x21 : tft.print(" - +100"); break;
  685. case 0x22 : tft.print(" - AM/PM"); break;
  686. case 0x30 : tft.print(" - Power"); break;
  687. case 0x31 : tft.print(" - Reset"); break;
  688. case 0x32 : tft.print(" - Sleep"); break;
  689. case 0x33 : tft.print(" - Sleep After"); break;
  690. case 0x34 : tft.print(" - Sleep Mode"); break;
  691. case 0x35 : tft.print(" - Illumination"); break;
  692. case 0x36 : tft.print(" - Function Buttons"); break;
  693. case 0x40 : tft.print(" - Menu"); break;
  694. case 0x41 : tft.print(" - Menu Pick"); break;
  695. case 0x42 : tft.print(" - Menu Up"); break;
  696. case 0x43 : tft.print(" - Menu Down"); break;
  697. case 0x44 : tft.print(" - Menu Left"); break;
  698. case 0x45 : tft.print(" - Menu Right"); break;
  699. case 0x46 : tft.print(" - Menu Escape"); break;
  700. case 0x47 : tft.print(" - Menu Value Increase"); break;
  701. case 0x48 : tft.print(" - Menu Value Decrease"); break;
  702. case 0x60 : tft.print(" - Data On Screen"); break;
  703. case 0x61 : tft.print(" - Closed Caption"); break;
  704. case 0x62 : tft.print(" - Closed Caption Select"); break;
  705. case 0x63 : tft.print(" - VCR/TV"); break;
  706. case 0x64 : tft.print(" - Broadcast Mode"); break;
  707. case 0x65 : tft.print(" - Snapshot"); break;
  708. case 0x66 : tft.print(" - Still"); break;
  709. case 0x80 : tft.print(" - Selection"); break;
  710. case 0x81 : tft.print(" - Assign Selection"); break;
  711. case 0x82 : tft.print(" - Mode Step"); break;
  712. case 0x83 : tft.print(" - Recall Last"); break;
  713. case 0x84 : tft.print(" - Enter Channel"); break;
  714. case 0x85 : tft.print(" - Order Movie"); break;
  715. case 0x86 : tft.print(" - Channel"); break;
  716. case 0x87 : tft.print(" - Media Selection"); break;
  717. case 0x88 : tft.print(" - Media Select Computer"); break;
  718. case 0x89 : tft.print(" - Media Select TV"); break;
  719. case 0x8A : tft.print(" - Media Select WWW"); break;
  720. case 0x8B : tft.print(" - Media Select DVD"); break;
  721. case 0x8C : tft.print(" - Media Select Telephone"); break;
  722. case 0x8D : tft.print(" - Media Select Program Guide"); break;
  723. case 0x8E : tft.print(" - Media Select Video Phone"); break;
  724. case 0x8F : tft.print(" - Media Select Games"); break;
  725. case 0x90 : tft.print(" - Media Select Messages"); break;
  726. case 0x91 : tft.print(" - Media Select CD"); break;
  727. case 0x92 : tft.print(" - Media Select VCR"); break;
  728. case 0x93 : tft.print(" - Media Select Tuner"); break;
  729. case 0x94 : tft.print(" - Quit"); break;
  730. case 0x95 : tft.print(" - Help"); break;
  731. case 0x96 : tft.print(" - Media Select Tape"); break;
  732. case 0x97 : tft.print(" - Media Select Cable"); break;
  733. case 0x98 : tft.print(" - Media Select Satellite"); break;
  734. case 0x99 : tft.print(" - Media Select Security"); break;
  735. case 0x9A : tft.print(" - Media Select Home"); break;
  736. case 0x9B : tft.print(" - Media Select Call"); break;
  737. case 0x9C : tft.print(" - Channel Increment"); break;
  738. case 0x9D : tft.print(" - Channel Decrement"); break;
  739. case 0x9E : tft.print(" - Media Select SAP"); break;
  740. case 0xA0 : tft.print(" - VCR Plus"); break;
  741. case 0xA1 : tft.print(" - Once"); break;
  742. case 0xA2 : tft.print(" - Daily"); break;
  743. case 0xA3 : tft.print(" - Weekly"); break;
  744. case 0xA4 : tft.print(" - Monthly"); break;
  745. case 0xB0 : tft.print(" - Play"); break;
  746. case 0xB1 : tft.print(" - Pause"); break;
  747. case 0xB2 : tft.print(" - Record"); break;
  748. case 0xB3 : tft.print(" - Fast Forward"); break;
  749. case 0xB4 : tft.print(" - Rewind"); break;
  750. case 0xB5 : tft.print(" - Scan Next Track"); break;
  751. case 0xB6 : tft.print(" - Scan Previous Track"); break;
  752. case 0xB7 : tft.print(" - Stop"); break;
  753. case 0xB8 : tft.print(" - Eject"); break;
  754. case 0xB9 : tft.print(" - Random Play"); break;
  755. case 0xBA : tft.print(" - Select DisC"); break;
  756. case 0xBB : tft.print(" - Enter Disc"); break;
  757. case 0xBC : tft.print(" - Repeat"); break;
  758. case 0xBD : tft.print(" - Tracking"); break;
  759. case 0xBE : tft.print(" - Track Normal"); break;
  760. case 0xBF : tft.print(" - Slow Tracking"); break;
  761. case 0xC0 : tft.print(" - Frame Forward"); break;
  762. case 0xC1 : tft.print(" - Frame Back"); break;
  763. case 0xC2 : tft.print(" - Mark"); break;
  764. case 0xC3 : tft.print(" - Clear Mark"); break;
  765. case 0xC4 : tft.print(" - Repeat From Mark"); break;
  766. case 0xC5 : tft.print(" - Return To Mark"); break;
  767. case 0xC6 : tft.print(" - Search Mark Forward"); break;
  768. case 0xC7 : tft.print(" - Search Mark Backwards"); break;
  769. case 0xC8 : tft.print(" - Counter Reset"); break;
  770. case 0xC9 : tft.print(" - Show Counter"); break;
  771. case 0xCA : tft.print(" - Tracking Increment"); break;
  772. case 0xCB : tft.print(" - Tracking Decrement"); break;
  773. case 0xCD : tft.print(" - Pause/Continue"); break;
  774. case 0xE0 : tft.print(" - Volume"); break;
  775. case 0xE1 : tft.print(" - Balance"); break;
  776. case 0xE2 : tft.print(" - Mute"); break;
  777. case 0xE3 : tft.print(" - Bass"); break;
  778. case 0xE4 : tft.print(" - Treble"); break;
  779. case 0xE5 : tft.print(" - Bass Boost"); break;
  780. case 0xE6 : tft.print(" - Surround Mode"); break;
  781. case 0xE7 : tft.print(" - Loudness"); break;
  782. case 0xE8 : tft.print(" - MPX"); break;
  783. case 0xE9 : tft.print(" - Volume Up"); break;
  784. case 0xEA : tft.print(" - Volume Down"); break;
  785. case 0xF0 : tft.print(" - Speed Select"); break;
  786. case 0xF1 : tft.print(" - Playback Speed"); break;
  787. case 0xF2 : tft.print(" - Standard Play"); break;
  788. case 0xF3 : tft.print(" - Long Play"); break;
  789. case 0xF4 : tft.print(" - Extended Play"); break;
  790. case 0xF5 : tft.print(" - Slow"); break;
  791. case 0x100: tft.print(" - Fan Enable"); break;
  792. case 0x101: tft.print(" - Fan Speed"); break;
  793. case 0x102: tft.print(" - Light"); break;
  794. case 0x103: tft.print(" - Light Illumination Level"); break;
  795. case 0x104: tft.print(" - Climate Control Enable"); break;
  796. case 0x105: tft.print(" - Room Temperature"); break;
  797. case 0x106: tft.print(" - Security Enable"); break;
  798. case 0x107: tft.print(" - Fire Alarm"); break;
  799. case 0x108: tft.print(" - Police Alarm"); break;
  800. case 0x150: tft.print(" - Balance Right"); break;
  801. case 0x151: tft.print(" - Balance Left"); break;
  802. case 0x152: tft.print(" - Bass Increment"); break;
  803. case 0x153: tft.print(" - Bass Decrement"); break;
  804. case 0x154: tft.print(" - Treble Increment"); break;
  805. case 0x155: tft.print(" - Treble Decrement"); break;
  806. case 0x160: tft.print(" - Speaker System"); break;
  807. case 0x161: tft.print(" - Channel Left"); break;
  808. case 0x162: tft.print(" - Channel Right"); break;
  809. case 0x163: tft.print(" - Channel Center"); break;
  810. case 0x164: tft.print(" - Channel Front"); break;
  811. case 0x165: tft.print(" - Channel Center Front"); break;
  812. case 0x166: tft.print(" - Channel Side"); break;
  813. case 0x167: tft.print(" - Channel Surround"); break;
  814. case 0x168: tft.print(" - Channel Low Frequency Enhancement"); break;
  815. case 0x169: tft.print(" - Channel Top"); break;
  816. case 0x16A: tft.print(" - Channel Unknown"); break;
  817. case 0x170: tft.print(" - Sub-channel"); break;
  818. case 0x171: tft.print(" - Sub-channel Increment"); break;
  819. case 0x172: tft.print(" - Sub-channel Decrement"); break;
  820. case 0x173: tft.print(" - Alternate Audio Increment"); break;
  821. case 0x174: tft.print(" - Alternate Audio Decrement"); break;
  822. case 0x180: tft.print(" - Application Launch Buttons"); break;
  823. case 0x181: tft.print(" - AL Launch Button Configuration Tool"); break;
  824. case 0x182: tft.print(" - AL Programmable Button Configuration"); break;
  825. case 0x183: tft.print(" - AL Consumer Control Configuration"); break;
  826. case 0x184: tft.print(" - AL Word Processor"); break;
  827. case 0x185: tft.print(" - AL Text Editor"); break;
  828. case 0x186: tft.print(" - AL Spreadsheet"); break;
  829. case 0x187: tft.print(" - AL Graphics Editor"); break;
  830. case 0x188: tft.print(" - AL Presentation App"); break;
  831. case 0x189: tft.print(" - AL Database App"); break;
  832. case 0x18A: tft.print(" - AL Email Reader"); break;
  833. case 0x18B: tft.print(" - AL Newsreader"); break;
  834. case 0x18C: tft.print(" - AL Voicemail"); break;
  835. case 0x18D: tft.print(" - AL Contacts/Address Book"); break;
  836. case 0x18E: tft.print(" - AL Calendar/Schedule"); break;
  837. case 0x18F: tft.print(" - AL Task/Project Manager"); break;
  838. case 0x190: tft.print(" - AL Log/Journal/Timecard"); break;
  839. case 0x191: tft.print(" - AL Checkbook/Finance"); break;
  840. case 0x192: tft.print(" - AL Calculator"); break;
  841. case 0x193: tft.print(" - AL A/V Capture/Playback"); break;
  842. case 0x194: tft.print(" - AL Local Machine Browser"); break;
  843. case 0x195: tft.print(" - AL LAN/WAN Browser"); break;
  844. case 0x196: tft.print(" - AL Internet Browser"); break;
  845. case 0x197: tft.print(" - AL Remote Networking/ISP Connect"); break;
  846. case 0x198: tft.print(" - AL Network Conference"); break;
  847. case 0x199: tft.print(" - AL Network Chat"); break;
  848. case 0x19A: tft.print(" - AL Telephony/Dialer"); break;
  849. case 0x19B: tft.print(" - AL Logon"); break;
  850. case 0x19C: tft.print(" - AL Logoff"); break;
  851. case 0x19D: tft.print(" - AL Logon/Logoff"); break;
  852. case 0x19E: tft.print(" - AL Terminal Lock/Screensaver"); break;
  853. case 0x19F: tft.print(" - AL Control Panel"); break;
  854. case 0x1A0: tft.print(" - AL Command Line Processor/Run"); break;
  855. case 0x1A1: tft.print(" - AL Process/Task Manager"); break;
  856. case 0x1A2: tft.print(" - AL Select Tast/Application"); break;
  857. case 0x1A3: tft.print(" - AL Next Task/Application"); break;
  858. case 0x1A4: tft.print(" - AL Previous Task/Application"); break;
  859. case 0x1A5: tft.print(" - AL Preemptive Halt Task/Application"); break;
  860. case 0x200: tft.print(" - Generic GUI Application Controls"); break;
  861. case 0x201: tft.print(" - AC New"); break;
  862. case 0x202: tft.print(" - AC Open"); break;
  863. case 0x203: tft.print(" - AC Close"); break;
  864. case 0x204: tft.print(" - AC Exit"); break;
  865. case 0x205: tft.print(" - AC Maximize"); break;
  866. case 0x206: tft.print(" - AC Minimize"); break;
  867. case 0x207: tft.print(" - AC Save"); break;
  868. case 0x208: tft.print(" - AC Print"); break;
  869. case 0x209: tft.print(" - AC Properties"); break;
  870. case 0x21A: tft.print(" - AC Undo"); break;
  871. case 0x21B: tft.print(" - AC Copy"); break;
  872. case 0x21C: tft.print(" - AC Cut"); break;
  873. case 0x21D: tft.print(" - AC Paste"); break;
  874. case 0x21E: tft.print(" - AC Select All"); break;
  875. case 0x21F: tft.print(" - AC Find"); break;
  876. case 0x220: tft.print(" - AC Find and Replace"); break;
  877. case 0x221: tft.print(" - AC Search"); break;
  878. case 0x222: tft.print(" - AC Go To"); break;
  879. case 0x223: tft.print(" - AC Home"); break;
  880. case 0x224: tft.print(" - AC Back"); break;
  881. case 0x225: tft.print(" - AC Forward"); break;
  882. case 0x226: tft.print(" - AC Stop"); break;
  883. case 0x227: tft.print(" - AC Refresh"); break;
  884. case 0x228: tft.print(" - AC Previous Link"); break;
  885. case 0x229: tft.print(" - AC Next Link"); break;
  886. case 0x22A: tft.print(" - AC Bookmarks"); break;
  887. case 0x22B: tft.print(" - AC History"); break;
  888. case 0x22C: tft.print(" - AC Subscriptions"); break;
  889. case 0x22D: tft.print(" - AC Zoom In"); break;
  890. case 0x22E: tft.print(" - AC Zoom Out"); break;
  891. case 0x22F: tft.print(" - AC Zoom"); break;
  892. case 0x230: tft.print(" - AC Full Screen View"); break;
  893. case 0x231: tft.print(" - AC Normal View"); break;
  894. case 0x232: tft.print(" - AC View Toggle"); break;
  895. case 0x233: tft.print(" - AC Scroll Up"); break;
  896. case 0x234: tft.print(" - AC Scroll Down"); break;
  897. case 0x235: tft.print(" - AC Scroll"); break;
  898. case 0x236: tft.print(" - AC Pan Left"); break;
  899. case 0x237: tft.print(" - AC Pan Right"); break;
  900. case 0x238: tft.print(" - AC Pan"); break;
  901. case 0x239: tft.print(" - AC New Window"); break;
  902. case 0x23A: tft.print(" - AC Tile Horizontally"); break;
  903. case 0x23B: tft.print(" - AC Tile Vertically"); break;
  904. case 0x23C: tft.print(" - AC Format"); break;
  905. }
  906. }
  907. tft.println();
  908. tft.updateScreen(); // update the screen now
  909. }
  910. void OnHIDExtrasRelease(uint32_t top, uint16_t key)
  911. {
  912. tft.print("HID (");
  913. tft.print(top, HEX);
  914. tft.print(") key release:");
  915. tft.println(key, HEX);
  916. }