2 #define USB_KEYBOARD_H 1
9 #define KBD_INTERFACE 0
10 #define KBD_ENDPOINT 1
12 #define KBD_BUFFER EP_DOUBLE_BUFFER
13 #define KBD_REPORT_KEYS (KBD_SIZE - 2)
16 #ifdef USB_NKRO_ENABLE
17 #define KBD2_INTERFACE 4
18 #define KBD2_ENDPOINT 5
20 #define KBD2_BUFFER EP_DOUBLE_BUFFER
21 #define KBD2_REPORT_KEYS (KBD2_SIZE - 1)
24 #if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
25 #define KEYS_MAX KBD2_REPORT_KEYS
27 #define KEYS_MAX KBD_REPORT_KEYS
30 #define BIT_LCTRL (1<<0)
31 #define BIT_LSHIFT (1<<1)
32 #define BIT_LALT (1<<2)
33 #define BIT_LGUI (1<<3)
34 #define BIT_RCTRL (1<<4)
35 #define BIT_RSHIFT (1<<5)
36 #define BIT_RALT (1<<6)
37 #define BIT_RGUI (1<<7)
38 #define BIT_LCTL BIT_LCTRL
39 #define BIT_RCTL BIT_RCTRL
40 #define BIT_LSFT BIT_LSHIFT
41 #define BIT_RSFT BIT_RSHIFT
43 typedef struct report {
44 uint8_t keys[KEYS_MAX];
47 } usb_keyboard_report_t;
50 #define usb_keyboard_keys usb_keyboard_report->keys
51 #define usb_keyboard_mods usb_keyboard_report->mods
52 #define usb_keyboard_keys_prev usb_keyboard_report_prev->keys
53 #define usb_keyboard_mods_prev usb_keyboard_report_prev->mods
56 extern usb_keyboard_report_t *usb_keyboard_report;
57 extern usb_keyboard_report_t *usb_keyboard_report_prev;
58 extern uint8_t usb_keyboard_protocol;
59 extern uint8_t usb_keyboard_idle_config;
60 extern uint8_t usb_keyboard_idle_count;
61 extern volatile uint8_t usb_keyboard_leds;
62 extern bool usb_keyboard_nkro;
65 int8_t usb_keyboard_send(void);
66 int8_t usb_keyboard_send_report(usb_keyboard_report_t *report);
68 void usb_keyboard_swap_report(void);
70 void usb_keyboard_clear_report(void);
71 void usb_keyboard_clear_keys(void);
72 void usb_keyboard_clear_mods(void);
74 void usb_keyboard_set_keys(uint8_t *keys);
75 void usb_keyboard_set_mods(uint8_t mods);
77 void usb_keyboard_add_code(uint8_t code);
78 void usb_keyboard_add_key(uint8_t code);
79 void usb_keyboard_add_mod(uint8_t code);
81 void usb_keyboard_del_code(uint8_t code);
82 void usb_keyboard_del_key(uint8_t code);
83 void usb_keyboard_del_mod(uint8_t code);
85 bool usb_keyboard_is_sent(void);
86 bool usb_keyboard_has_key(void);
87 bool usb_keyboard_has_mod(void);
89 uint8_t usb_keyboard_get_key(void);
91 void usb_keyboard_print_report(usb_keyboard_report_t *report);