diff options
| author | tmk <nobody@nowhere> | 2012-10-17 03:44:01 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-10-17 15:55:37 +0900 |
| commit | 30eb3e3520e9d4d7b9a9dbac0c5c0200485103c2 (patch) | |
| tree | c95f8e39411cf05e5f393948b3a3a1b85deec5b9 /common | |
| parent | 8f7ed2bc1902cdeeb78c49f4833816a33cd6d3a0 (diff) | |
| download | qmk_firmware-30eb3e3520e9d4d7b9a9dbac0c5c0200485103c2.tar.gz qmk_firmware-30eb3e3520e9d4d7b9a9dbac0c5c0200485103c2.zip | |
Add command console and mouseky parameters tweak.
Diffstat (limited to 'common')
| -rw-r--r-- | common/command.c | 427 | ||||
| -rw-r--r-- | common/keyboard.c | 38 | ||||
| -rw-r--r-- | common/print.c | 8 | ||||
| -rw-r--r-- | common/print.h | 1 |
4 files changed, 395 insertions, 79 deletions
diff --git a/common/command.c b/common/command.c index 0ad06e65b..bbc45f45a 100644 --- a/common/command.c +++ b/common/command.c | |||
| @@ -43,29 +43,42 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | static bool command_common(uint8_t code); | 45 | static bool command_common(uint8_t code); |
| 46 | static void help(void); | 46 | static void command_common_help(void); |
| 47 | static bool command_console(uint8_t code); | ||
| 48 | static void command_console_help(void); | ||
| 49 | static bool mousekey_console(uint8_t code); | ||
| 50 | static void mousekey_console_help(void); | ||
| 51 | |||
| 52 | static uint8_t kc2int(uint8_t code); | ||
| 47 | static void switch_layer(uint8_t layer); | 53 | static void switch_layer(uint8_t layer); |
| 48 | static void clear_keyboard(void); | 54 | static void clear_keyboard(void); |
| 49 | 55 | ||
| 50 | static bool last_print_enable; | 56 | |
| 57 | typedef enum { ONESHOT, CONSOLE, MOUSEKEY } cmdstate_t; | ||
| 58 | static cmdstate_t state = ONESHOT; | ||
| 51 | 59 | ||
| 52 | 60 | ||
| 53 | bool command_proc(uint8_t code) | 61 | bool command_proc(uint8_t code) |
| 54 | { | 62 | { |
| 55 | if (!IS_COMMAND()) | 63 | switch (state) { |
| 56 | return false; | 64 | case ONESHOT: |
| 57 | 65 | if (!IS_COMMAND()) | |
| 58 | last_print_enable = print_enable; | 66 | return false; |
| 59 | print_enable = true; | 67 | return (command_extra(code) || command_common(code)); |
| 60 | if (command_extra(code) || command_common(code)) { | 68 | case CONSOLE: |
| 61 | _delay_ms(500); | 69 | command_console(code); |
| 62 | return true; | 70 | break; |
| 71 | case MOUSEKEY: | ||
| 72 | mousekey_console(code); | ||
| 73 | break; | ||
| 74 | default: | ||
| 75 | state = ONESHOT; | ||
| 76 | return false; | ||
| 63 | } | 77 | } |
| 64 | print_enable = last_print_enable; | 78 | return true; |
| 65 | return false; | ||
| 66 | } | 79 | } |
| 67 | 80 | ||
| 68 | /* This allows to define extra commands. return 0 when not processed. */ | 81 | /* This allows to define extra commands. return false when not processed. */ |
| 69 | bool command_extra(uint8_t code) __attribute__ ((weak)); | 82 | bool command_extra(uint8_t code) __attribute__ ((weak)); |
| 70 | bool command_extra(uint8_t code) | 83 | bool command_extra(uint8_t code) |
| 71 | { | 84 | { |
| @@ -73,72 +86,122 @@ bool command_extra(uint8_t code) | |||
| 73 | } | 86 | } |
| 74 | 87 | ||
| 75 | 88 | ||
| 89 | /*********************************************************** | ||
| 90 | * Command common | ||
| 91 | ***********************************************************/ | ||
| 92 | static void command_common_help(void) | ||
| 93 | { | ||
| 94 | print_enable = true; | ||
| 95 | print("\n\n----- Command Help -----\n"); | ||
| 96 | print("c: enter console mode\n"); | ||
| 97 | print("d: toggle debug enable\n"); | ||
| 98 | print("x: toggle matrix debug\n"); | ||
| 99 | print("k: toggle keyboard debug\n"); | ||
| 100 | print("m: toggle mouse debug\n"); | ||
| 101 | print("p: toggle print enable\n"); | ||
| 102 | print("v: print device version & info\n"); | ||
| 103 | print("t: print timer count\n"); | ||
| 104 | print("s: print status\n"); | ||
| 105 | #ifdef NKRO_ENABLE | ||
| 106 | print("n: toggle NKRO\n"); | ||
| 107 | #endif | ||
| 108 | print("0/F10: switch to Layer0 \n"); | ||
| 109 | print("1/F1: switch to Layer1 \n"); | ||
| 110 | print("2/F2: switch to Layer2 \n"); | ||
| 111 | print("3/F3: switch to Layer3 \n"); | ||
| 112 | print("4/F4: switch to Layer4 \n"); | ||
| 113 | print("PScr: power down/remote wake-up\n"); | ||
| 114 | print("Paus: jump to bootloader\n"); | ||
| 115 | } | ||
| 116 | |||
| 76 | static bool command_common(uint8_t code) | 117 | static bool command_common(uint8_t code) |
| 77 | { | 118 | { |
| 78 | switch (code) { | 119 | switch (code) { |
| 79 | case KC_H: | 120 | case KC_H: |
| 80 | help(); | 121 | case KC_SLASH: /* ? */ |
| 122 | command_common_help(); | ||
| 81 | break; | 123 | break; |
| 82 | case KC_DEL: | 124 | case KC_C: |
| 125 | print_enable = true; | ||
| 126 | debug_matrix = false; | ||
| 127 | debug_keyboard = false; | ||
| 128 | debug_mouse = false; | ||
| 129 | debug_enable = false; | ||
| 130 | command_console_help(); | ||
| 131 | print("\nEnter Console Mode\n"); | ||
| 132 | print("C> "); | ||
| 133 | state = CONSOLE; | ||
| 134 | break; | ||
| 135 | case KC_PAUSE: | ||
| 83 | clear_keyboard(); | 136 | clear_keyboard(); |
| 84 | print("jump to bootloader... "); | 137 | print("\n\nJump to bootloader... "); |
| 85 | _delay_ms(1000); | 138 | _delay_ms(1000); |
| 86 | bootloader_jump(); // not return | 139 | bootloader_jump(); // not return |
| 87 | print("not supported.\n"); | 140 | print("not supported.\n"); |
| 88 | break; | 141 | break; |
| 89 | case KC_D: | 142 | case KC_D: |
| 90 | debug_enable = !debug_enable; | ||
| 91 | if (debug_enable) { | 143 | if (debug_enable) { |
| 92 | last_print_enable = true; | 144 | print("\nDEBUG: disabled.\n"); |
| 93 | print("debug enabled.\n"); | 145 | debug_matrix = false; |
| 94 | debug_matrix = true; | ||
| 95 | debug_keyboard = true; | ||
| 96 | debug_mouse = true; | ||
| 97 | } else { | ||
| 98 | print("debug disabled.\n"); | ||
| 99 | last_print_enable = false; | ||
| 100 | debug_matrix = false; | ||
| 101 | debug_keyboard = false; | 146 | debug_keyboard = false; |
| 102 | debug_mouse = false; | 147 | debug_mouse = false; |
| 148 | debug_enable = false; | ||
| 149 | } else { | ||
| 150 | print("\nDEBUG: enabled.\n"); | ||
| 151 | debug_matrix = true; | ||
| 152 | debug_keyboard = true; | ||
| 153 | debug_mouse = true; | ||
| 154 | debug_enable = true; | ||
| 103 | } | 155 | } |
| 104 | break; | 156 | break; |
| 105 | case KC_X: // debug matrix toggle | 157 | case KC_X: // debug matrix toggle |
| 106 | debug_matrix = !debug_matrix; | 158 | debug_matrix = !debug_matrix; |
| 107 | if (debug_matrix) | 159 | if (debug_matrix) { |
| 108 | print("debug matrix enabled.\n"); | 160 | print("\nDEBUG: matrix enabled.\n"); |
| 109 | else | 161 | debug_enable = true; |
| 110 | print("debug matrix disabled.\n"); | 162 | } else { |
| 163 | print("\nDEBUG: matrix disabled.\n"); | ||
| 164 | } | ||
| 111 | break; | 165 | break; |
| 112 | case KC_K: // debug keyboard toggle | 166 | case KC_K: // debug keyboard toggle |
| 113 | debug_keyboard = !debug_keyboard; | 167 | debug_keyboard = !debug_keyboard; |
| 114 | if (debug_keyboard) | 168 | if (debug_keyboard) { |
| 115 | print("debug keyboard enabled.\n"); | 169 | print("\nDEBUG: keyboard enabled.\n"); |
| 116 | else | 170 | debug_enable = true; |
| 117 | print("debug keyboard disabled.\n"); | 171 | } else { |
| 172 | print("\nDEBUG: keyboard disabled.\n"); | ||
| 173 | } | ||
| 118 | break; | 174 | break; |
| 119 | case KC_M: // debug mouse toggle | 175 | case KC_M: // debug mouse toggle |
| 120 | debug_mouse = !debug_mouse; | 176 | debug_mouse = !debug_mouse; |
| 121 | if (debug_mouse) | 177 | if (debug_mouse) { |
| 122 | print("debug mouse enabled.\n"); | 178 | print("\nDEBUG: mouse enabled.\n"); |
| 123 | else | 179 | debug_enable = true; |
| 124 | print("debug mouse disabled.\n"); | 180 | } else { |
| 181 | print("\nDEBUG: mouse disabled.\n"); | ||
| 182 | } | ||
| 125 | break; | 183 | break; |
| 126 | case KC_V: // print version & information | 184 | case KC_V: // print version & information |
| 185 | print("\n\n----- Version -----\n"); | ||
| 127 | print(STR(DESCRIPTION) "\n"); | 186 | print(STR(DESCRIPTION) "\n"); |
| 187 | print(STR(MANUFACTURER) "(" STR(VENDOR_ID) ")/"); | ||
| 188 | print(STR(PRODUCT) "(" STR(PRODUCT_ID) ") "); | ||
| 189 | print("VERSION: " STR(DEVICE_VER) "\n"); | ||
| 128 | break; | 190 | break; |
| 129 | case KC_T: // print timer | 191 | case KC_T: // print timer |
| 130 | print("timer: "); phex16(timer_count); print("\n"); | 192 | print("timer: "); phex16(timer_count>>16); phex16(timer_count); print("\n"); |
| 131 | break; | 193 | break; |
| 132 | case KC_P: // print toggle | 194 | case KC_P: // print toggle |
| 133 | if (last_print_enable) { | 195 | if (print_enable) { |
| 134 | print("print disabled.\n"); | 196 | print("print disabled.\n"); |
| 135 | last_print_enable = false; | 197 | print_enable = false; |
| 136 | } else { | 198 | } else { |
| 137 | last_print_enable = true; | 199 | print_enable = true; |
| 138 | print("print enabled.\n"); | 200 | print("print enabled.\n"); |
| 139 | } | 201 | } |
| 140 | break; | 202 | break; |
| 141 | case KC_S: | 203 | case KC_S: |
| 204 | print("\n\n----- Status -----\n"); | ||
| 142 | print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n"); | 205 | print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n"); |
| 143 | #ifdef HOST_PJRC | 206 | #ifdef HOST_PJRC |
| 144 | print("UDCON: "); phex(UDCON); print("\n"); | 207 | print("UDCON: "); phex(UDCON); print("\n"); |
| @@ -166,7 +229,8 @@ static bool command_common(uint8_t code) | |||
| 166 | break; | 229 | break; |
| 167 | #endif | 230 | #endif |
| 168 | #ifdef EXTRAKEY_ENABLE | 231 | #ifdef EXTRAKEY_ENABLE |
| 169 | case KC_ESC: | 232 | case KC_PSCREEN: |
| 233 | // TODO: Power key should take this feature? otherwise any key during suspend. | ||
| 170 | #ifdef HOST_PJRC | 234 | #ifdef HOST_PJRC |
| 171 | if (suspend && remote_wakeup) { | 235 | if (suspend && remote_wakeup) { |
| 172 | usb_remote_wakeup(); | 236 | usb_remote_wakeup(); |
| @@ -203,31 +267,269 @@ static bool command_common(uint8_t code) | |||
| 203 | switch_layer(4); | 267 | switch_layer(4); |
| 204 | break; | 268 | break; |
| 205 | default: | 269 | default: |
| 270 | print("?"); | ||
| 206 | return false; | 271 | return false; |
| 207 | } | 272 | } |
| 208 | return true; | 273 | return true; |
| 209 | } | 274 | } |
| 210 | 275 | ||
| 211 | static void help(void) | 276 | |
| 277 | /*********************************************************** | ||
| 278 | * Command console | ||
| 279 | ***********************************************************/ | ||
| 280 | static void command_console_help(void) | ||
| 212 | { | 281 | { |
| 213 | print("d: toggle debug enable\n"); | 282 | print_enable = true; |
| 214 | print("x: toggle matrix debug\n"); | 283 | print("\n\n----- Console Help -----\n"); |
| 215 | print("k: toggle keyboard debug\n"); | 284 | print("ESC/q: quit\n"); |
| 216 | print("m: toggle mouse debug\n"); | 285 | #ifdef MOUSEKEY_ENABLE |
| 217 | print("p: toggle print enable\n"); | 286 | print("m: mousekey\n"); |
| 218 | print("v: print version\n"); | 287 | #endif |
| 219 | print("t: print timer count\n"); | 288 | } |
| 220 | print("s: print status\n"); | 289 | |
| 221 | print("ESC: power down/wake up\n"); | 290 | static bool command_console(uint8_t code) |
| 222 | print("0/F10: switch to Layer0 \n"); | 291 | { |
| 223 | print("1/F1: switch to Layer1 \n"); | 292 | switch (code) { |
| 224 | print("2/F2: switch to Layer2 \n"); | 293 | case KC_H: |
| 225 | print("3/F3: switch to Layer3 \n"); | 294 | case KC_SLASH: /* ? */ |
| 226 | print("4/F4: switch to Layer4 \n"); | 295 | command_console_help(); |
| 227 | #ifdef NKRO_ENABLE | 296 | break; |
| 228 | print("n: toggle NKRO\n"); | 297 | case KC_Q: |
| 298 | case KC_ESC: | ||
| 299 | print("\nQuit Console Mode\n"); | ||
| 300 | state = ONESHOT; | ||
| 301 | return false; | ||
| 302 | #ifdef MOUSEKEY_ENABLE | ||
| 303 | case KC_M: | ||
| 304 | mousekey_console_help(); | ||
| 305 | print("\nEnter Mousekey Console\n"); | ||
| 306 | print("M0>"); | ||
| 307 | state = MOUSEKEY; | ||
| 308 | return true; | ||
| 309 | #endif | ||
| 310 | default: | ||
| 311 | print("?"); | ||
| 312 | return false; | ||
| 313 | } | ||
| 314 | print("C> "); | ||
| 315 | return true; | ||
| 316 | } | ||
| 317 | |||
| 318 | |||
| 319 | #ifdef MOUSEKEY_ENABLE | ||
| 320 | /*********************************************************** | ||
| 321 | * Mousekey console | ||
| 322 | ***********************************************************/ | ||
| 323 | static uint8_t mousekey_param = 0; | ||
| 324 | |||
| 325 | static void mousekey_param_print(void) | ||
| 326 | { | ||
| 327 | print("\n\n----- Mousekey Parameters -----\n"); | ||
| 328 | print("1: mk_delay(*10ms): "); pdec(mk_delay); print("\n"); | ||
| 329 | print("2: mk_interval(ms): "); pdec(mk_interval); print("\n"); | ||
| 330 | print("3: mk_max_speed: "); pdec(mk_max_speed); print("\n"); | ||
| 331 | print("4: mk_time_to_max: "); pdec(mk_time_to_max); print("\n"); | ||
| 332 | print("5: mk_wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n"); | ||
| 333 | print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); | ||
| 334 | } | ||
| 335 | |||
| 336 | static void mousekey_param_inc(uint8_t param, uint8_t inc) | ||
| 337 | { | ||
| 338 | switch (param) { | ||
| 339 | case 1: | ||
| 340 | if (mk_delay + inc < UINT8_MAX) | ||
| 341 | mk_delay += inc; | ||
| 342 | else | ||
| 343 | mk_delay = UINT8_MAX; | ||
| 344 | print("mk_delay = "); pdec(mk_delay); print("\n"); | ||
| 345 | break; | ||
| 346 | case 2: | ||
| 347 | if (mk_interval + inc < UINT8_MAX) | ||
| 348 | mk_interval += inc; | ||
| 349 | else | ||
| 350 | mk_interval = UINT8_MAX; | ||
| 351 | print("mk_interval = "); pdec(mk_interval); print("\n"); | ||
| 352 | break; | ||
| 353 | case 3: | ||
| 354 | if (mk_max_speed + inc < UINT8_MAX) | ||
| 355 | mk_max_speed += inc; | ||
| 356 | else | ||
| 357 | mk_max_speed = UINT8_MAX; | ||
| 358 | print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); | ||
| 359 | break; | ||
| 360 | case 4: | ||
| 361 | if (mk_time_to_max + inc < UINT8_MAX) | ||
| 362 | mk_time_to_max += inc; | ||
| 363 | else | ||
| 364 | mk_time_to_max = UINT8_MAX; | ||
| 365 | print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); | ||
| 366 | break; | ||
| 367 | case 5: | ||
| 368 | if (mk_wheel_max_speed + inc < UINT8_MAX) | ||
| 369 | mk_wheel_max_speed += inc; | ||
| 370 | else | ||
| 371 | mk_wheel_max_speed = UINT8_MAX; | ||
| 372 | print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); | ||
| 373 | break; | ||
| 374 | case 6: | ||
| 375 | if (mk_wheel_time_to_max + inc < UINT8_MAX) | ||
| 376 | mk_wheel_time_to_max += inc; | ||
| 377 | else | ||
| 378 | mk_wheel_time_to_max = UINT8_MAX; | ||
| 379 | print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); | ||
| 380 | break; | ||
| 381 | } | ||
| 382 | } | ||
| 383 | |||
| 384 | static void mousekey_param_dec(uint8_t param, uint8_t dec) | ||
| 385 | { | ||
| 386 | switch (param) { | ||
| 387 | case 1: | ||
| 388 | if (mk_delay > dec) | ||
| 389 | mk_delay -= dec; | ||
| 390 | else | ||
| 391 | mk_delay = 0; | ||
| 392 | print("mk_delay = "); pdec(mk_delay); print("\n"); | ||
| 393 | break; | ||
| 394 | case 2: | ||
| 395 | if (mk_interval > dec) | ||
| 396 | mk_interval -= dec; | ||
| 397 | else | ||
| 398 | mk_interval = 0; | ||
| 399 | print("mk_interval = "); pdec(mk_interval); print("\n"); | ||
| 400 | break; | ||
| 401 | case 3: | ||
| 402 | if (mk_max_speed > dec) | ||
| 403 | mk_max_speed -= dec; | ||
| 404 | else | ||
| 405 | mk_max_speed = 0; | ||
| 406 | print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); | ||
| 407 | break; | ||
| 408 | case 4: | ||
| 409 | if (mk_time_to_max > dec) | ||
| 410 | mk_time_to_max -= dec; | ||
| 411 | else | ||
| 412 | mk_time_to_max = 0; | ||
| 413 | print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); | ||
| 414 | break; | ||
| 415 | case 5: | ||
| 416 | if (mk_wheel_max_speed > dec) | ||
| 417 | mk_wheel_max_speed -= dec; | ||
| 418 | else | ||
| 419 | mk_wheel_max_speed = 0; | ||
| 420 | print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); | ||
| 421 | break; | ||
| 422 | case 6: | ||
| 423 | if (mk_wheel_time_to_max > dec) | ||
| 424 | mk_wheel_time_to_max -= dec; | ||
| 425 | else | ||
| 426 | mk_wheel_time_to_max = 0; | ||
| 427 | print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); | ||
| 428 | break; | ||
| 429 | } | ||
| 430 | } | ||
| 431 | |||
| 432 | static void mousekey_console_help(void) | ||
| 433 | { | ||
| 434 | print("\n\n----- Mousekey Parameters Help -----\n"); | ||
| 435 | print("ESC/q: quit\n"); | ||
| 436 | print("1: select mk_delay(*10ms)\n"); | ||
| 437 | print("2: select mk_interval(ms)\n"); | ||
| 438 | print("3: select mk_max_speed\n"); | ||
| 439 | print("4: select mk_time_to_max\n"); | ||
| 440 | print("5: select mk_wheel_max_speed\n"); | ||
| 441 | print("6: select mk_wheel_time_to_max\n"); | ||
| 442 | print("p: print prameters\n"); | ||
| 443 | print("d: set default values\n"); | ||
| 444 | print("up: increase prameters(+1)\n"); | ||
| 445 | print("down: decrease prameters(-1)\n"); | ||
| 446 | print("pgup: increase prameters(+10)\n"); | ||
| 447 | print("pgdown: decrease prameters(-10)\n"); | ||
| 448 | print("\nspeed = delta * max_speed * (repeat / time_to_max)\n"); | ||
| 449 | print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA); | ||
| 450 | print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n"); | ||
| 451 | print("See http://en.wikipedia.org/wiki/Mouse_keys\n"); | ||
| 452 | } | ||
| 453 | |||
| 454 | static bool mousekey_console(uint8_t code) | ||
| 455 | { | ||
| 456 | switch (code) { | ||
| 457 | case KC_H: | ||
| 458 | case KC_SLASH: /* ? */ | ||
| 459 | mousekey_console_help(); | ||
| 460 | break; | ||
| 461 | case KC_Q: | ||
| 462 | case KC_ESC: | ||
| 463 | mousekey_param = 0; | ||
| 464 | print("\nQuit Mousekey Console\n"); | ||
| 465 | print("C> "); | ||
| 466 | state = CONSOLE; | ||
| 467 | return false; | ||
| 468 | case KC_P: | ||
| 469 | mousekey_param_print(); | ||
| 470 | break; | ||
| 471 | case KC_1: | ||
| 472 | case KC_2: | ||
| 473 | case KC_3: | ||
| 474 | case KC_4: | ||
| 475 | case KC_5: | ||
| 476 | case KC_6: | ||
| 477 | case KC_7: | ||
| 478 | case KC_8: | ||
| 479 | case KC_9: | ||
| 480 | case KC_0: | ||
| 481 | mousekey_param = kc2int(code); | ||
| 482 | print("selected parameter: "); pdec(mousekey_param); print("\n"); | ||
| 483 | break; | ||
| 484 | case KC_UP: | ||
| 485 | mousekey_param_inc(mousekey_param, 1); | ||
| 486 | break; | ||
| 487 | case KC_DOWN: | ||
| 488 | mousekey_param_dec(mousekey_param, 1); | ||
| 489 | break; | ||
| 490 | case KC_PGUP: | ||
| 491 | mousekey_param_inc(mousekey_param, 10); | ||
| 492 | break; | ||
| 493 | case KC_PGDN: | ||
| 494 | mousekey_param_dec(mousekey_param, 10); | ||
| 495 | break; | ||
| 496 | case KC_D: | ||
| 497 | mk_delay = MOUSEKEY_DELAY/10; | ||
| 498 | mk_interval = MOUSEKEY_INTERVAL; | ||
| 499 | mk_max_speed = MOUSEKEY_MAX_SPEED; | ||
| 500 | mk_time_to_max = MOUSEKEY_TIME_TO_MAX; | ||
| 501 | mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; | ||
| 502 | mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; | ||
| 503 | print("set default values.\n"); | ||
| 504 | break; | ||
| 505 | default: | ||
| 506 | print("?"); | ||
| 507 | return false; | ||
| 508 | } | ||
| 509 | print("M"); pdec(mousekey_param); print("> "); | ||
| 510 | return true; | ||
| 511 | } | ||
| 229 | #endif | 512 | #endif |
| 230 | print("DEL: jump to bootloader\n"); | 513 | |
| 514 | |||
| 515 | /*********************************************************** | ||
| 516 | * Utilities | ||
| 517 | ***********************************************************/ | ||
| 518 | static uint8_t kc2int(uint8_t code) | ||
| 519 | { | ||
| 520 | switch (code) { | ||
| 521 | case KC_1: return 1; | ||
| 522 | case KC_2: return 2; | ||
| 523 | case KC_3: return 3; | ||
| 524 | case KC_4: return 4; | ||
| 525 | case KC_5: return 5; | ||
| 526 | case KC_6: return 6; | ||
| 527 | case KC_7: return 7; | ||
| 528 | case KC_8: return 8; | ||
| 529 | case KC_9: return 9; | ||
| 530 | case KC_0: return 0; | ||
| 531 | } | ||
| 532 | return 0; | ||
| 231 | } | 533 | } |
| 232 | 534 | ||
| 233 | static void switch_layer(uint8_t layer) | 535 | static void switch_layer(uint8_t layer) |
| @@ -242,6 +544,7 @@ static void switch_layer(uint8_t layer) | |||
| 242 | static void clear_keyboard(void) | 544 | static void clear_keyboard(void) |
| 243 | { | 545 | { |
| 244 | host_clear_keys(); | 546 | host_clear_keys(); |
| 547 | host_clear_mods(); | ||
| 245 | host_send_keyboard_report(); | 548 | host_send_keyboard_report(); |
| 246 | 549 | ||
| 247 | host_system_send(0); | 550 | host_system_send(0); |
diff --git a/common/keyboard.c b/common/keyboard.c index c7ea2b840..d7ced430e 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -30,6 +30,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | #define Kdebug(s) do { if (debug_keyboard) debug(s); } while(0) | ||
| 34 | #define Kdebug_P(s) do { if (debug_keyboard) debug_P(s); } while(0) | ||
| 35 | #define Kdebug_hex(s) do { if (debug_keyboard) debug_hex(s); } while(0) | ||
| 36 | |||
| 33 | #define LAYER_DELAY 250 | 37 | #define LAYER_DELAY 250 |
| 34 | 38 | ||
| 35 | typedef enum keykind { | 39 | typedef enum keykind { |
| @@ -124,8 +128,8 @@ static void layer_switch_on(uint8_t code) | |||
| 124 | fn_state_bits |= FN_BIT(code); | 128 | fn_state_bits |= FN_BIT(code); |
| 125 | uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer); | 129 | uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer); |
| 126 | if (current_layer != new_layer) { | 130 | if (current_layer != new_layer) { |
| 127 | debug("Layer Switch(on): "); debug_hex(current_layer); | 131 | Kdebug("Layer Switch(on): "); Kdebug_hex(current_layer); |
| 128 | debug(" -> "); debug_hex(new_layer); debug("\n"); | 132 | Kdebug(" -> "); Kdebug_hex(new_layer); Kdebug("\n"); |
| 129 | 133 | ||
| 130 | clear_keyboard_but_mods(); | 134 | clear_keyboard_but_mods(); |
| 131 | current_layer = new_layer; | 135 | current_layer = new_layer; |
| @@ -138,8 +142,8 @@ static bool layer_switch_off(uint8_t code) | |||
| 138 | fn_state_bits &= ~FN_BIT(code); | 142 | fn_state_bits &= ~FN_BIT(code); |
| 139 | uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer); | 143 | uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer); |
| 140 | if (current_layer != new_layer) { | 144 | if (current_layer != new_layer) { |
| 141 | debug("Layer Switch(off): "); debug_hex(current_layer); | 145 | Kdebug("Layer Switch(off): "); Kdebug_hex(current_layer); |
| 142 | debug(" -> "); debug_hex(new_layer); debug("\n"); | 146 | Kdebug(" -> "); Kdebug_hex(new_layer); Kdebug("\n"); |
| 143 | 147 | ||
| 144 | clear_keyboard_but_mods(); | 148 | clear_keyboard_but_mods(); |
| 145 | current_layer = new_layer; | 149 | current_layer = new_layer; |
| @@ -151,9 +155,7 @@ static bool layer_switch_off(uint8_t code) | |||
| 151 | static void register_code(uint8_t code) | 155 | static void register_code(uint8_t code) |
| 152 | { | 156 | { |
| 153 | if IS_KEY(code) { | 157 | if IS_KEY(code) { |
| 154 | if (command_proc(code)) { | 158 | if (!command_proc(code)) { |
| 155 | //clear_keyboard(); | ||
| 156 | } else { | ||
| 157 | host_add_key(code); | 159 | host_add_key(code); |
| 158 | host_send_keyboard_report(); | 160 | host_send_keyboard_report(); |
| 159 | } | 161 | } |
| @@ -163,8 +165,10 @@ static void register_code(uint8_t code) | |||
| 163 | host_send_keyboard_report(); | 165 | host_send_keyboard_report(); |
| 164 | } | 166 | } |
| 165 | else if IS_FN(code) { | 167 | else if IS_FN(code) { |
| 166 | host_add_key(keymap_fn_keycode(FN_INDEX(code))); | 168 | if (!command_proc(keymap_fn_keycode(FN_INDEX(code)))) { |
| 167 | host_send_keyboard_report(); | 169 | host_add_key(keymap_fn_keycode(FN_INDEX(code))); |
| 170 | host_send_keyboard_report(); | ||
| 171 | } | ||
| 168 | } | 172 | } |
| 169 | else if IS_MOUSEKEY(code) { | 173 | else if IS_MOUSEKEY(code) { |
| 170 | #ifdef MOUSEKEY_ENABLE | 174 | #ifdef MOUSEKEY_ENABLE |
| @@ -331,9 +335,9 @@ static void unregister_code(uint8_t code) | |||
| 331 | * Ld: Switch back to default layer(*unregister* all keys but modifiers) | 335 | * Ld: Switch back to default layer(*unregister* all keys but modifiers) |
| 332 | */ | 336 | */ |
| 333 | #define NEXT(state) do { \ | 337 | #define NEXT(state) do { \ |
| 334 | debug("NEXT: "); debug_P(state_str(kbdstate)); \ | 338 | Kdebug("NEXT: "); Kdebug_P(state_str(kbdstate)); \ |
| 335 | kbdstate = state; \ | 339 | kbdstate = state; \ |
| 336 | debug(" -> "); debug_P(state_str(kbdstate)); debug("\n"); \ | 340 | Kdebug(" -> "); Kdebug_P(state_str(kbdstate)); Kdebug("\n"); \ |
| 337 | } while (0) | 341 | } while (0) |
| 338 | 342 | ||
| 339 | static inline void process_key(keyevent_t event) | 343 | static inline void process_key(keyevent_t event) |
| @@ -343,11 +347,11 @@ static inline void process_key(keyevent_t event) | |||
| 343 | 347 | ||
| 344 | uint8_t tmp_mods; | 348 | uint8_t tmp_mods; |
| 345 | 349 | ||
| 346 | debug("state: "); debug_P(state_str(kbdstate)); | 350 | Kdebug("state: "); Kdebug_P(state_str(kbdstate)); |
| 347 | debug(" kind: "); debug_hex(kind); | 351 | Kdebug(" kind: "); Kdebug_hex(kind); |
| 348 | debug(" code: "); debug_hex(code); | 352 | Kdebug(" code: "); Kdebug_hex(code); |
| 349 | if (event.pressed) { debug("d"); } else { debug("u"); } | 353 | if (event.pressed) { Kdebug("d"); } else { Kdebug("u"); } |
| 350 | debug("\n"); | 354 | Kdebug("\n"); |
| 351 | 355 | ||
| 352 | switch (kbdstate) { | 356 | switch (kbdstate) { |
| 353 | case IDLE: | 357 | case IDLE: |
| @@ -607,7 +611,7 @@ void keyboard_task(void) | |||
| 607 | is_matrix_on |= matrix_get_row(r); | 611 | is_matrix_on |= matrix_get_row(r); |
| 608 | } | 612 | } |
| 609 | if (!is_matrix_on) { | 613 | if (!is_matrix_on) { |
| 610 | debug("FAIL SAFE: clear all keys(default layer).\n"); | 614 | Kdebug("FAIL SAFE: clear all keys(default layer).\n"); |
| 611 | clear_keyboard(); | 615 | clear_keyboard(); |
| 612 | current_layer = default_layer; | 616 | current_layer = default_layer; |
| 613 | } | 617 | } |
diff --git a/common/print.c b/common/print.c index 558181ea7..4e36d3935 100644 --- a/common/print.c +++ b/common/print.c | |||
| @@ -75,6 +75,14 @@ void phex16(unsigned int i) | |||
| 75 | phex(i); | 75 | phex(i); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | void pdec(uint8_t i) | ||
| 79 | { | ||
| 80 | if (!print_enable) return; | ||
| 81 | if (i/100) sendchar('0' + (i/100)); | ||
| 82 | if (i/100 || i%100/10) sendchar('0' + (i%100/10)); | ||
| 83 | sendchar('0' + (i%10)); | ||
| 84 | } | ||
| 85 | |||
| 78 | 86 | ||
| 79 | void pbin(unsigned char c) | 87 | void pbin(unsigned char c) |
| 80 | { | 88 | { |
diff --git a/common/print.h b/common/print.h index d55f5695d..1c4567862 100644 --- a/common/print.h +++ b/common/print.h | |||
| @@ -45,6 +45,7 @@ void print_S(const char *s); | |||
| 45 | void print_P(const char *s); | 45 | void print_P(const char *s); |
| 46 | void phex(unsigned char c); | 46 | void phex(unsigned char c); |
| 47 | void phex16(unsigned int i); | 47 | void phex16(unsigned int i); |
| 48 | void pdec(uint8_t i); | ||
| 48 | void pbin(unsigned char c); | 49 | void pbin(unsigned char c); |
| 49 | void pbin_reverse(unsigned char c); | 50 | void pbin_reverse(unsigned char c); |
| 50 | #ifdef __cplusplus | 51 | #ifdef __cplusplus |
