X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=common%2Fcommand.c;h=7bb2a23f1909ec21629aa375303f7c43fb24670a;hb=6215727b0bd827a18456b21a26d6175abe365ada;hp=a06e6a00d15128606c3adb5978127bd2eb4f64ad;hpb=220de27bed198c2ea27886986de7afd8013d5545;p=max%2Ftmk_keyboard.git diff --git a/common/command.c b/common/command.c index a06e6a00..7bb2a23f 100644 --- a/common/command.c +++ b/common/command.c @@ -19,6 +19,7 @@ along with this program. If not, see . #include #include "keycode.h" #include "host.h" +#include "keymap.h" #include "print.h" #include "debug.h" #include "util.h" @@ -53,7 +54,6 @@ static void mousekey_console_help(void); static uint8_t numkey2num(uint8_t code); static void switch_layer(uint8_t layer); -static void clear_keyboard(void); typedef enum { ONESHOT, CONSOLE, MOUSEKEY } cmdstate_t; @@ -234,6 +234,7 @@ static bool command_common(uint8_t code) break; #ifdef NKRO_ENABLE case KC_N: + clear_keyboard(); //Prevents stuck keys. keyboard_nkro = !keyboard_nkro; if (keyboard_nkro) print("NKRO: enabled\n"); @@ -262,23 +263,16 @@ static bool command_common(uint8_t code) #endif case KC_0: case KC_F10: + clear_keyboard(); switch_layer(0); break; - case KC_1: - case KC_F1: - switch_layer(1); - break; - case KC_2: - case KC_F2: - switch_layer(2); - break; - case KC_3: - case KC_F3: - switch_layer(3); + case KC_1 ... KC_9: + clear_keyboard(); + switch_layer((code - KC_1) + 1); break; - case KC_4: - case KC_F4: - switch_layer(4); + case KC_F1 ... KC_F9: + clear_keyboard(); + switch_layer((code - KC_F1) + 1); break; default: print("?"); @@ -555,18 +549,3 @@ static void switch_layer(uint8_t layer) default_layer = layer; print("switch to "); print_val_hex8(layer); } - -static void clear_keyboard(void) -{ - host_clear_keys(); - host_clear_mods(); - host_send_keyboard_report(); - - host_system_send(0); - host_consumer_send(0); - -#ifdef MOUSEKEY_ENABLE - mousekey_clear(); - mousekey_send(); -#endif -}