summaryrefslogtreecommitdiff
path: root/host.c
diff options
context:
space:
mode:
authortmk2012-05-27 14:19:16 +0900
committertmk2012-05-27 14:19:16 +0900
commit225de7a847a511d004bf909b1334e19497cf2f9d (patch)
treece7c4786038cd3a3bd6086db25a5061e6f51dc73 /host.c
parent7be605cce75ea572cd2eb62dca03e14d161ef467 (diff)
parent11f087002052be0aab285a77362085008e853be6 (diff)
Merge branch 'fix_layer_delay'
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;
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");
+ }
+}