aboutsummaryrefslogtreecommitdiff
path: root/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'host.c')
-rw-r--r--host.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/host.c b/host.c
index c5383ed42..cc26d55c2 100644
--- a/host.c
+++ b/host.c
@@ -35,7 +35,9 @@ report_keyboard_t *keyboard_report_prev = &report1;
35 35
36 36
37static inline void add_key_byte(uint8_t code); 37static inline void add_key_byte(uint8_t code);
38static inline void del_key_byte(uint8_t code);
38static inline void add_key_bit(uint8_t code); 39static inline void add_key_bit(uint8_t code);
40static inline void del_key_bit(uint8_t code);
39 41
40 42
41void host_set_driver(host_driver_t *d) 43void host_set_driver(host_driver_t *d)
@@ -66,11 +68,27 @@ void host_add_key(uint8_t key)
66 add_key_byte(key); 68 add_key_byte(key);
67} 69}
68 70
71void host_del_key(uint8_t key)
72{
73#ifdef NKRO_ENABLE
74 if (keyboard_nkro) {
75 del_key_bit(key);
76 return;
77 }
78#endif
79 del_key_byte(key);
80}
81
69void host_add_mod_bit(uint8_t mod) 82void host_add_mod_bit(uint8_t mod)
70{ 83{
71 keyboard_report->mods |= mod; 84 keyboard_report->mods |= mod;
72} 85}
73 86
87void host_del_mod_bit(uint8_t mod)
88{
89 keyboard_report->mods &= ~mod;
90}
91
74void host_set_mods(uint8_t mods) 92void host_set_mods(uint8_t mods)
75{ 93{
76 keyboard_report->mods = mods; 94 keyboard_report->mods = mods;
@@ -85,6 +103,15 @@ void host_add_code(uint8_t code)
85 } 103 }
86} 104}
87 105
106void host_del_code(uint8_t code)
107{
108 if (IS_MOD(code)) {
109 host_del_mod_bit(MOD_BIT(code));
110 } else {
111 host_del_key(code);
112 }
113}
114
88void host_swap_keyboard_report(void) 115void host_swap_keyboard_report(void)
89{ 116{
90 uint8_t sreg = SREG; 117 uint8_t sreg = SREG;
@@ -180,6 +207,17 @@ static inline void add_key_byte(uint8_t code)
180 } 207 }
181} 208}
182 209
210static inline void del_key_byte(uint8_t code)
211{
212 int i = 0;
213 for (; i < REPORT_KEYS; i++) {
214 if (keyboard_report->keys[i] == code) {
215 keyboard_report->keys[i] = 0;
216 break;
217 }
218 }
219}
220
183static inline void add_key_bit(uint8_t code) 221static inline void add_key_bit(uint8_t code)
184{ 222{
185 if ((code>>3) < REPORT_KEYS) { 223 if ((code>>3) < REPORT_KEYS) {
@@ -188,3 +226,12 @@ static inline void add_key_bit(uint8_t code)
188 debug("add_key_bit: can't add: "); phex(code); debug("\n"); 226 debug("add_key_bit: can't add: "); phex(code); debug("\n");
189 } 227 }
190} 228}
229
230static inline void del_key_bit(uint8_t code)
231{
232 if ((code>>3) < REPORT_KEYS) {
233 keyboard_report->keys[code>>3] &= ~(1<<(code&7));
234 } else {
235 debug("del_key_bit: can't del: "); phex(code); debug("\n");
236 }
237}