Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Based on Obdev's AVRUSB code and under the same license.
  3. *
  4. * TODO: Make a proper file header. :-)
  5. */
  6. #ifndef __UsbKeyboard_h__
  7. #define __UsbKeyboard_h__
  8. #include <avr/pgmspace.h>
  9. #include <avr/interrupt.h>
  10. #include <string.h>
  11. #include "usbdrv.h"
  12. // TODO: Work around Arduino 12 issues better.
  13. //#include <WConstants.h>
  14. //#undef int()
  15. typedef uint8_t byte;
  16. #define WAIT_USB do { \
  17. UsbKeyboard.update(); \
  18. if (!usbInterruptIsReady()) \
  19. { \
  20. return; \
  21. } \
  22. } while(0)
  23. #define BUFFER_SIZE 4 // Minimum of 2: 1 for modifiers + 1 for keystroke
  24. static uchar idleRate; // in 4 ms units
  25. #include "keycodes.h"
  26. class UsbKeyboardDevice {
  27. public:
  28. UsbKeyboardDevice (const char* layout);
  29. void setLayout(const char* layout);
  30. bool isUsbReady();
  31. void update() {
  32. usbPoll();
  33. }
  34. void sendKeyStrokes(const char* str);
  35. void sendKeyStroke(byte keyStroke) {
  36. sendKeyStroke(keyStroke, 0);
  37. }
  38. void sendKeyStroke(byte keyStroke, byte modifiers);
  39. #ifdef ARD_USBKBD_AZERTY
  40. static int charToKeyAzerty(int, int*);
  41. #endif
  42. #ifdef ARD_USBKBD_QWERTY
  43. static int charToKeyQwerty(int, int*);
  44. #endif
  45. //private: TODO: Make friend?
  46. uchar reportBuffer[4]; // buffer for HID reports [ 1 modifier byte + (len-1) key strokes]
  47. private:
  48. char* _layout;
  49. static int charModAltGr(char, int*);
  50. static int charModShift(char, int*);
  51. };
  52. #include "UsbKeyboard.hxx"
  53. #endif // __UsbKeyboard_h__