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.

63 line
1.3KB

  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. USBHub hub3(myusb);
  9. KeyboardController keyboard1(myusb);
  10. KeyboardController keyboard2(myusb);
  11. USBHIDParser hid1(myusb);
  12. USBHIDParser hid2(myusb);
  13. USBHIDParser hid3(myusb);
  14. USBHIDParser hid4(myusb);
  15. USBHIDParser hid5(myusb);
  16. MouseController mouse1(myusb);
  17. void setup()
  18. {
  19. while (!Serial) ; // wait for Arduino Serial Monitor
  20. Serial.println("USB Host Testing");
  21. myusb.begin();
  22. keyboard1.attachPress(OnPress);
  23. keyboard2.attachPress(OnPress);
  24. }
  25. void loop()
  26. {
  27. myusb.Task();
  28. if(mouse1.available()) {
  29. Serial.print("buttons = ");
  30. Serial.print(mouse1.getButtons());
  31. Serial.print(", mouseX = ");
  32. Serial.print(mouse1.getMouseX());
  33. Serial.print(", mouseY = ");
  34. Serial.print(mouse1.getMouseY());
  35. Serial.print(", wheel = ");
  36. Serial.print(mouse1.getWheel());
  37. Serial.print(", wheelH = ");
  38. Serial.print(mouse1.getWheelH());
  39. Serial.println();
  40. mouse1.mouseDataClear();
  41. }
  42. }
  43. void OnPress(int key)
  44. {
  45. Serial.print("key '");
  46. Serial.print((char)key);
  47. Serial.print("' ");
  48. Serial.println(key);
  49. //Serial.print("key ");
  50. //Serial.print((char)keyboard1.getKey());
  51. //Serial.print(" ");
  52. //Serial.print((char)keyboard2.getKey());
  53. //Serial.println();
  54. }