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.

UsbRawHid.h 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. UsbRawHid.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 UsbRawHidDevice {
  31. public:
  32. UsbRawHidDevice();
  33. bool isUsbReady();
  34. void update() {
  35. usbPoll();
  36. }
  37. //private: TODO: Make friend?
  38. report_t reportBuffer; // buffer for HID reports [ 1 modifier byte + (len-1) key strokes]
  39. private:
  40. };
  41. #include "UsbRawHid.hxx"
  42. #endif // __UsbKeyboard_h__