Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UsbMouse.h 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Based on Obdev's AVRUSB code and under the same license.
  3. * Modified by Robin Thoni <robin@rthoni.com>
  4. */
  5. #ifndef __UsbKeyboard_h__
  6. #define __UsbKeyboard_h__
  7. #include <avr/pgmspace.h>
  8. #include <avr/interrupt.h>
  9. #include <string.h>
  10. #include "usbdrv.h"
  11. // TODO: Work around Arduino 12 issues better.
  12. //#include <WConstants.h>
  13. //#undef int()
  14. typedef uint8_t byte;
  15. #define WAIT_USB do { \
  16. UsbMouse.update(); \
  17. if (!usbInterruptIsReady()) \
  18. { \
  19. return; \
  20. } \
  21. } while(0)
  22. #define BUFFER_SIZE 4 // Minimum of 2: 1 for modifiers + 1 for keystroke
  23. typedef struct{
  24. uchar buttonMask;
  25. char dx;
  26. char dy;
  27. char dWheel;
  28. }report_t;
  29. static uchar idleRate;/* repeat rate for keyboards, never used for mice */
  30. class UsbMouseDevice {
  31. public:
  32. UsbMouseDevice();
  33. bool isUsbReady();
  34. void update() {
  35. usbPoll();
  36. }
  37. void move(char dx, char dy);
  38. void updateStatus();
  39. //private: TODO: Make friend?
  40. report_t reportBuffer; // buffer for HID reports [ 1 modifier byte + (len-1) key strokes]
  41. private:
  42. };
  43. #include "UsbMouse.hxx"
  44. #endif // __UsbKeyboard_h__