From 71ac82337f803e8ec0c081b3221ac0ccf61035b0 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 9 Oct 2012 16:50:14 +0900 Subject: Clean host.h interface. --- common/keyboard.c | 84 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 37 deletions(-) (limited to 'common/keyboard.c') diff --git a/common/keyboard.c b/common/keyboard.c index 6adad88824..37d3b06ba2 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -81,17 +81,37 @@ static inline keykind_t get_keykind(uint8_t code, bool pressed) return NONE; } +static void clear_keyboard(void) +{ + host_clear_keys(); + host_clear_mods(); + host_send_keyboard_report(); + + host_system_send(0); + host_consumer_send(0); + + mousekey_clear(); + mousekey_send(); +} + +static void clear_keyboard_but_mods(void) +{ + host_clear_keys(); + host_send_keyboard_report(); + + host_system_send(0); + host_consumer_send(0); + + mousekey_clear(); + mousekey_send(); +} + static void layer_switch_on(uint8_t code) { if (!IS_FN(code)) return; fn_state_bits |= FN_BIT(code); if (current_layer != keymap_fn_layer(FN_INDEX(code))) { - // clear all key execpt Mod key - host_clear_all_keys_but_mods(); - host_system_send(0); - host_consumer_send(0); - mousekey_clear(); - mousekey_send(); + clear_keyboard_but_mods(); debug("Layer Switch(on): "); debug_hex(current_layer); current_layer = keymap_fn_layer(FN_INDEX(code)); @@ -104,12 +124,7 @@ static void layer_switch_off(uint8_t code) if (!IS_FN(code)) return; fn_state_bits &= ~FN_BIT(code); if (current_layer != keymap_fn_layer(biton(fn_state_bits))) { - // clear all key execpt Mod key - host_clear_all_keys_but_mods(); - host_system_send(0); - host_consumer_send(0); - mousekey_clear(); - mousekey_send(); + clear_keyboard_but_mods(); debug("Layer Switch(off): "); debug_hex(current_layer); current_layer = keymap_fn_layer(biton(fn_state_bits)); @@ -117,11 +132,6 @@ static void layer_switch_off(uint8_t code) } } -static inline uint8_t get_keycode(key_t key) -{ - return keymap_get_keycode(current_layer, key.row, key.col); -} - // whether any key except modifier is down or not static inline bool is_anykey_down(void) { @@ -129,7 +139,7 @@ static inline bool is_anykey_down(void) matrix_row_t matrix_row = matrix_get_row(r); for (int c = 0; c < MATRIX_COLS; c++) { if (matrix_row && (1<