]> git.gir.st - tmk_keyboard.git/blob - usb_keyboard.h
add build option USB_12KRO.
[tmk_keyboard.git] / usb_keyboard.h
1 #ifndef USB_KEYBOARD_H
2 #define USB_KEYBOARD_H 1
3
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include "usb.h"
7
8
9 #define KEYBOARD_INTERFACE 0
10 #define KEYBOARD_ENDPOINT 1
11 #ifdef USB_12KRO
12 #define KEYBOARD_INTERFACE2 4
13 #define KEYBOARD_ENDPOINT2 5
14 #endif
15 #define KEYBOARD_SIZE 8
16 #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER
17
18 #define BIT_LCTRL (1<<0)
19 #define BIT_LSHIFT (1<<1)
20 #define BIT_LALT (1<<2)
21 #define BIT_LGUI (1<<3)
22 #define BIT_RCTRL (1<<4)
23 #define BIT_RSHIFT (1<<5)
24 #define BIT_RALT (1<<6)
25 #define BIT_RGUI (1<<7)
26 #define BIT_LCTL BIT_LCTRL
27 #define BIT_RCTL BIT_RCTRL
28 #define BIT_LSFT BIT_LSHIFT
29 #define BIT_RSFT BIT_RSHIFT
30
31 #ifdef USB_12KRO
32 # define KEYBOARD_REPORT_MAX 12
33 #else
34 # define KEYBOARD_REPORT_MAX 6
35 #endif
36 typedef struct report {
37 uint8_t keys[KEYBOARD_REPORT_MAX];
38 uint8_t mods;
39 bool is_sent;
40 } usb_keyboard_report_t;
41
42
43 #define usb_keyboard_keys usb_keyboard_report->keys
44 #define usb_keyboard_mods usb_keyboard_report->mods
45 #define usb_keyboard_keys_prev usb_keyboard_report_prev->keys
46 #define usb_keyboard_mods_prev usb_keyboard_report_prev->mods
47
48
49 extern usb_keyboard_report_t *usb_keyboard_report;
50 extern usb_keyboard_report_t *usb_keyboard_report_prev;
51 extern uint8_t usb_keyboard_protocol;
52 extern uint8_t usb_keyboard_idle_config;
53 extern uint8_t usb_keyboard_idle_count;
54 extern volatile uint8_t usb_keyboard_leds;
55
56
57 int8_t usb_keyboard_press(uint8_t key, uint8_t modifier);
58 int8_t usb_keyboard_send(void);
59 int8_t usb_keyboard_send_report(usb_keyboard_report_t *report);
60
61 void usb_keyboard_swap_report(void);
62
63 void usb_keyboard_clear_report(void);
64 void usb_keyboard_clear_keys(void);
65 void usb_keyboard_clear_mods(void);
66
67 void usb_keyboard_set_keys(uint8_t keys[6]);
68 void usb_keyboard_set_mods(uint8_t mods);
69
70 void usb_keyboard_add_code(uint8_t code);
71 void usb_keyboard_add_key(uint8_t code);
72 void usb_keyboard_add_mod(uint8_t code);
73
74 void usb_keyboard_del_code(uint8_t code);
75 void usb_keyboard_del_key(uint8_t code);
76 void usb_keyboard_del_mod(uint8_t code);
77
78 bool usb_keyboard_is_sent(void);
79 bool usb_keyboard_has_key(void);
80 bool usb_keyboard_has_mod(void);
81
82 void usb_keyboard_print_report(usb_keyboard_report_t *report);
83
84 #endif
Imprint / Impressum