Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Mouse.ino 1.1KB

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