diff options
author | tmk <nobody@nowhere> | 2012-10-17 17:10:20 +0200 |
---|---|---|
committer | tmk <nobody@nowhere> | 2012-10-17 17:59:59 +0200 |
commit | fffc375b45ad795c4a8d3cde94783dac195a2613 (patch) | |
tree | 0a78cce225b04930de14935dffd36ce8f3bf2d76 /common | |
parent | ce2e06c39465b76a1780e5d594eaea7697afafd6 (diff) | |
download | qmk_firmware-fffc375b45ad795c4a8d3cde94783dac195a2613.tar.gz qmk_firmware-fffc375b45ad795c4a8d3cde94783dac195a2613.tar.xz |
Add child proof keyboard locking feature!
Fix: add wait for Power down command
Add ifdef of MOUSEKEY_ENABLE
Diffstat (limited to 'common')
-rw-r--r-- | common/command.c | 23 | ||||
-rw-r--r-- | common/keyboard.c | 2 | ||||
-rw-r--r-- | common/matrix.h | 2 |
3 files changed, 22 insertions, 5 deletions
diff --git a/common/command.c b/common/command.c index bbc45f45a..8e2e21a70 100644 --- a/common/command.c +++ b/common/command.c @@ -46,10 +46,12 @@ static bool command_common(uint8_t code); static void command_common_help(void); static bool command_console(uint8_t code); static void command_console_help(void); +#ifdef MOUSEKEY_ENABLE static bool mousekey_console(uint8_t code); static void mousekey_console_help(void); +#endif -static uint8_t kc2int(uint8_t code); +static uint8_t numkey2num(uint8_t code); static void switch_layer(uint8_t layer); static void clear_keyboard(void); @@ -68,9 +70,11 @@ bool command_proc(uint8_t code) case CONSOLE: command_console(code); break; +#ifdef MOUSEKEY_ENABLE case MOUSEKEY: mousekey_console(code); break; +#endif default: state = ONESHOT; return false; @@ -111,12 +115,24 @@ static void command_common_help(void) print("3/F3: switch to Layer3 \n"); print("4/F4: switch to Layer4 \n"); print("PScr: power down/remote wake-up\n"); + print("Caps: Lock Keyboard(Child Proof)\n"); print("Paus: jump to bootloader\n"); } static bool command_common(uint8_t code) { + static host_driver_t *host_driver = 0; switch (code) { + case KC_CAPSLOCK: + if (host_get_driver()) { + host_driver = host_get_driver(); + host_set_driver(0); + print("Locked.\n"); + } else { + host_set_driver(host_driver); + print("Unlocked.\n"); + } + break; case KC_H: case KC_SLASH: /* ? */ command_common_help(); @@ -241,6 +257,7 @@ static bool command_common(uint8_t code) } #else host_system_send(SYSTEM_POWER_DOWN); + _delay_ms(100); host_system_send(0); _delay_ms(500); #endif @@ -478,7 +495,7 @@ static bool mousekey_console(uint8_t code) case KC_8: case KC_9: case KC_0: - mousekey_param = kc2int(code); + mousekey_param = numkey2num(code); print("selected parameter: "); pdec(mousekey_param); print("\n"); break; case KC_UP: @@ -515,7 +532,7 @@ static bool mousekey_console(uint8_t code) /*********************************************************** * Utilities ***********************************************************/ -static uint8_t kc2int(uint8_t code) +static uint8_t numkey2num(uint8_t code) { switch (code) { case KC_1: return 1; diff --git a/common/keyboard.c b/common/keyboard.c index d7ced430e..e973c46d5 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -563,7 +563,7 @@ void keyboard_task(void) matrix_row = matrix_get_row(r); matrix_change = matrix_row ^ matrix_prev[r]; if (matrix_change) { - matrix_debug(); + if (debug_matrix) matrix_print(); for (int c = 0; c < MATRIX_COLS; c++) { if (matrix_change & (1<<c)) { diff --git a/common/matrix.h b/common/matrix.h index 91231e765..b3332d5ff 100644 --- a/common/matrix.h +++ b/common/matrix.h @@ -54,7 +54,7 @@ matrix_row_t matrix_get_row(uint8_t row); /* count keys pressed */ uint8_t matrix_key_count(void); /* print matrix for debug */ -void matrix_debug(void); +void matrix_print(void); #endif |