Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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