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.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #if defined(HOST_PJRC)
  24. # include "usb.h"
  25. # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
  26. # define REPORT_KEYS KBD2_REPORT_KEYS
  27. # else
  28. # define REPORT_KEYS KBD_REPORT_KEYS
  29. # endif
  30. #elif defined(HOST_VUSB)
  31. # define REPORT_KEYS 6
  32. #endif
  33. typedef struct {
  34. uint8_t mods;
  35. uint8_t rserved;
  36. uint8_t keys[REPORT_KEYS];
  37. } report_keyboard_t;
  38. typedef struct {
  39. uint8_t buttons;
  40. int8_t x;
  41. int8_t y;
  42. int8_t v;
  43. int8_t h;
  44. } report_mouse_t;
  45. #ifdef USB_NKRO_ENABLE
  46. extern bool keyboard_nkro;
  47. #endif
  48. extern report_keyboard_t *keyboard_report;
  49. extern report_keyboard_t *keyboard_report_prev;
  50. uint8_t host_keyboard_leds(void);
  51. /* keyboard report operations */
  52. void host_add_key(uint8_t key);
  53. void host_add_mod_bit(uint8_t mod);
  54. void host_set_mods(uint8_t mods);
  55. void host_add_code(uint8_t code);
  56. void host_swap_keyboard_report(void);
  57. void host_clear_keyboard_report(void);
  58. uint8_t host_has_anykey(void);
  59. uint8_t *host_get_keys(void);
  60. uint8_t host_get_mods(void);
  61. void host_send_keyboard_report(void);
  62. void host_mouse_send(report_mouse_t *report);
  63. #endif