summaryrefslogtreecommitdiff
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 c5383ed424..cc26d55c22 100644
--- a/host.c
+++ b/host.c
@@ -35,7 +35,9 @@ report_keyboard_t *keyboard_report_prev = &report1;
static inline void add_key_byte(uint8_t code);
+static inline void del_key_byte(uint8_t code);
static inline void add_key_bit(uint8_t code);
+static inline void del_key_bit(uint8_t code);
void host_set_driver(host_driver_t *d)
@@ -66,11 +68,27 @@ void host_add_key(uint8_t key)
add_key_byte(key);
}
+void host_del_key(uint8_t key)
+{
+#ifdef NKRO_ENABLE
+ if (keyboard_nkro) {
+ del_key_bit(key);
+ return;
+ }
+#endif
+ del_key_byte(key);
+}
+
void host_add_mod_bit(uint8_t mod)
{
keyboard_report->mods |= mod;
}
+void host_del_mod_bit(uint8_t mod)
+{
+ keyboard_report->mods &= ~mod;
+}
+
void host_set_mods(uint8_t mods)
{
keyboard_report->mods = mods;
@@ -85,6 +103,15 @@ void host_add_code(uint8_t code)
}
}
+void host_del_code(uint8_t code)
+{
+ if (IS_MOD(code)) {
+ host_del_mod_bit(MOD_BIT(code));
+ } else {
+ host_del_key(code);
+ }
+}
+
void host_swap_keyboard_report(void)
{
uint8_t sreg = SREG;
@@ -180,6 +207,17 @@ static inline void add_key_byte(uint8_t code)
}
}
+static inline void del_key_byte(uint8_t code)
+{
+ int i = 0;
+ for (; i < REPORT_KEYS; i++) {
+ if (keyboard_report->keys[i] == code) {
+ keyboard_report->keys[i] = 0;
+ break;
+ }
+ }
+}
+
static inline void add_key_bit(uint8_t code)
{
if ((code>>3) < REPORT_KEYS) {
@@ -188,3 +226,12 @@ static inline void add_key_bit(uint8_t code)
debug("add_key_bit: can't add: "); phex(code); debug("\n");
}
}
+
+static inline void del_key_bit(uint8_t code)
+{
+ if ((code>>3) < REPORT_KEYS) {
+ keyboard_report->keys[code>>3] &= ~(1<<(code&7));
+ } else {
+ debug("del_key_bit: can't del: "); phex(code); debug("\n");
+ }
+}