diff options
| -rw-r--r-- | common/action.c | 356 | ||||
| -rw-r--r-- | common/action.h | 217 | ||||
| -rw-r--r-- | common/command.c | 7 | ||||
| -rw-r--r-- | common/keymap.c | 91 | ||||
| -rw-r--r-- | common/keymap.h | 17 | ||||
| -rw-r--r-- | common/layer_switch.c | 167 | ||||
| -rw-r--r-- | common/layer_switch.h | 71 |
7 files changed, 585 insertions, 341 deletions
diff --git a/common/action.c b/common/action.c index 246fd99d8..3703b4e8c 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -202,23 +202,6 @@ void action_exec(keyevent_t event) | |||
| 202 | } | 202 | } |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | static action_t get_action(key_t key) | ||
| 206 | { | ||
| 207 | action_t action; | ||
| 208 | action.code = ACTION_NO; | ||
| 209 | |||
| 210 | /* layer_switch */ | ||
| 211 | action = layer_switch_get_action(key); | ||
| 212 | if (action.code != ACTION_TRANSPARENT) { | ||
| 213 | return action; | ||
| 214 | } | ||
| 215 | |||
| 216 | /* default layer */ | ||
| 217 | //debug("get_aciton: default layer: "); debug_dec(default_layer); debug("\n"); | ||
| 218 | action = action_for_key(default_layer, key); | ||
| 219 | return action; | ||
| 220 | } | ||
| 221 | |||
| 222 | static void process_action(keyrecord_t *record) | 205 | static void process_action(keyrecord_t *record) |
| 223 | { | 206 | { |
| 224 | keyevent_t event = record->event; | 207 | keyevent_t event = record->event; |
| @@ -226,9 +209,11 @@ static void process_action(keyrecord_t *record) | |||
| 226 | 209 | ||
| 227 | if (IS_NOEVENT(event)) { return; } | 210 | if (IS_NOEVENT(event)) { return; } |
| 228 | 211 | ||
| 229 | action_t action = get_action(event.key); | 212 | action_t action = layer_switch_get_action(event.key); |
| 230 | debug("ACTION: "); debug_action(action); debug(" "); | 213 | debug("ACTION: "); debug_action(action); |
| 231 | layer_switch_debug(); debug("["); debug_dec(default_layer); debug("]\n"); | 214 | debug(" overlays: "); overlay_debug(); |
| 215 | debug(" keymaps: "); keymap_debug(); | ||
| 216 | debug(" default_layer: "); debug_dec(default_layer); debug("\n"); | ||
| 232 | 217 | ||
| 233 | switch (action.kind.id) { | 218 | switch (action.kind.id) { |
| 234 | /* Key and Mods */ | 219 | /* Key and Mods */ |
| @@ -368,207 +353,292 @@ static void process_action(keyrecord_t *record) | |||
| 368 | #endif | 353 | #endif |
| 369 | break; | 354 | break; |
| 370 | 355 | ||
| 371 | /* Layer key */ | 356 | case ACT_KEYMAP: |
| 372 | case ACT_LAYER_SET: | ||
| 373 | switch (action.layer.code) { | 357 | switch (action.layer.code) { |
| 374 | case LAYER_MOMENTARY: /* momentary */ | 358 | /* Keymap Reset */ |
| 375 | if (event.pressed) { | 359 | case OP_RESET: |
| 376 | layer_switch_move(action.layer.val); | 360 | default_layer_set(action.layer.val); |
| 377 | } | ||
| 378 | else { | ||
| 379 | // NOTE: This is needed by legacy keymap support | ||
| 380 | layer_switch_move(0); | ||
| 381 | } | ||
| 382 | break; | 361 | break; |
| 383 | case LAYER_ON_PRESS: | 362 | /* Keymap Reset default layer */ |
| 363 | case (OP_RESET | ON_PRESS): | ||
| 384 | if (event.pressed) { | 364 | if (event.pressed) { |
| 385 | layer_switch_move(action.layer.val); | 365 | default_layer_set(action.layer.val); |
| 366 | overlay_clear(); | ||
| 386 | } | 367 | } |
| 387 | break; | 368 | break; |
| 388 | case LAYER_ON_RELEASE: | 369 | case (OP_RESET | ON_RELEASE): |
| 389 | if (!event.pressed) { | 370 | if (!event.pressed) { |
| 390 | layer_switch_move(action.layer.val); | 371 | default_layer_set(action.layer.val); |
| 372 | overlay_clear(); | ||
| 391 | } | 373 | } |
| 392 | break; | 374 | break; |
| 393 | case LAYER_ON_BOTH: | 375 | case (OP_RESET | ON_BOTH): |
| 394 | layer_switch_move(action.layer.val); | 376 | default_layer_set(action.layer.val); |
| 377 | overlay_clear(); | ||
| 395 | break; | 378 | break; |
| 396 | case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */ | 379 | |
| 380 | /* Keymap Bit invert */ | ||
| 381 | case OP_INV: | ||
| 382 | /* with tap toggle */ | ||
| 397 | if (event.pressed) { | 383 | if (event.pressed) { |
| 398 | if (tap_count < TAPPING_TOGGLE) { | 384 | if (tap_count < TAPPING_TOGGLE) { |
| 399 | layer_switch_move(action.layer.val); | 385 | debug("KEYMAP_INV: tap toggle(press).\n"); |
| 386 | keymap_invert(action.layer.val); | ||
| 400 | } | 387 | } |
| 401 | } else { | 388 | } else { |
| 402 | if (tap_count >= TAPPING_TOGGLE) { | 389 | if (tap_count <= TAPPING_TOGGLE) { |
| 403 | debug("LAYER_PRESSED: tap toggle.\n"); | 390 | debug("KEYMAP_INV: tap toggle(release).\n"); |
| 404 | layer_switch_move(action.layer.val); | 391 | keymap_invert(action.layer.val); |
| 405 | } | 392 | } |
| 406 | } | 393 | } |
| 407 | break; | 394 | break; |
| 408 | case LAYER_SET_DEFAULT_ON_PRESS: | 395 | case (OP_INV | ON_PRESS): |
| 409 | if (event.pressed) { | 396 | if (event.pressed) { |
| 410 | default_layer = action.layer.val; | 397 | keymap_invert(action.layer.val); |
| 411 | layer_switch_move(0); | ||
| 412 | } | 398 | } |
| 413 | break; | 399 | break; |
| 414 | case LAYER_SET_DEFAULT_ON_RELEASE: | 400 | case (OP_INV | ON_RELEASE): |
| 415 | if (!event.pressed) { | 401 | if (!event.pressed) { |
| 416 | default_layer = action.layer.val; | 402 | keymap_invert(action.layer.val); |
| 417 | layer_switch_move(0); | ||
| 418 | } | 403 | } |
| 419 | break; | 404 | break; |
| 420 | case LAYER_SET_DEFAULT_ON_BOTH: | 405 | case (OP_INV | ON_BOTH): |
| 421 | default_layer = action.layer.val; | 406 | keymap_invert(action.layer.val); |
| 422 | layer_switch_move(0); | ||
| 423 | break; | 407 | break; |
| 424 | default: | 408 | |
| 425 | /* tap key */ | 409 | /* Keymap Bit on */ |
| 410 | case OP_ON: | ||
| 426 | if (event.pressed) { | 411 | if (event.pressed) { |
| 427 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { | 412 | keymap_on(action.layer.val); |
| 428 | debug("LAYER_SET: Tap: register_code\n"); | ||
| 429 | register_code(action.layer.code); | ||
| 430 | } else { | ||
| 431 | debug("LAYER_SET: No tap: layer_set(on press)\n"); | ||
| 432 | layer_switch_move(action.layer.val); | ||
| 433 | } | ||
| 434 | } else { | 413 | } else { |
| 435 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { | 414 | keymap_off(action.layer.val); |
| 436 | debug("LAYER_SET: Tap: unregister_code\n"); | ||
| 437 | unregister_code(action.layer.code); | ||
| 438 | } else { | ||
| 439 | // NOTE: This is needed by legacy keymap support | ||
| 440 | debug("LAYER_SET: No tap: return to default layer(on release)\n"); | ||
| 441 | layer_switch_move(0); | ||
| 442 | } | ||
| 443 | } | 415 | } |
| 444 | break; | 416 | break; |
| 445 | } | 417 | case (OP_ON | ON_PRESS): |
| 446 | break; | ||
| 447 | case ACT_LAYER_BIT: | ||
| 448 | switch (action.layer.code) { | ||
| 449 | case LAYER_MOMENTARY: /* momentary */ | ||
| 450 | if (event.pressed) { | 418 | if (event.pressed) { |
| 451 | layer_switch_move(layer_switch_get_layer() | action.layer.val); | 419 | keymap_on(action.layer.val); |
| 420 | } | ||
| 421 | break; | ||
| 422 | case (OP_ON | ON_RELEASE): | ||
| 423 | if (!event.pressed) { | ||
| 424 | keymap_on(action.layer.val); | ||
| 425 | } | ||
| 426 | break; | ||
| 427 | case (OP_ON | ON_BOTH): | ||
| 428 | keymap_on(action.layer.val); | ||
| 429 | break; | ||
| 430 | |||
| 431 | /* Keymap Bit off */ | ||
| 432 | case OP_OFF: | ||
| 433 | if (event.pressed) { | ||
| 434 | keymap_off(action.layer.val); | ||
| 452 | } else { | 435 | } else { |
| 453 | layer_switch_move(layer_switch_get_layer() & ~action.layer.val); | 436 | keymap_on(action.layer.val); |
| 454 | } | 437 | } |
| 455 | break; | 438 | break; |
| 456 | case LAYER_ON_PRESS: | 439 | case (OP_OFF | ON_PRESS): |
| 457 | if (event.pressed) { | 440 | if (event.pressed) { |
| 458 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | 441 | keymap_off(action.layer.val); |
| 459 | } | 442 | } |
| 460 | break; | 443 | break; |
| 461 | case LAYER_ON_RELEASE: | 444 | case (OP_OFF | ON_RELEASE): |
| 462 | if (!event.pressed) { | 445 | if (!event.pressed) { |
| 463 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | 446 | keymap_off(action.layer.val); |
| 464 | } | 447 | } |
| 465 | break; | 448 | break; |
| 466 | case LAYER_ON_BOTH: | 449 | case (OP_OFF | ON_BOTH): |
| 467 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | 450 | keymap_off(action.layer.val); |
| 468 | break; | 451 | break; |
| 469 | case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */ | 452 | |
| 453 | /* Keymap Bit set */ | ||
| 454 | case OP_SET: | ||
| 470 | if (event.pressed) { | 455 | if (event.pressed) { |
| 471 | if (tap_count < TAPPING_TOGGLE) { | 456 | keymap_set(action.layer.val); |
| 472 | debug("LAYER_BIT: tap toggle(press).\n"); | ||
| 473 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | ||
| 474 | } | ||
| 475 | } else { | 457 | } else { |
| 476 | if (tap_count <= TAPPING_TOGGLE) { | 458 | keymap_clear(); |
| 477 | debug("LAYER_BIT: tap toggle(release).\n"); | ||
| 478 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | ||
| 479 | } | ||
| 480 | } | 459 | } |
| 481 | break; | 460 | break; |
| 482 | case LAYER_SET_DEFAULT_ON_PRESS: | 461 | case (OP_SET | ON_PRESS): |
| 483 | if (event.pressed) { | 462 | if (event.pressed) { |
| 484 | default_layer = default_layer ^ action.layer.val; | 463 | keymap_set(action.layer.val); |
| 485 | layer_switch_move(default_layer); | ||
| 486 | } | 464 | } |
| 487 | break; | 465 | break; |
| 488 | case LAYER_SET_DEFAULT_ON_RELEASE: | 466 | case (OP_SET | ON_RELEASE): |
| 489 | if (!event.pressed) { | 467 | if (!event.pressed) { |
| 490 | default_layer = default_layer ^ action.layer.val; | 468 | keymap_set(action.layer.val); |
| 491 | layer_switch_move(default_layer); | ||
| 492 | } | 469 | } |
| 493 | break; | 470 | break; |
| 494 | case LAYER_SET_DEFAULT_ON_BOTH: | 471 | case (OP_SET | ON_BOTH): |
| 495 | default_layer = default_layer ^ action.layer.val; | 472 | keymap_set(action.layer.val); |
| 496 | layer_switch_move(default_layer); | ||
| 497 | break; | 473 | break; |
| 474 | |||
| 475 | /* Keymap Bit invert with tap key */ | ||
| 498 | default: | 476 | default: |
| 499 | // tap key | ||
| 500 | if (event.pressed) { | 477 | if (event.pressed) { |
| 501 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { | 478 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { |
| 502 | debug("LAYER_BIT: Tap: register_code\n"); | 479 | debug("KEYMAP_TAP_KEY: Tap: register_code\n"); |
| 503 | register_code(action.layer.code); | 480 | register_code(action.layer.code); |
| 504 | } else { | 481 | } else { |
| 505 | debug("LAYER_BIT: No tap: layer_bit(on press)\n"); | 482 | debug("KEYMAP_TAP_KEY: No tap: invert on press\n"); |
| 506 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | 483 | keymap_invert(action.layer.val); |
| 507 | } | 484 | } |
| 508 | } else { | 485 | } else { |
| 509 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { | 486 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { |
| 510 | debug("LAYER_BIT: Tap: unregister_code\n"); | 487 | debug("KEYMAP_TAP_KEY: Tap: unregister_code\n"); |
| 511 | unregister_code(action.layer.code); | 488 | unregister_code(action.layer.code); |
| 512 | } else { | 489 | } else { |
| 513 | debug("LAYER_BIT: No tap: layer_bit(on release)\n"); | 490 | debug("KEYMAP_TAP_KEY: No tap: invert on release\n"); |
| 514 | layer_switch_move(layer_switch_get_layer() ^ action.layer.val); | 491 | keymap_invert(action.layer.val); |
| 515 | } | 492 | } |
| 516 | } | 493 | } |
| 517 | break; | 494 | break; |
| 518 | } | 495 | } |
| 519 | break; | 496 | break; |
| 520 | case ACT_LAYER_SWITCH: | 497 | |
| 498 | case ACT_OVERLAY: | ||
| 521 | switch (action.layer.code) { | 499 | switch (action.layer.code) { |
| 522 | case LAYER_MOMENTARY: /* momentary */ | 500 | // Overlay Invert bit4 |
| 523 | if (event.pressed) { | 501 | case OP_INV4 | 0: |
| 524 | layer_switch_on(action.layer.val); | 502 | if (action.layer.val == 0) { |
| 503 | overlay_clear(); | ||
| 525 | } else { | 504 | } else { |
| 526 | layer_switch_off(action.layer.val); | 505 | overlay_set(overlay_stat ^ action.layer.val); |
| 527 | } | 506 | } |
| 528 | break; | 507 | break; |
| 529 | case LAYER_ON_PRESS: | 508 | case OP_INV4 | 1: |
| 530 | if (event.pressed) { | 509 | if (action.layer.val == 0) { |
| 531 | layer_switch_invert(action.layer.val); | 510 | if (event.pressed) overlay_clear(); |
| 511 | } else { | ||
| 512 | overlay_set(overlay_stat ^ action.layer.val<<4); | ||
| 532 | } | 513 | } |
| 533 | break; | 514 | break; |
| 534 | case LAYER_ON_RELEASE: | 515 | case OP_INV4 | 2: |
| 535 | if (!event.pressed) { | 516 | if (action.layer.val == 0) { |
| 536 | layer_switch_invert(action.layer.val); | 517 | if (!event.pressed) overlay_clear(); |
| 518 | } else { | ||
| 519 | overlay_set(overlay_stat ^ action.layer.val<<8); | ||
| 537 | } | 520 | } |
| 538 | break; | 521 | break; |
| 539 | case LAYER_ON_BOTH: | 522 | case OP_INV4 | 3: |
| 540 | layer_switch_invert(action.layer.val); | 523 | if (action.layer.val == 0) { |
| 524 | overlay_clear(); | ||
| 525 | } else { | ||
| 526 | overlay_set(overlay_stat ^ action.layer.val<<12); | ||
| 527 | } | ||
| 541 | break; | 528 | break; |
| 542 | case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */ | 529 | |
| 530 | /* Overlay Bit invert */ | ||
| 531 | case OP_INV: | ||
| 532 | /* with tap toggle */ | ||
| 543 | if (event.pressed) { | 533 | if (event.pressed) { |
| 544 | if (tap_count < TAPPING_TOGGLE) { | 534 | if (tap_count < TAPPING_TOGGLE) { |
| 545 | debug("LAYER_SWITCH: tap toggle(press).\n"); | 535 | debug("OVERLAY_INV: tap toggle(press).\n"); |
| 546 | layer_switch_invert(action.layer.val); | 536 | overlay_invert(action.layer.val); |
| 547 | } | 537 | } |
| 548 | } else { | 538 | } else { |
| 549 | if (tap_count <= TAPPING_TOGGLE) { | 539 | if (tap_count <= TAPPING_TOGGLE) { |
| 550 | debug("LAYER_SWITCH: tap toggle(release).\n"); | 540 | debug("OVERLAY_INV: tap toggle(release).\n"); |
| 551 | layer_switch_invert(action.layer.val); | 541 | overlay_invert(action.layer.val); |
| 552 | } | 542 | } |
| 553 | } | 543 | } |
| 554 | break; | 544 | break; |
| 545 | case (OP_INV | ON_PRESS): | ||
| 546 | if (event.pressed) { | ||
| 547 | overlay_invert(action.layer.val); | ||
| 548 | } | ||
| 549 | break; | ||
| 550 | case (OP_INV | ON_RELEASE): | ||
| 551 | if (!event.pressed) { | ||
| 552 | overlay_invert(action.layer.val); | ||
| 553 | } | ||
| 554 | break; | ||
| 555 | case (OP_INV | ON_BOTH): | ||
| 556 | overlay_invert(action.layer.val); | ||
| 557 | break; | ||
| 558 | |||
| 559 | /* Overlay Bit on */ | ||
| 560 | case OP_ON: | ||
| 561 | if (event.pressed) { | ||
| 562 | overlay_on(action.layer.val); | ||
| 563 | } else { | ||
| 564 | overlay_off(action.layer.val); | ||
| 565 | } | ||
| 566 | break; | ||
| 567 | case (OP_ON | ON_PRESS): | ||
| 568 | if (event.pressed) { | ||
| 569 | overlay_on(action.layer.val); | ||
| 570 | } | ||
| 571 | break; | ||
| 572 | case (OP_ON | ON_RELEASE): | ||
| 573 | if (!event.pressed) { | ||
| 574 | overlay_on(action.layer.val); | ||
| 575 | } | ||
| 576 | break; | ||
| 577 | case (OP_ON | ON_BOTH): | ||
| 578 | overlay_on(action.layer.val); | ||
| 579 | break; | ||
| 580 | |||
| 581 | /* Overlay Bit off */ | ||
| 582 | case OP_OFF: | ||
| 583 | if (event.pressed) { | ||
| 584 | overlay_off(action.layer.val); | ||
| 585 | } else { | ||
| 586 | overlay_on(action.layer.val); | ||
| 587 | } | ||
| 588 | break; | ||
| 589 | case (OP_OFF | ON_PRESS): | ||
| 590 | if (event.pressed) { | ||
| 591 | overlay_off(action.layer.val); | ||
| 592 | } | ||
| 593 | break; | ||
| 594 | case (OP_OFF | ON_RELEASE): | ||
| 595 | if (!event.pressed) { | ||
| 596 | overlay_off(action.layer.val); | ||
| 597 | } | ||
| 598 | break; | ||
| 599 | case (OP_OFF | ON_BOTH): | ||
| 600 | overlay_off(action.layer.val); | ||
| 601 | break; | ||
| 602 | |||
| 603 | /* Overlay Bit set */ | ||
| 604 | case OP_SET: | ||
| 605 | if (event.pressed) { | ||
| 606 | overlay_move(action.layer.val); | ||
| 607 | } else { | ||
| 608 | overlay_clear(); | ||
| 609 | } | ||
| 610 | break; | ||
| 611 | case (OP_SET | ON_PRESS): | ||
| 612 | if (event.pressed) { | ||
| 613 | overlay_move(action.layer.val); | ||
| 614 | } | ||
| 615 | break; | ||
| 616 | case (OP_SET | ON_RELEASE): | ||
| 617 | if (!event.pressed) { | ||
| 618 | overlay_move(action.layer.val); | ||
| 619 | } | ||
| 620 | break; | ||
| 621 | case (OP_SET | ON_BOTH): | ||
| 622 | overlay_move(action.layer.val); | ||
| 623 | break; | ||
| 624 | |||
| 625 | /* Overlay Bit invert with tap key */ | ||
| 555 | default: | 626 | default: |
| 556 | // tap key | ||
| 557 | if (event.pressed) { | 627 | if (event.pressed) { |
| 558 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { | 628 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { |
| 559 | debug("LAYER_SWITCH: Tap: register_code\n"); | 629 | debug("OVERLAY_TAP_KEY: Tap: register_code\n"); |
| 560 | register_code(action.layer.code); | 630 | register_code(action.layer.code); |
| 561 | } else { | 631 | } else { |
| 562 | debug("LAYER_SWITCH: No tap: layer_switch on press\n"); | 632 | debug("OVERLAY_TAP_KEY: No tap: invert on press\n"); |
| 563 | layer_switch_invert(action.layer.val); | 633 | overlay_invert(action.layer.val); |
| 564 | } | 634 | } |
| 565 | } else { | 635 | } else { |
| 566 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { | 636 | if (IS_TAPPING_KEY(event.key) && tap_count > 0) { |
| 567 | debug("LAYER_SWITCH: Tap: unregister_code\n"); | 637 | debug("OVERLAY_TAP_KEY: Tap: unregister_code\n"); |
| 568 | unregister_code(action.layer.code); | 638 | unregister_code(action.layer.code); |
| 569 | } else { | 639 | } else { |
| 570 | debug("LAYER_SWITCH: No tap: layer_switch on release\n"); | 640 | debug("OVERLAY_TAP_KEY: No tap: invert on release\n"); |
| 571 | layer_switch_invert(action.layer.val); | 641 | overlay_invert(action.layer.val); |
| 572 | } | 642 | } |
| 573 | } | 643 | } |
| 574 | break; | 644 | break; |
| @@ -877,28 +947,21 @@ bool sending_anykey(void) | |||
| 877 | 947 | ||
| 878 | bool is_tap_key(key_t key) | 948 | bool is_tap_key(key_t key) |
| 879 | { | 949 | { |
| 880 | action_t action = get_action(key); | 950 | action_t action = layer_switch_get_action(key); |
| 881 | 951 | ||
| 882 | switch (action.kind.id) { | 952 | switch (action.kind.id) { |
| 883 | case ACT_LMODS_TAP: | 953 | case ACT_LMODS_TAP: |
| 884 | case ACT_RMODS_TAP: | 954 | case ACT_RMODS_TAP: |
| 885 | return true; | 955 | return true; |
| 886 | case ACT_LAYER_SET: | 956 | case ACT_KEYMAP: |
| 887 | case ACT_LAYER_BIT: | 957 | case ACT_OVERLAY: |
| 888 | switch (action.layer.code) { | 958 | switch (action.layer.code) { |
| 889 | case LAYER_MOMENTARY: | 959 | case 0x04 ... 0xEF: /* tap key */ |
| 890 | case LAYER_ON_PRESS: | 960 | case OP_INV: |
| 891 | case LAYER_ON_RELEASE: | ||
| 892 | case LAYER_ON_BOTH: | ||
| 893 | case LAYER_SET_DEFAULT_ON_PRESS: | ||
| 894 | case LAYER_SET_DEFAULT_ON_RELEASE: | ||
| 895 | case LAYER_SET_DEFAULT_ON_BOTH: | ||
| 896 | return false; | ||
| 897 | case LAYER_TAP_TOGGLE: | ||
| 898 | default: /* tap key */ | ||
| 899 | return true; | 961 | return true; |
| 962 | default: | ||
| 963 | return false; | ||
| 900 | } | 964 | } |
| 901 | return false; | ||
| 902 | case ACT_FUNCTION: | 965 | case ACT_FUNCTION: |
| 903 | if (action.func.opt & FUNC_TAP) { return true; } | 966 | if (action.func.opt & FUNC_TAP) { return true; } |
| 904 | return false; | 967 | return false; |
| @@ -929,9 +992,8 @@ static void debug_action(action_t action) | |||
| 929 | case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; | 992 | case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; |
| 930 | case ACT_USAGE: debug("ACT_USAGE"); break; | 993 | case ACT_USAGE: debug("ACT_USAGE"); break; |
| 931 | case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; | 994 | case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; |
| 932 | case ACT_LAYER_SET: debug("ACT_LAYER_SET"); break; | 995 | case ACT_KEYMAP: debug("ACT_KEYMAP"); break; |
| 933 | case ACT_LAYER_BIT: debug("ACT_LAYER_BIT"); break; | 996 | case ACT_OVERLAY: debug("ACT_OVERLAY"); break; |
| 934 | case ACT_LAYER_SWITCH: debug("ACT_LAYER_SWITCH"); break; | ||
| 935 | case ACT_MACRO: debug("ACT_MACRO"); break; | 997 | case ACT_MACRO: debug("ACT_MACRO"); break; |
| 936 | case ACT_COMMAND: debug("ACT_COMMAND"); break; | 998 | case ACT_COMMAND: debug("ACT_COMMAND"); break; |
| 937 | case ACT_FUNCTION: debug("ACT_FUNCTION"); break; | 999 | case ACT_FUNCTION: debug("ACT_FUNCTION"); break; |
diff --git a/common/action.h b/common/action.h index 46ae809cb..c02a2e71f 100644 --- a/common/action.h +++ b/common/action.h | |||
| @@ -150,40 +150,41 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 150 | * | 150 | * |
| 151 | * Mouse Keys | 151 | * Mouse Keys |
| 152 | * ---------- | 152 | * ---------- |
| 153 | * NOTE: can be combined with 'Other HID Usage'? to save action kind id. | ||
| 154 | * ACT_MOUSEKEY(0110): | 153 | * ACT_MOUSEKEY(0110): |
| 155 | * 0101|XXXX| keycode Mouse key | 154 | * 0101|XXXX| keycode Mouse key |
| 156 | * | 155 | * |
| 157 | * | 156 | * |
| 158 | * Layer Actions | 157 | * Layer Actions |
| 159 | * ------------- | 158 | * ------------- |
| 160 | * ACT_LAYER_SET(1000): Set layer | 159 | * ACT_KEYMAP: |
| 161 | * 1000|LLLL|0000 0000 set current layer on press and return to default on release(momentary) | 160 | * 1000|LLLL|0000 0000 Reset default layer |
| 162 | * 1000|LLLL|0000 0001 set current layer on press | 161 | * 1000|LLLL|0000 00xx Reset default layer and clear overlay |
| 163 | * 1000|LLLL|0000 0010 set current layer on release | 162 | * 1000|LLLL| keycode Invert with tap key |
| 164 | * 1000|LLLL|0000 0011 set current layer on both | 163 | * 1000|LLLL|1111 0000 Invert with tap toggle |
| 165 | * 1000|LLLL| keycode set current layer on hold and send key on tap | 164 | * 1000|LLLL|1111 00xx Invert[^= L] |
| 166 | * 1000|LLLL|1111 0000 set current layer on hold and toggle on several taps | 165 | * 1000|LLLL|1111 0100 On/Off |
| 167 | * 1000|DDDD|1111 1111 set default layer on press | 166 | * 1000|LLLL|1111 01xx On[|= L] |
| 168 | * L: 0 means default layer | 167 | * 1000|LLLL|1111 1000 Off/On |
| 168 | * 1000|LLLL|1111 10xx Off[&= ~L] | ||
| 169 | * 1000|LLLL|1111 1100 Set/Set(0) | ||
| 170 | * 1000|LLLL|1111 11xx Set[= L] | ||
| 171 | * default layer: 0-15(4bit) | ||
| 172 | * xx: On {00:for special use, 01:press, 10:release, 11:both} | ||
| 169 | * | 173 | * |
| 170 | * ACT_LAYER_BIT(1001): Bit-op layer | 174 | * ACT_OVERLAY: |
| 171 | * 1001|BBBB|0000 0000 bit-on current layer on press and bit-off on release(momentary) | 175 | * 1011|0000|0000 0000 Clear overlay |
| 172 | * 1001|BBBB|0000 0001 bit-xor current layer on press | 176 | * 1011|LLLL|0000 00ss Invert 4-bit chunk [^= L<<(4*ss)] |
| 173 | * 1001|BBBB|0000 0010 bit-xor current layer on release | 177 | * 1011|LLLL| keycode Invert with tap key |
| 174 | * 1001|BBBB|0000 0011 bit-xor current layer on both | 178 | * 1011|LLLL|1111 0000 Invert with tap toggle |
| 175 | * 1001|BBBB| keycode bit-xor current layer on hold and send key on tap | 179 | * 1011|LLLL|1111 00xx Invert[^= 1<<L] |
| 176 | * 1001|BBBB|1111 0000 bit-xor current layer on hold and toggle on several taps | 180 | * 1011|LLLL|1111 0100 On/Off(momentary) |
| 177 | * 1001|BBBB|1111 1111 bit-xor default layer on both | 181 | * 1011|LLLL|1111 01xx On[|= 1<<L] |
| 178 | * | 182 | * 1011|LLLL|1111 1000 Off/On |
| 179 | * ACT_LAYER_SWITCH: Switch | 183 | * 1011|LLLL|1111 10xx Off[&= ~1<<L] |
| 180 | * 1011|LLLL|0000 0000 On on press and Off on release(momentary) | 184 | * 1011|LLLL|1111 1100 Set[= 1<<L]/Clear |
| 181 | * 1011|LLLL|0000 0001 Invert on press | 185 | * 1011|LLLL|1111 11xx Set[= 1<<L] |
| 182 | * 1011|LLLL|0000 0010 Invert on release | 186 | * overlays: 16-layer on/off status(16bit) |
| 183 | * 1011|LLLL|0000 0011 Invert on both | 187 | * xx: On {00:for special use, 01:press, 10:release, 11:both} |
| 184 | * 1011|LLLL| keycode Invert on hold and send key on tap | ||
| 185 | * 1011|LLLL|1111 0000 Invert on hold and toggle on several taps | ||
| 186 | * 1011|LLLL|1111 1111 (not used) | ||
| 187 | * | 188 | * |
| 188 | * | 189 | * |
| 189 | * Extensions(11XX) | 190 | * Extensions(11XX) |
| @@ -211,9 +212,8 @@ enum action_kind_id { | |||
| 211 | ACT_USAGE = 0b0100, | 212 | ACT_USAGE = 0b0100, |
| 212 | ACT_MOUSEKEY = 0b0101, | 213 | ACT_MOUSEKEY = 0b0101, |
| 213 | 214 | ||
| 214 | ACT_LAYER_SET = 0b1000, | 215 | ACT_KEYMAP = 0b1000, |
| 215 | ACT_LAYER_BIT = 0b1001, | 216 | ACT_OVERLAY = 0b1001, |
| 216 | ACT_LAYER_SWITCH = 0b1011, | ||
| 217 | 217 | ||
| 218 | ACT_MACRO = 0b1100, | 218 | ACT_MACRO = 0b1100, |
| 219 | ACT_COMMAND = 0b1110, | 219 | ACT_COMMAND = 0b1110, |
| @@ -254,73 +254,108 @@ enum mods_codes { | |||
| 254 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) | 254 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) |
| 255 | 255 | ||
| 256 | 256 | ||
| 257 | /* | 257 | /* Layer Operation: |
| 258 | * Layer switching | 258 | * Invert layer ^= (1<<layer) |
| 259 | * On layer |= (1<<layer) | ||
| 260 | * Off layer &= ~(1<<layer) | ||
| 261 | * Set layer = (1<<layer) | ||
| 262 | * Clear layer = 0 | ||
| 259 | */ | 263 | */ |
| 260 | enum layer_codes { | 264 | enum layer_params { |
| 261 | LAYER_MOMENTARY = 0, | 265 | ON_PRESS = 1, |
| 262 | LAYER_ON_PRESS = 1, | 266 | ON_RELEASE = 2, |
| 263 | LAYER_ON_RELEASE = 2, | 267 | ON_BOTH = 3, |
| 264 | LAYER_ON_BOTH =3, | 268 | |
| 265 | LAYER_TAP_TOGGLE = 0xF0, | 269 | OP_RESET = 0x00, |
| 266 | LAYER_SET_DEFAULT_ON_PRESS = 0xFD, | 270 | OP_INV4 = 0x00, |
| 267 | LAYER_SET_DEFAULT_ON_RELEASE = 0xFE, | 271 | OP_INV = 0xF0, |
| 268 | LAYER_SET_DEFAULT_ON_BOTH = 0xFF | 272 | OP_ON = 0xF4, |
| 273 | OP_OFF = 0xF8, | ||
| 274 | OP_SET = 0xFC, | ||
| 269 | }; | 275 | }; |
| 276 | |||
| 270 | /* | 277 | /* |
| 271 | * Default layer | 278 | * Default Layer |
| 272 | */ | ||
| 273 | /* set default layer */ | ||
| 274 | #define ACTION_LAYER_SET_DEFAULT(layer) ACTION_LAYER_SET_DEFAULT_R(layer) | ||
| 275 | #define ACTION_LAYER_SET_DEFAULT_P(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_SET_DEFAULT_ON_PRESS) | ||
| 276 | #define ACTION_LAYER_SET_DEFAULT_R(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_SET_DEFAULT_ON_RELEASE) | ||
| 277 | #define ACTION_LAYER_SET_DEFAULT_B(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_SET_DEFAULT_ON_BOTH) | ||
| 278 | /* bit-xor default layer */ | ||
| 279 | #define ACTION_LAYER_BIT_DEFAULT(bits) ACTION_LAYER_BIT_DEFAULT_R(bits) | ||
| 280 | #define ACTION_LAYER_BIT_DEFAULT_P(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_SET_DEFAULT_ON_PRESS) | ||
| 281 | #define ACTION_LAYER_BIT_DEFAULT_R(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_SET_DEFAULT_ON_RELEASE) | ||
| 282 | #define ACTION_LAYER_BIT_DEFAULT_B(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_SET_DEFAULT_ON_BOTH) | ||
| 283 | /* | ||
| 284 | * Current layer: Return to default layer | ||
| 285 | */ | ||
| 286 | #define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R | ||
| 287 | #define ACTION_LAYER_DEFAULT_P ACTION_LAYER_SET_P(0) | ||
| 288 | #define ACTION_LAYER_DEFAULT_R ACTION_LAYER_SET_R(0) | ||
| 289 | #define ACTION_LAYER_DEFAULT_B ACTION_LAYER_SET_B(0) | ||
| 290 | /* | ||
| 291 | * Current layer: Set | ||
| 292 | */ | ||
| 293 | #define ACTION_LAYER_SET(layer) ACTION_LAYER_SET_P(layer) | ||
| 294 | #define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_MOMENTARY) | ||
| 295 | #define ACTION_LAYER_SET_TOGGLE(layer) ACTION_LAYER_SET_R(layer) | ||
| 296 | #define ACTION_LAYER_SET_P(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_ON_PRESS) | ||
| 297 | #define ACTION_LAYER_SET_R(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_ON_RELEASE) | ||
| 298 | #define ACTION_LAYER_SET_B(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_ON_BOTH) | ||
| 299 | #define ACTION_LAYER_SET_TAP_TOGGLE(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_TAP_TOGGLE) | ||
| 300 | #define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER_SET, (layer)<<8 | (key)) | ||
| 301 | /* | ||
| 302 | * Current layer: Bit-op | ||
| 303 | */ | 279 | */ |
| 304 | #define ACTION_LAYER_BIT(bits) ACTION_LAYER_BIT_MOMENTARY(bits) | 280 | #define ACTION_KEYMAP(layer) ACTION_KEYMAP_MOMENTARY(layer) |
| 305 | #define ACTION_LAYER_BIT_MOMENTARY(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_MOMENTARY) | 281 | #define ACTION_KEYMAP_MOMENTARY(layer) ACTION_KEYMAP_INV_B(layer) |
| 306 | #define ACTION_LAYER_BIT_TOGGLE(bits) ACTION_LAYER_BIT_R(bits) | 282 | #define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV_R(layer) |
| 307 | #define ACTION_LAYER_BIT_P(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_PRESS) | 283 | /* Set default layer */ |
| 308 | #define ACTION_LAYER_BIT_R(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_RELEASE) | 284 | #define ACTION_SET_DEFAULT_LAYER(layer) ACTION_KEYMAP_RESET(layer) |
| 309 | #define ACTION_LAYER_BIT_B(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_BOTH) | 285 | #define ACTION_SET_DEFAULT_LAYER_P(layer) ACTION_KEYMAP_RESET_P(layer) |
| 310 | #define ACTION_LAYER_BIT_TAP_TOGGLE(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_TAP_TOGGLE) | 286 | #define ACTION_SET_DEFAULT_LAYER_R(layer) ACTION_KEYMAP_RESET_R(layer) |
| 311 | #define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (bits)<<8 | (key)) | 287 | #define ACTION_SET_DEFAULT_LAYER_B(layer) ACTION_KEYMAP_RESET_B(layer) |
| 288 | /* Keymap Set and clear overaly */ | ||
| 289 | #define ACTION_KEYMAP_RESET(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | 0) | ||
| 290 | #define ACTION_KEYMAP_RESET_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS) | ||
| 291 | #define ACTION_KEYMAP_RESET_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS) | ||
| 292 | #define ACTION_KEYMAP_RESET_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | ON_PRESS) | ||
| 293 | /* Keymap Invert */ | ||
| 294 | #define ACTION_KEYMAP_INV(layer) ACTION_KEYMAP_INV_B(layer) | ||
| 295 | #define ACTION_KEYMAP_TAP_TOGGLE(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0) | ||
| 296 | #define ACTION_KEYMAP_INV_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_PRESS) | ||
| 297 | #define ACTION_KEYMAP_INV_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_RELEASE) | ||
| 298 | #define ACTION_KEYMAP_INV_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | ON_BOTH) | ||
| 299 | /* Keymap On */ | ||
| 300 | #define ACTION_KEYMAP_ON(layer) ACTION_KEYMAP_ON_OFF(layer) | ||
| 301 | #define ACTION_KEYMAP_ON_OFF(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | 0) | ||
| 302 | #define ACTION_KEYMAP_ON_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_PRESS) | ||
| 303 | #define ACTION_KEYMAP_ON_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_RELEASE) | ||
| 304 | #define ACTION_KEYMAP_ON_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | ON_BOTH) | ||
| 305 | /* Keymap Off */ | ||
| 306 | #define ACTION_KEYMAP_OFF(layer) ACTION_KEYMAP_OFF_ON(layer) | ||
| 307 | #define ACTION_KEYMAP_OFF_ON(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | 0) | ||
| 308 | #define ACTION_KEYMAP_OFF_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_PRESS) | ||
| 309 | #define ACTION_KEYMAP_OFF_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_RELEASE) | ||
| 310 | #define ACTION_KEYMAP_OFF_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | ON_BOTH) | ||
| 311 | /* Keymap Set */ | ||
| 312 | #define ACTION_KEYMAP_SET(layer) ACTION_KEYMAP_SET_CLEAR(layer) | ||
| 313 | #define ACTION_KEYMAP_SET_CLEAR(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | 0) | ||
| 314 | #define ACTION_KEYMAP_SET_P(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_PRESS) | ||
| 315 | #define ACTION_KEYMAP_SET_R(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_RELEASE) | ||
| 316 | #define ACTION_KEYMAP_SET_B(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | ON_BOTH) | ||
| 317 | /* Keymap Invert with tap key */ | ||
| 318 | #define ACTION_KEYMAP_TAP_KEY(layer, key) ACTION(ACT_KEYMAP, (layer)<<8 | (key)) | ||
| 319 | |||
| 312 | /* | 320 | /* |
| 313 | * Layer SWITCH | 321 | * Overlay Layer |
| 314 | */ | 322 | */ |
| 315 | /* momentary */ | 323 | #define ACTION_OVERLAY(layer) ACTION_OVERLAY_MOMENTARY(layer) |
| 316 | #define ACTION_LAYER_SWITCH(layer) ACTION_LAYER_SWITCH_MOMENTARY(layer) | 324 | #define ACTION_OVERLAY_MOMENTARY(layer) ACTION_OVERLAY_ON_OFF(layer) |
| 317 | #define ACTION_LAYER_SWITCH_MOMENTARY(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_MOMENTARY) | 325 | #define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV_R(layer) |
| 318 | #define ACTION_LAYER_SWITCH_TOGGLE(layer) ACTION_LAYER_SWITCH_R(layer) | 326 | /* Overlay Clear */ |
| 319 | #define ACTION_LAYER_SWITCH_P(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_ON_PRESS) | 327 | #define ACTION_OVERLAY_CLEAR ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | 0) |
| 320 | #define ACTION_LAYER_SWITCH_R(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_ON_RELEASE) | 328 | #define ACTION_OVERLAY_CLEAR_P ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_PRESS) |
| 321 | #define ACTION_LAYER_SWITCH_B(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_ON_BOTH) | 329 | #define ACTION_OVERLAY_CLEAR_R ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_RELEASE) |
| 322 | #define ACTION_LAYER_SWITCH_TAP_TOGGLE(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_TAP_TOGGLE) | 330 | #define ACTION_OVERLAY_CLEAR_B ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | ON_BOTH) |
| 323 | #define ACTION_LAYER_SWITCH_TAP_KEY(layer, key) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | (key)) | 331 | /* Overlay Invert 4-bit chunk */ |
| 332 | #define ACTION_OVERLAY_INV4(bits, shift) ACTION(ACT_OVERLAY, (bits)<<8 | OP_INV4 | shift) | ||
| 333 | /* Overlay Invert */ | ||
| 334 | #define ACTION_OVERLAY_INV(layer) ACTION_OVERLAY_INV_B(layer) | ||
| 335 | #define ACTION_OVERLAY_TAP_TOGGLE(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | 0) | ||
| 336 | #define ACTION_OVERLAY_INV_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_PRESS) | ||
| 337 | #define ACTION_OVERLAY_INV_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_RELEASE) | ||
| 338 | #define ACTION_OVERLAY_INV_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | ON_BOTH) | ||
| 339 | /* Overlay On */ | ||
| 340 | #define ACTION_OVERLAY_ON(layer) ACTION_OVERLAY_ON_OFF(layer) | ||
| 341 | #define ACTION_OVERLAY_ON_OFF(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | 0) | ||
| 342 | #define ACTION_OVERLAY_ON_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_PRESS) | ||
| 343 | #define ACTION_OVERLAY_ON_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_RELEASE) | ||
| 344 | #define ACTION_OVERLAY_ON_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | ON_BOTH) | ||
| 345 | /* Overlay Off */ | ||
| 346 | #define ACTION_OVERLAY_OFF(layer) ACTION_OVERLAY_OFF_ON(layer) | ||
| 347 | #define ACTION_OVERLAY_OFF_ON(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | 0) | ||
| 348 | #define ACTION_OVERLAY_OFF_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_PRESS) | ||
| 349 | #define ACTION_OVERLAY_OFF_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_RELEASE) | ||
| 350 | #define ACTION_OVERLAY_OFF_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | ON_BOTH) | ||
| 351 | /* Overlay Set */ | ||
| 352 | #define ACTION_OVERLAY_SET(layer) ACTION_OVERLAY_SET_CLEAR(layer) | ||
| 353 | #define ACTION_OVERLAY_SET_CLEAR(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | 0) | ||
| 354 | #define ACTION_OVERLAY_SET_P(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_PRESS) | ||
| 355 | #define ACTION_OVERLAY_SET_R(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_RELEASE) | ||
| 356 | #define ACTION_OVERLAY_SET_B(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | ON_BOTH) | ||
| 357 | /* Overlay Invert with tap key */ | ||
| 358 | #define ACTION_OVERLAY_TAP_KEY(layer, key) ACTION(ACT_OVERLAY, (layer)<<8 | (key)) | ||
| 324 | 359 | ||
| 325 | 360 | ||
| 326 | /* | 361 | /* |
diff --git a/common/command.c b/common/command.c index 2d01c95e6..202d531fd 100644 --- a/common/command.c +++ b/common/command.c | |||
| @@ -543,9 +543,8 @@ static uint8_t numkey2num(uint8_t code) | |||
| 543 | 543 | ||
| 544 | static void switch_default_layer(uint8_t layer) | 544 | static void switch_default_layer(uint8_t layer) |
| 545 | { | 545 | { |
| 546 | // TODO check existence of layer or whether it can be used as default layer | 546 | print("switch_default_layer: "); print_dec(default_layer); print(" to "); print_dec(layer); print("\n"); |
| 547 | print("switch_default_layer: "); print_dec(default_layer); print(" to "); print_dec(layer); | 547 | default_layer_set(layer); |
| 548 | default_layer = layer; | 548 | overlay_clear(); |
| 549 | layer_switch_clear(); | ||
| 550 | clear_keyboard(); | 549 | clear_keyboard(); |
| 551 | } | 550 | } |
diff --git a/common/keymap.c b/common/keymap.c index 078615814..3f13d4497 100644 --- a/common/keymap.c +++ b/common/keymap.c | |||
| @@ -14,13 +14,71 @@ GNU General Public License for more details. | |||
| 14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | #include <avr/pgmspace.h> | ||
| 17 | #include "keymap.h" | 18 | #include "keymap.h" |
| 18 | #include "report.h" | 19 | #include "report.h" |
| 19 | #include "keycode.h" | 20 | #include "keycode.h" |
| 21 | #include "layer_switch.h" | ||
| 20 | #include "action.h" | 22 | #include "action.h" |
| 23 | #include "debug.h" | ||
| 21 | 24 | ||
| 22 | 25 | ||
| 23 | action_t keymap_keycode_to_action(uint8_t keycode) | 26 | static action_t keycode_to_action(uint8_t keycode); |
| 27 | |||
| 28 | #ifdef USE_KEYMAP_V2 | ||
| 29 | /* converts key to action */ | ||
| 30 | action_t action_for_key(uint8_t layer, key_t key) | ||
| 31 | { | ||
| 32 | uint8_t keycode = keymap_key_to_keycode(layer, key); | ||
| 33 | switch (keycode) { | ||
| 34 | case KC_FN0 ... KC_FN31: | ||
| 35 | return keymap_fn_to_action(keycode); | ||
| 36 | default: | ||
| 37 | return keycode_to_action(keycode); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | __attribute__ ((weak)) | ||
| 42 | void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) | ||
| 43 | { | ||
| 44 | } | ||
| 45 | #else | ||
| 46 | /* | ||
| 47 | * legacy keymap support | ||
| 48 | */ | ||
| 49 | /* translation for legacy keymap */ | ||
| 50 | action_t action_for_key(uint8_t layer, key_t key) | ||
| 51 | { | ||
| 52 | /* convert from legacy keycode to action */ | ||
| 53 | /* layer 16-31 indicate 'overlay' but not supported in legacy keymap */ | ||
| 54 | uint8_t keycode = keymap_get_keycode((layer & OVERLAY_MASK), key.row, key.col); | ||
| 55 | action_t action; | ||
| 56 | switch (keycode) { | ||
| 57 | case KC_FN0 ... KC_FN31: | ||
| 58 | { | ||
| 59 | uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); | ||
| 60 | uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); | ||
| 61 | if (key) { | ||
| 62 | action.code = ACTION_KEYMAP_TAP_KEY(layer, key); | ||
| 63 | } else { | ||
| 64 | action.code = ACTION_KEYMAP_MOMENTARY(layer); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | return action; | ||
| 68 | default: | ||
| 69 | return keycode_to_action(keycode); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | /* not used for legacy keymap */ | ||
| 73 | void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) | ||
| 74 | { | ||
| 75 | } | ||
| 76 | #endif | ||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | /* translates keycode to action */ | ||
| 81 | static action_t keycode_to_action(uint8_t keycode) | ||
| 24 | { | 82 | { |
| 25 | action_t action; | 83 | action_t action; |
| 26 | switch (keycode) { | 84 | switch (keycode) { |
| @@ -51,34 +109,3 @@ action_t keymap_keycode_to_action(uint8_t keycode) | |||
| 51 | } | 109 | } |
| 52 | return action; | 110 | return action; |
| 53 | } | 111 | } |
| 54 | |||
| 55 | #ifndef NO_LEGACY_KEYMAP_SUPPORT | ||
| 56 | /* legacy support with weak reference */ | ||
| 57 | __attribute__ ((weak)) | ||
| 58 | action_t action_for_key(uint8_t layer, key_t key) | ||
| 59 | { | ||
| 60 | /* convert from legacy keycode to action */ | ||
| 61 | uint8_t keycode = keymap_get_keycode(layer, key.row, key.col); | ||
| 62 | action_t action; | ||
| 63 | switch (keycode) { | ||
| 64 | case KC_FN0 ... KC_FN31: | ||
| 65 | { | ||
| 66 | uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); | ||
| 67 | uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); | ||
| 68 | if (key) { | ||
| 69 | action.code = ACTION_LAYER_SET_TAP_KEY(layer, key); | ||
| 70 | } else { | ||
| 71 | action.code = ACTION_LAYER_SET_MOMENTARY(layer); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | return action; | ||
| 75 | default: | ||
| 76 | return keymap_keycode_to_action(keycode); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | #endif | ||
| 80 | |||
| 81 | __attribute__ ((weak)) | ||
| 82 | void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) | ||
| 83 | { | ||
| 84 | } | ||
diff --git a/common/keymap.h b/common/keymap.h index 63bf14482..0c483483f 100644 --- a/common/keymap.h +++ b/common/keymap.h | |||
| @@ -23,16 +23,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "action.h" | 23 | #include "action.h" |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | /* translates key_t to keycode */ | 26 | #ifdef USE_KEYMAP_V2 |
| 27 | /* translates key to keycode | ||
| 28 | * layer: 0-15 for base layers | ||
| 29 | * 16-31 for overlays | ||
| 30 | */ | ||
| 27 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); | 31 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); |
| 28 | /* translates keycode to action */ | ||
| 29 | action_t keymap_keycode_to_action(uint8_t keycode); | ||
| 30 | /* translates Fn keycode to action */ | 32 | /* translates Fn keycode to action */ |
| 31 | action_t keymap_fn_to_action(uint8_t keycode); | 33 | action_t keymap_fn_to_action(uint8_t keycode); |
| 32 | 34 | #else | |
| 33 | 35 | #warning "You are using LEGACY KEYAMP. Consider using NEW KEYMAP." | |
| 34 | 36 | /* | |
| 35 | #ifndef NO_LEGACY_KEYMAP_SUPPORT | 37 | * legacy keymap support |
| 38 | */ | ||
| 36 | /* keycode of key */ | 39 | /* keycode of key */ |
| 37 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); | 40 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); |
| 38 | /* layer to move during press Fn key */ | 41 | /* layer to move during press Fn key */ |
diff --git a/common/layer_switch.c b/common/layer_switch.c index 22bfb34f6..19e286f88 100644 --- a/common/layer_switch.c +++ b/common/layer_switch.c | |||
| @@ -6,84 +6,168 @@ | |||
| 6 | #include "layer_switch.h" | 6 | #include "layer_switch.h" |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | /* | ||
| 10 | * Default Layer (0-15) | ||
| 11 | */ | ||
| 9 | uint8_t default_layer = 0; | 12 | uint8_t default_layer = 0; |
| 10 | 13 | ||
| 11 | uint16_t layer_switch_stat = 0; | 14 | void default_layer_set(uint8_t layer) |
| 15 | { | ||
| 16 | debug("default_layer_set: "); | ||
| 17 | debug_dec(default_layer); debug(" to "); | ||
| 18 | |||
| 19 | default_layer = layer; | ||
| 20 | |||
| 21 | debug_dec(default_layer); debug("\n"); | ||
| 22 | |||
| 23 | clear_keyboard_but_mods(); // To avoid stuck keys | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | /* | ||
| 28 | * Keymap Layer (0-15) | ||
| 29 | */ | ||
| 30 | uint16_t keymap_stat = 0; | ||
| 31 | |||
| 32 | /* return highest layer whose state is on */ | ||
| 33 | uint8_t keymap_get_layer(void) | ||
| 34 | { | ||
| 35 | return biton16(keymap_stat); | ||
| 36 | } | ||
| 37 | |||
| 38 | static void keymap_stat_set(uint16_t stat) | ||
| 39 | { | ||
| 40 | debug("keymap: "); | ||
| 41 | keymap_debug(); debug(" to "); | ||
| 12 | 42 | ||
| 43 | keymap_stat = stat; | ||
| 44 | |||
| 45 | keymap_debug(); debug("\n"); | ||
| 46 | |||
| 47 | clear_keyboard_but_mods(); // To avoid stuck keys | ||
| 48 | } | ||
| 49 | |||
| 50 | void keymap_clear(void) | ||
| 51 | { | ||
| 52 | keymap_stat_set(0); | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | void keymap_set(uint16_t stat) | ||
| 57 | { | ||
| 58 | keymap_stat_set(stat); | ||
| 59 | } | ||
| 60 | |||
| 61 | void keymap_move(uint8_t layer) | ||
| 62 | { | ||
| 63 | keymap_stat_set(1<<layer); | ||
| 64 | } | ||
| 13 | 65 | ||
| 14 | uint16_t layer_switch_get_stat(void) | 66 | void keymap_on(uint8_t layer) |
| 15 | { | 67 | { |
| 16 | return layer_switch_stat; | 68 | keymap_stat_set(keymap_stat | (1<<layer)); |
| 17 | } | 69 | } |
| 18 | 70 | ||
| 71 | void keymap_off(uint8_t layer) | ||
| 72 | { | ||
| 73 | keymap_stat_set(keymap_stat & ~(1<<layer)); | ||
| 74 | } | ||
| 75 | |||
| 76 | void keymap_invert(uint8_t layer) | ||
| 77 | { | ||
| 78 | keymap_stat_set(keymap_stat ^ (1<<layer)); | ||
| 79 | } | ||
| 80 | |||
| 81 | void keymap_or(uint16_t stat) | ||
| 82 | { | ||
| 83 | keymap_stat_set(keymap_stat | stat); | ||
| 84 | } | ||
| 85 | void keymap_and(uint16_t stat) | ||
| 86 | { | ||
| 87 | keymap_stat_set(keymap_stat & stat); | ||
| 88 | } | ||
| 89 | void keymap_xor(uint16_t stat) | ||
| 90 | { | ||
| 91 | keymap_stat_set(keymap_stat ^ stat); | ||
| 92 | } | ||
| 93 | |||
| 94 | void keymap_debug(void) | ||
| 95 | { | ||
| 96 | debug_hex16(keymap_stat); debug("("); debug_dec(keymap_get_layer()); debug(")"); | ||
| 97 | } | ||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | /* | ||
| 102 | * Overlay Layer (16-31 = 0-15|0x10) | ||
| 103 | */ | ||
| 104 | uint16_t overlay_stat = 0; | ||
| 105 | |||
| 19 | /* return highest layer whose state is on */ | 106 | /* return highest layer whose state is on */ |
| 20 | uint8_t layer_switch_get_layer(void) | 107 | uint8_t overlay_get_layer(void) |
| 21 | { | 108 | { |
| 22 | return biton16(layer_switch_stat); | 109 | return biton16(overlay_stat); |
| 23 | } | 110 | } |
| 24 | 111 | ||
| 25 | static inline void stat_set(uint16_t stat) | 112 | static void overlay_stat_set(uint16_t stat) |
| 26 | { | 113 | { |
| 27 | debug("layer_switch: "); | 114 | debug("overlay: "); |
| 28 | layer_switch_debug(); debug(" to "); | 115 | overlay_debug(); debug(" to "); |
| 29 | 116 | ||
| 30 | layer_switch_stat = stat; | 117 | overlay_stat = stat; |
| 31 | 118 | ||
| 32 | layer_switch_debug(); debug("\n"); | 119 | overlay_debug(); debug("\n"); |
| 33 | 120 | ||
| 34 | clear_keyboard_but_mods(); // To avoid stuck keys | 121 | clear_keyboard_but_mods(); // To avoid stuck keys |
| 35 | } | 122 | } |
| 36 | 123 | ||
| 37 | void layer_switch_clear(void) | 124 | void overlay_clear(void) |
| 38 | { | 125 | { |
| 39 | stat_set(0); | 126 | overlay_stat_set(0); |
| 40 | } | 127 | } |
| 41 | 128 | ||
| 42 | 129 | ||
| 43 | void layer_switch_set(uint16_t stat) | 130 | void overlay_set(uint16_t stat) |
| 44 | { | 131 | { |
| 45 | stat_set(stat); | 132 | overlay_stat_set(stat); |
| 46 | } | 133 | } |
| 47 | 134 | ||
| 48 | void layer_switch_move(uint8_t layer) | 135 | void overlay_move(uint8_t layer) |
| 49 | { | 136 | { |
| 50 | if (layer) | 137 | overlay_stat_set(1<<layer); |
| 51 | stat_set(1<<layer); | ||
| 52 | else | ||
| 53 | stat_set(0); // fall back to default layer | ||
| 54 | } | 138 | } |
| 55 | 139 | ||
| 56 | void layer_switch_on(uint8_t layer) | 140 | void overlay_on(uint8_t layer) |
| 57 | { | 141 | { |
| 58 | stat_set(layer_switch_stat | (1<<layer)); | 142 | overlay_stat_set(overlay_stat | (1<<layer)); |
| 59 | } | 143 | } |
| 60 | 144 | ||
| 61 | void layer_switch_off(uint8_t layer) | 145 | void overlay_off(uint8_t layer) |
| 62 | { | 146 | { |
| 63 | stat_set(layer_switch_stat & ~(1<<layer)); | 147 | overlay_stat_set(overlay_stat & ~(1<<layer)); |
| 64 | } | 148 | } |
| 65 | 149 | ||
| 66 | void layer_switch_invert(uint8_t layer) | 150 | void overlay_invert(uint8_t layer) |
| 67 | { | 151 | { |
| 68 | stat_set(layer_switch_stat ^ (1<<layer)); | 152 | overlay_stat_set(overlay_stat ^ (1<<layer)); |
| 69 | } | 153 | } |
| 70 | 154 | ||
| 71 | void layer_switch_or(uint16_t stat) | 155 | void overlay_or(uint16_t stat) |
| 72 | { | 156 | { |
| 73 | stat_set(layer_switch_stat | stat); | 157 | overlay_stat_set(overlay_stat | stat); |
| 74 | } | 158 | } |
| 75 | void layer_switch_and(uint16_t stat) | 159 | void overlay_and(uint16_t stat) |
| 76 | { | 160 | { |
| 77 | stat_set(layer_switch_stat & stat); | 161 | overlay_stat_set(overlay_stat & stat); |
| 78 | } | 162 | } |
| 79 | void layer_switch_xor(uint16_t stat) | 163 | void overlay_xor(uint16_t stat) |
| 80 | { | 164 | { |
| 81 | stat_set(layer_switch_stat ^ stat); | 165 | overlay_stat_set(overlay_stat ^ stat); |
| 82 | } | 166 | } |
| 83 | 167 | ||
| 84 | void layer_switch_debug(void) | 168 | void overlay_debug(void) |
| 85 | { | 169 | { |
| 86 | debug_hex16(layer_switch_stat); debug("("); debug_dec(layer_switch_get_layer()); debug(")"); | 170 | debug_hex16(overlay_stat); debug("("); debug_dec(overlay_get_layer()); debug(")"); |
| 87 | } | 171 | } |
| 88 | 172 | ||
| 89 | action_t layer_switch_get_action(key_t key) | 173 | action_t layer_switch_get_action(key_t key) |
| @@ -91,14 +175,27 @@ action_t layer_switch_get_action(key_t key) | |||
| 91 | action_t action; | 175 | action_t action; |
| 92 | action.code = ACTION_TRANSPARENT; | 176 | action.code = ACTION_TRANSPARENT; |
| 93 | 177 | ||
| 94 | /* higher layer first */ | 178 | /* overlay: top layer first */ |
| 95 | for (int8_t i = 15; i >= 0; i--) { | 179 | for (int8_t i = 15; i >= 0; i--) { |
| 96 | if (layer_switch_stat & (1<<i)) { | 180 | if (overlay_stat & (1<<i)) { |
| 181 | action = action_for_key(i | OVERLAY_BIT, key); | ||
| 182 | if (action.code != ACTION_TRANSPARENT) { | ||
| 183 | return action; | ||
| 184 | } | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | /* keymap: top layer first */ | ||
| 189 | for (int8_t i = 15; i >= 0; i--) { | ||
| 190 | if (keymap_stat & (1<<i)) { | ||
| 97 | action = action_for_key(i, key); | 191 | action = action_for_key(i, key); |
| 98 | if (action.code != ACTION_TRANSPARENT) { | 192 | if (action.code != ACTION_TRANSPARENT) { |
| 99 | return action; | 193 | return action; |
| 100 | } | 194 | } |
| 101 | } | 195 | } |
| 102 | } | 196 | } |
| 197 | |||
| 198 | /* default layer */ | ||
| 199 | action = action_for_key(default_layer, key); | ||
| 103 | return action; | 200 | return action; |
| 104 | } | 201 | } |
diff --git a/common/layer_switch.h b/common/layer_switch.h index 25c81a5dc..a566ab12b 100644 --- a/common/layer_switch.h +++ b/common/layer_switch.h | |||
| @@ -22,36 +22,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 22 | #include "action.h" | 22 | #include "action.h" |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | /* overlays are asigned at layer 16-31 */ | ||
| 26 | #define OVERLAY_BIT 0x10 | ||
| 27 | #define OVERLAY_MASK 0x0F | ||
| 28 | |||
| 29 | |||
| 30 | /* | ||
| 31 | * Default Layer | ||
| 32 | */ | ||
| 25 | /* base layer to fall back */ | 33 | /* base layer to fall back */ |
| 26 | extern uint8_t default_layer; | 34 | extern uint8_t default_layer; |
| 35 | void default_layer_set(uint8_t layer); | ||
| 36 | |||
| 37 | |||
| 38 | /* | ||
| 39 | * Keymap Layer | ||
| 40 | */ | ||
| 41 | extern uint16_t keymap_stat; | ||
| 42 | /* return current active layer */ | ||
| 43 | uint8_t keymap_get_layer(void); | ||
| 44 | void keymap_clear(void); | ||
| 45 | void keymap_set(uint16_t stat); | ||
| 46 | void keymap_move(uint8_t layer); | ||
| 47 | void keymap_on(uint8_t layer); | ||
| 48 | void keymap_off(uint8_t layer); | ||
| 49 | void keymap_invert(uint8_t layer); | ||
| 50 | /* bitwise operation */ | ||
| 51 | void keymap_or(uint16_t stat); | ||
| 52 | void keymap_and(uint16_t stat); | ||
| 53 | void keymap_xor(uint16_t stat); | ||
| 54 | void keymap_debug(void); | ||
| 27 | 55 | ||
| 28 | /* layer status */ | ||
| 29 | extern uint16_t layer_switch_stat; | ||
| 30 | 56 | ||
| 31 | /* return layer status */ | 57 | /* |
| 32 | uint16_t layer_switch_get_stat(void); | 58 | * Overlay Layer |
| 59 | */ | ||
| 60 | extern uint16_t overlay_stat; | ||
| 33 | /* return current active layer */ | 61 | /* return current active layer */ |
| 34 | uint8_t layer_switch_get_layer(void); | 62 | uint8_t overlay_get_layer(void); |
| 35 | 63 | void overlay_clear(void); | |
| 36 | /* switch off all layers */ | 64 | void overlay_set(uint16_t stat); |
| 37 | void layer_switch_clear(void); | 65 | void overlay_move(uint8_t layer); |
| 38 | /* set layer status */ | 66 | void overlay_on(uint8_t layer); |
| 39 | void layer_switch_set(uint16_t stat); | 67 | void overlay_off(uint8_t layer); |
| 40 | /* move to layer */ | 68 | void overlay_invert(uint8_t layer); |
| 41 | void layer_switch_move(uint8_t layer); | 69 | /* bitwise operation */ |
| 42 | /* switch on layer */ | 70 | void overlay_or(uint16_t stat); |
| 43 | void layer_switch_on(uint8_t layer); | 71 | void overlay_and(uint16_t stat); |
| 44 | /* switch off layer */ | 72 | void overlay_xor(uint16_t stat); |
| 45 | void layer_switch_off(uint8_t layer); | 73 | void overlay_debug(void); |
| 46 | /* switch state of layer */ | 74 | |
| 47 | void layer_switch_invert(uint8_t layer); | 75 | |
| 48 | |||
| 49 | /* bitwise operation against layer status */ | ||
| 50 | void layer_switch_or(uint16_t stat); | ||
| 51 | void layer_switch_and(uint16_t stat); | ||
| 52 | void layer_switch_xor(uint16_t stat); | ||
| 53 | |||
| 54 | void layer_switch_debug(void); | ||
| 55 | 76 | ||
| 56 | /* return action depending on current layer status */ | 77 | /* return action depending on current layer status */ |
| 57 | action_t layer_switch_get_action(key_t key); | 78 | action_t layer_switch_get_action(key_t key); |
