diff options
Diffstat (limited to 'pjrc/usb_keyboard.h')
| -rw-r--r-- | pjrc/usb_keyboard.h | 68 |
1 files changed, 3 insertions, 65 deletions
diff --git a/pjrc/usb_keyboard.h b/pjrc/usb_keyboard.h index 53de4336d..22287a056 100644 --- a/pjrc/usb_keyboard.h +++ b/pjrc/usb_keyboard.h | |||
| @@ -4,78 +4,16 @@ | |||
| 4 | #include <stdint.h> | 4 | #include <stdint.h> |
| 5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
| 6 | #include "usb.h" | 6 | #include "usb.h" |
| 7 | #include "host.h" | ||
| 7 | 8 | ||
| 8 | 9 | ||
| 9 | #define KBD_INTERFACE 0 | ||
| 10 | #define KBD_ENDPOINT 1 | ||
| 11 | #define KBD_SIZE 8 | ||
| 12 | #define KBD_BUFFER EP_DOUBLE_BUFFER | ||
| 13 | #define KBD_REPORT_KEYS (KBD_SIZE - 2) | ||
| 14 | |||
| 15 | // secondary keyboard | ||
| 16 | #ifdef USB_NKRO_ENABLE | ||
| 17 | #define KBD2_INTERFACE 4 | ||
| 18 | #define KBD2_ENDPOINT 5 | ||
| 19 | #define KBD2_SIZE 16 | ||
| 20 | #define KBD2_BUFFER EP_DOUBLE_BUFFER | ||
| 21 | #define KBD2_REPORT_KEYS (KBD2_SIZE - 1) | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS | ||
| 25 | #define KEYS_MAX KBD2_REPORT_KEYS | ||
| 26 | #else | ||
| 27 | #define KEYS_MAX KBD_REPORT_KEYS | ||
| 28 | #endif | ||
| 29 | |||
| 30 | |||
| 31 | typedef struct report { | ||
| 32 | uint8_t keys[KEYS_MAX]; | ||
| 33 | uint8_t mods; | ||
| 34 | bool is_sent; | ||
| 35 | } usb_keyboard_report_t; | ||
| 36 | |||
| 37 | |||
| 38 | #define usb_keyboard_keys usb_keyboard_report->keys | ||
| 39 | #define usb_keyboard_mods usb_keyboard_report->mods | ||
| 40 | #define usb_keyboard_keys_prev usb_keyboard_report_prev->keys | ||
| 41 | #define usb_keyboard_mods_prev usb_keyboard_report_prev->mods | ||
| 42 | |||
| 43 | |||
| 44 | extern usb_keyboard_report_t *usb_keyboard_report; | ||
| 45 | extern usb_keyboard_report_t *usb_keyboard_report_prev; | ||
| 46 | extern uint8_t usb_keyboard_protocol; | 10 | extern uint8_t usb_keyboard_protocol; |
| 47 | extern uint8_t usb_keyboard_idle_config; | 11 | extern uint8_t usb_keyboard_idle_config; |
| 48 | extern uint8_t usb_keyboard_idle_count; | 12 | extern uint8_t usb_keyboard_idle_count; |
| 49 | extern volatile uint8_t usb_keyboard_leds; | 13 | extern volatile uint8_t usb_keyboard_leds; |
| 50 | extern bool usb_keyboard_nkro; | ||
| 51 | |||
| 52 | |||
| 53 | int8_t usb_keyboard_send(void); | ||
| 54 | int8_t usb_keyboard_send_report(usb_keyboard_report_t *report); | ||
| 55 | |||
| 56 | void usb_keyboard_swap_report(void); | ||
| 57 | |||
| 58 | void usb_keyboard_clear_report(void); | ||
| 59 | void usb_keyboard_clear_keys(void); | ||
| 60 | void usb_keyboard_clear_mods(void); | ||
| 61 | |||
| 62 | void usb_keyboard_set_keys(uint8_t *keys); | ||
| 63 | void usb_keyboard_set_mods(uint8_t mods); | ||
| 64 | |||
| 65 | void usb_keyboard_add_code(uint8_t code); | ||
| 66 | void usb_keyboard_add_key(uint8_t code); | ||
| 67 | void usb_keyboard_add_mod(uint8_t code); | ||
| 68 | |||
| 69 | void usb_keyboard_del_code(uint8_t code); | ||
| 70 | void usb_keyboard_del_key(uint8_t code); | ||
| 71 | void usb_keyboard_del_mod(uint8_t code); | ||
| 72 | |||
| 73 | bool usb_keyboard_is_sent(void); | ||
| 74 | bool usb_keyboard_has_key(void); | ||
| 75 | bool usb_keyboard_has_mod(void); | ||
| 76 | 14 | ||
| 77 | uint8_t usb_keyboard_get_key(void); | ||
| 78 | 15 | ||
| 79 | void usb_keyboard_print_report(usb_keyboard_report_t *report); | 16 | int8_t usb_keyboard_send_report(report_keyboard_t *report); |
| 17 | void usb_keyboard_print_report(report_keyboard_t *report); | ||
| 80 | 18 | ||
| 81 | #endif | 19 | #endif |
