Keyboard firmwares for Atmel AVR and Cortex-M
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.

host.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef HOST_H
  2. #define HOST_H
  3. #include <stdint.h>
  4. /* keyboard Modifiers in boot protocol report */
  5. #define BIT_LCTRL (1<<0)
  6. #define BIT_LSHIFT (1<<1)
  7. #define BIT_LALT (1<<2)
  8. #define BIT_LGUI (1<<3)
  9. #define BIT_RCTRL (1<<4)
  10. #define BIT_RSHIFT (1<<5)
  11. #define BIT_RALT (1<<6)
  12. #define BIT_RGUI (1<<7)
  13. #define BIT_LCTL BIT_LCTRL
  14. #define BIT_RCTL BIT_RCTRL
  15. #define BIT_LSFT BIT_LSHIFT
  16. #define BIT_RSFT BIT_RSHIFT
  17. /* mouse buttons */
  18. #define MOUSE_BTN1 (1<<0)
  19. #define MOUSE_BTN2 (1<<1)
  20. #define MOUSE_BTN3 (1<<2)
  21. #define MOUSE_BTN4 (1<<3)
  22. #define MOUSE_BTN5 (1<<4)
  23. #define REPORT_KEYS 6
  24. typedef struct {
  25. uint8_t mods;
  26. uint8_t rserved;
  27. uint8_t keys[REPORT_KEYS];
  28. } report_keyboard_t;
  29. typedef struct {
  30. uint8_t buttons;
  31. int8_t x;
  32. int8_t y;
  33. /*
  34. int8_t v;
  35. int8_t h;
  36. */
  37. } report_mouse_t;
  38. extern report_keyboard_t *keyboard_report;
  39. extern report_keyboard_t *keyboard_report_prev;
  40. /* keyboard report operations */
  41. void host_add_key(uint8_t key);
  42. void host_add_mod_bit(uint8_t mod);
  43. void host_set_mods(uint8_t mods);
  44. void host_add_code(uint8_t code);
  45. void host_swap_keyboard_report(void);
  46. void host_clear_keyboard_report(void);
  47. uint8_t host_has_anykey(void);
  48. uint8_t *host_get_keys(void);
  49. uint8_t host_get_mods(void);
  50. void host_send_keyboard_report(void);
  51. void host_send_mouse_report(void);
  52. void host_mouse_send(report_mouse_t *report);
  53. #endif