diff options
| author | tmk <nobody@nowhere> | 2012-10-18 00:10:20 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-10-18 00:59:59 +0900 |
| commit | fffc375b45ad795c4a8d3cde94783dac195a2613 (patch) | |
| tree | 0a78cce225b04930de14935dffd36ce8f3bf2d76 /common/command.c | |
| parent | ce2e06c39465b76a1780e5d594eaea7697afafd6 (diff) | |
| download | qmk_firmware-fffc375b45ad795c4a8d3cde94783dac195a2613.tar.gz qmk_firmware-fffc375b45ad795c4a8d3cde94783dac195a2613.zip | |
Add child proof keyboard locking feature!
Fix: add wait for Power down command
Add ifdef of MOUSEKEY_ENABLE
Diffstat (limited to 'common/command.c')
| -rw-r--r-- | common/command.c | 23 |
1 files changed, 20 insertions, 3 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); | |||
| 46 | static void command_common_help(void); | 46 | static void command_common_help(void); |
| 47 | static bool command_console(uint8_t code); | 47 | static bool command_console(uint8_t code); |
| 48 | static void command_console_help(void); | 48 | static void command_console_help(void); |
| 49 | #ifdef MOUSEKEY_ENABLE | ||
| 49 | static bool mousekey_console(uint8_t code); | 50 | static bool mousekey_console(uint8_t code); |
| 50 | static void mousekey_console_help(void); | 51 | static void mousekey_console_help(void); |
| 52 | #endif | ||
| 51 | 53 | ||
| 52 | static uint8_t kc2int(uint8_t code); | 54 | static uint8_t numkey2num(uint8_t code); |
| 53 | static void switch_layer(uint8_t layer); | 55 | static void switch_layer(uint8_t layer); |
| 54 | static void clear_keyboard(void); | 56 | static void clear_keyboard(void); |
| 55 | 57 | ||
| @@ -68,9 +70,11 @@ bool command_proc(uint8_t code) | |||
| 68 | case CONSOLE: | 70 | case CONSOLE: |
| 69 | command_console(code); | 71 | command_console(code); |
| 70 | break; | 72 | break; |
| 73 | #ifdef MOUSEKEY_ENABLE | ||
| 71 | case MOUSEKEY: | 74 | case MOUSEKEY: |
| 72 | mousekey_console(code); | 75 | mousekey_console(code); |
| 73 | break; | 76 | break; |
| 77 | #endif | ||
| 74 | default: | 78 | default: |
| 75 | state = ONESHOT; | 79 | state = ONESHOT; |
| 76 | return false; | 80 | return false; |
| @@ -111,12 +115,24 @@ static void command_common_help(void) | |||
| 111 | print("3/F3: switch to Layer3 \n"); | 115 | print("3/F3: switch to Layer3 \n"); |
| 112 | print("4/F4: switch to Layer4 \n"); | 116 | print("4/F4: switch to Layer4 \n"); |
| 113 | print("PScr: power down/remote wake-up\n"); | 117 | print("PScr: power down/remote wake-up\n"); |
| 118 | print("Caps: Lock Keyboard(Child Proof)\n"); | ||
| 114 | print("Paus: jump to bootloader\n"); | 119 | print("Paus: jump to bootloader\n"); |
| 115 | } | 120 | } |
| 116 | 121 | ||
| 117 | static bool command_common(uint8_t code) | 122 | static bool command_common(uint8_t code) |
| 118 | { | 123 | { |
| 124 | static host_driver_t *host_driver = 0; | ||
| 119 | switch (code) { | 125 | switch (code) { |
| 126 | case KC_CAPSLOCK: | ||
| 127 | if (host_get_driver()) { | ||
| 128 | host_driver = host_get_driver(); | ||
| 129 | host_set_driver(0); | ||
| 130 | print("Locked.\n"); | ||
| 131 | } else { | ||
| 132 | host_set_driver(host_driver); | ||
| 133 | print("Unlocked.\n"); | ||
| 134 | } | ||
| 135 | break; | ||
| 120 | case KC_H: | 136 | case KC_H: |
| 121 | case KC_SLASH: /* ? */ | 137 | case KC_SLASH: /* ? */ |
| 122 | command_common_help(); | 138 | command_common_help(); |
| @@ -241,6 +257,7 @@ static bool command_common(uint8_t code) | |||
| 241 | } | 257 | } |
| 242 | #else | 258 | #else |
| 243 | host_system_send(SYSTEM_POWER_DOWN); | 259 | host_system_send(SYSTEM_POWER_DOWN); |
| 260 | _delay_ms(100); | ||
| 244 | host_system_send(0); | 261 | host_system_send(0); |
| 245 | _delay_ms(500); | 262 | _delay_ms(500); |
| 246 | #endif | 263 | #endif |
| @@ -478,7 +495,7 @@ static bool mousekey_console(uint8_t code) | |||
| 478 | case KC_8: | 495 | case KC_8: |
| 479 | case KC_9: | 496 | case KC_9: |
| 480 | case KC_0: | 497 | case KC_0: |
| 481 | mousekey_param = kc2int(code); | 498 | mousekey_param = numkey2num(code); |
| 482 | print("selected parameter: "); pdec(mousekey_param); print("\n"); | 499 | print("selected parameter: "); pdec(mousekey_param); print("\n"); |
| 483 | break; | 500 | break; |
| 484 | case KC_UP: | 501 | case KC_UP: |
| @@ -515,7 +532,7 @@ static bool mousekey_console(uint8_t code) | |||
| 515 | /*********************************************************** | 532 | /*********************************************************** |
| 516 | * Utilities | 533 | * Utilities |
| 517 | ***********************************************************/ | 534 | ***********************************************************/ |
| 518 | static uint8_t kc2int(uint8_t code) | 535 | static uint8_t numkey2num(uint8_t code) |
| 519 | { | 536 | { |
| 520 | switch (code) { | 537 | switch (code) { |
| 521 | case KC_1: return 1; | 538 | case KC_1: return 1; |
