diff options
| author | tmk <nobody@nowhere> | 2013-02-26 16:27:09 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-02-26 16:27:09 +0900 |
| commit | a207e848b3b308406263576c1e0d066067888416 (patch) | |
| tree | 1e2ac59d8350a8f5a56b645954cae948841e17c9 | |
| parent | 6778324de2f8cbdf4eeada7b2be05937dc833e9b (diff) | |
| download | qmk_firmware-a207e848b3b308406263576c1e0d066067888416.tar.gz qmk_firmware-a207e848b3b308406263576c1e0d066067888416.zip | |
Add tap flags on record_t
| -rw-r--r-- | common/action.c | 46 | ||||
| -rw-r--r-- | common/action.h | 18 | ||||
| -rw-r--r-- | common/action_macro.c | 1 | ||||
| -rw-r--r-- | keyboard/hhkb/keymap.c | 143 |
4 files changed, 104 insertions, 104 deletions
diff --git a/common/action.c b/common/action.c index fc8818030..7f3e236f0 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -206,7 +206,7 @@ void action_exec(keyevent_t event) | |||
| 206 | static void process_action(keyrecord_t *record) | 206 | static void process_action(keyrecord_t *record) |
| 207 | { | 207 | { |
| 208 | keyevent_t event = record->event; | 208 | keyevent_t event = record->event; |
| 209 | uint8_t tap_count = record->tap_count; | 209 | uint8_t tap_count = record->tap.count; |
| 210 | 210 | ||
| 211 | if (IS_NOEVENT(event)) { return; } | 211 | if (IS_NOEVENT(event)) { return; } |
| 212 | 212 | ||
| @@ -295,7 +295,7 @@ static void process_action(keyrecord_t *record) | |||
| 295 | if (waiting_buffer_has_anykey_pressed()) { | 295 | if (waiting_buffer_has_anykey_pressed()) { |
| 296 | debug("MODS_TAP: Tap: Cancel: add_mods\n"); | 296 | debug("MODS_TAP: Tap: Cancel: add_mods\n"); |
| 297 | // ad hoc: set 0 to cancel tap | 297 | // ad hoc: set 0 to cancel tap |
| 298 | record->tap_count = 0; | 298 | record->tap.count = 0; |
| 299 | add_mods(mods); | 299 | add_mods(mods); |
| 300 | } else { | 300 | } else { |
| 301 | debug("MODS_TAP: Tap: register_code\n"); | 301 | debug("MODS_TAP: Tap: register_code\n"); |
| @@ -697,16 +697,17 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 697 | // if tapping | 697 | // if tapping |
| 698 | if (IS_TAPPING_PRESSED()) { | 698 | if (IS_TAPPING_PRESSED()) { |
| 699 | if (WITHIN_TAPPING_TERM(event)) { | 699 | if (WITHIN_TAPPING_TERM(event)) { |
| 700 | if (tapping_key.tap_count == 0) { | 700 | if (tapping_key.tap.count == 0) { |
| 701 | if (IS_TAPPING_KEY(event.key) && !event.pressed) { | 701 | if (IS_TAPPING_KEY(event.key) && !event.pressed) { |
| 702 | // first tap! | 702 | // first tap! |
| 703 | debug("Tapping: First tap(0->1).\n"); | 703 | debug("Tapping: First tap(0->1).\n"); |
| 704 | tapping_key.tap_count = 1; | 704 | tapping_key.tap.count = 1; |
| 705 | tapping_key.tap.interrupted = (waiting_buffer_has_anykey_pressed() ? true : false); | ||
| 705 | debug_tapping_key(); | 706 | debug_tapping_key(); |
| 706 | process_action(&tapping_key); | 707 | process_action(&tapping_key); |
| 707 | 708 | ||
| 708 | // enqueue | 709 | // enqueue |
| 709 | keyp->tap_count = tapping_key.tap_count; | 710 | keyp->tap = tapping_key.tap; |
| 710 | return false; | 711 | return false; |
| 711 | } | 712 | } |
| 712 | #if TAPPING_TERM >= 500 | 713 | #if TAPPING_TERM >= 500 |
| @@ -730,19 +731,19 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 730 | // tap_count > 0 | 731 | // tap_count > 0 |
| 731 | else { | 732 | else { |
| 732 | if (IS_TAPPING_KEY(event.key) && !event.pressed) { | 733 | if (IS_TAPPING_KEY(event.key) && !event.pressed) { |
| 733 | debug("Tapping: Tap release("); debug_dec(tapping_key.tap_count); debug(")\n"); | 734 | debug("Tapping: Tap release("); debug_dec(tapping_key.tap.count); debug(")\n"); |
| 734 | keyp->tap_count = tapping_key.tap_count; | 735 | keyp->tap = tapping_key.tap; |
| 735 | process_action(keyp); | 736 | process_action(keyp); |
| 736 | tapping_key = *keyp; | 737 | tapping_key = *keyp; |
| 737 | debug_tapping_key(); | 738 | debug_tapping_key(); |
| 738 | return true; | 739 | return true; |
| 739 | } | 740 | } |
| 740 | else if (is_tap_key(keyp->event.key) && event.pressed) { | 741 | else if (is_tap_key(keyp->event.key) && event.pressed) { |
| 741 | if (tapping_key.tap_count > 1) { | 742 | if (tapping_key.tap.count > 1) { |
| 742 | debug("Tapping: Start new tap with releasing last tap(>1).\n"); | 743 | debug("Tapping: Start new tap with releasing last tap(>1).\n"); |
| 743 | // unregister key | 744 | // unregister key |
| 744 | process_action(&(keyrecord_t){ | 745 | process_action(&(keyrecord_t){ |
| 745 | .tap_count = tapping_key.tap_count, | 746 | .tap = tapping_key.tap, |
| 746 | .event.key = tapping_key.event.key, | 747 | .event.key = tapping_key.event.key, |
| 747 | .event.time = event.time, | 748 | .event.time = event.time, |
| 748 | .event.pressed = false | 749 | .event.pressed = false |
| @@ -766,7 +767,7 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 766 | } | 767 | } |
| 767 | // after TAPPING_TERM | 768 | // after TAPPING_TERM |
| 768 | else { | 769 | else { |
| 769 | if (tapping_key.tap_count == 0) { | 770 | if (tapping_key.tap.count == 0) { |
| 770 | debug("Tapping: End. Timeout. Not tap(0): "); | 771 | debug("Tapping: End. Timeout. Not tap(0): "); |
| 771 | debug_event(event); debug("\n"); | 772 | debug_event(event); debug("\n"); |
| 772 | process_action(&tapping_key); | 773 | process_action(&tapping_key); |
| @@ -776,17 +777,17 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 776 | } else { | 777 | } else { |
| 777 | if (IS_TAPPING_KEY(event.key) && !event.pressed) { | 778 | if (IS_TAPPING_KEY(event.key) && !event.pressed) { |
| 778 | debug("Tapping: End. last timeout tap release(>0)."); | 779 | debug("Tapping: End. last timeout tap release(>0)."); |
| 779 | keyp->tap_count = tapping_key.tap_count; | 780 | keyp->tap = tapping_key.tap; |
| 780 | process_action(keyp); | 781 | process_action(keyp); |
| 781 | tapping_key = (keyrecord_t){}; | 782 | tapping_key = (keyrecord_t){}; |
| 782 | return true; | 783 | return true; |
| 783 | } | 784 | } |
| 784 | else if (is_tap_key(keyp->event.key) && event.pressed) { | 785 | else if (is_tap_key(keyp->event.key) && event.pressed) { |
| 785 | if (tapping_key.tap_count > 1) { | 786 | if (tapping_key.tap.count > 1) { |
| 786 | debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); | 787 | debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); |
| 787 | // unregister key | 788 | // unregister key |
| 788 | process_action(&(keyrecord_t){ | 789 | process_action(&(keyrecord_t){ |
| 789 | .tap_count = tapping_key.tap_count, | 790 | .tap = tapping_key.tap, |
| 790 | .event.key = tapping_key.event.key, | 791 | .event.key = tapping_key.event.key, |
| 791 | .event.time = event.time, | 792 | .event.time = event.time, |
| 792 | .event.pressed = false | 793 | .event.pressed = false |
| @@ -810,10 +811,11 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 810 | } | 811 | } |
| 811 | } else if (IS_TAPPING_RELEASED()) { | 812 | } else if (IS_TAPPING_RELEASED()) { |
| 812 | if (WITHIN_TAPPING_TERM(event)) { | 813 | if (WITHIN_TAPPING_TERM(event)) { |
| 813 | if (tapping_key.tap_count > 0 && IS_TAPPING_KEY(event.key) && event.pressed) { | 814 | if (tapping_key.tap.count > 0 && IS_TAPPING_KEY(event.key) && event.pressed) { |
| 814 | // sequential tap. | 815 | // sequential tap. |
| 815 | keyp->tap_count = tapping_key.tap_count + 1; | 816 | keyp->tap = tapping_key.tap; |
| 816 | debug("Tapping: Tap press("); debug_dec(keyp->tap_count); debug(")\n"); | 817 | keyp->tap.count += 1; |
| 818 | debug("Tapping: Tap press("); debug_dec(keyp->tap.count); debug(")\n"); | ||
| 817 | process_action(keyp); | 819 | process_action(keyp); |
| 818 | tapping_key = *keyp; | 820 | tapping_key = *keyp; |
| 819 | debug_tapping_key(); | 821 | debug_tapping_key(); |
| @@ -858,16 +860,16 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 858 | static void waiting_buffer_scan_tap(void) | 860 | static void waiting_buffer_scan_tap(void) |
| 859 | { | 861 | { |
| 860 | // tapping already is settled | 862 | // tapping already is settled |
| 861 | if (tapping_key.tap_count > 0) return; | 863 | if (tapping_key.tap.count > 0) return; |
| 862 | // invalid state: tapping_key released && tap_count == 0 | 864 | // invalid state: tapping_key released && tap.count == 0 |
| 863 | if (!tapping_key.event.pressed) return; | 865 | if (!tapping_key.event.pressed) return; |
| 864 | 866 | ||
| 865 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { | 867 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { |
| 866 | if (IS_TAPPING_KEY(waiting_buffer[i].event.key) && | 868 | if (IS_TAPPING_KEY(waiting_buffer[i].event.key) && |
| 867 | !waiting_buffer[i].event.pressed && | 869 | !waiting_buffer[i].event.pressed && |
| 868 | WITHIN_TAPPING_TERM(waiting_buffer[i].event)) { | 870 | WITHIN_TAPPING_TERM(waiting_buffer[i].event)) { |
| 869 | tapping_key.tap_count = 1; | 871 | tapping_key.tap.count = 1; |
| 870 | waiting_buffer[i].tap_count = 1; | 872 | waiting_buffer[i].tap.count = 1; |
| 871 | process_action(&tapping_key); | 873 | process_action(&tapping_key); |
| 872 | 874 | ||
| 873 | debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n"); | 875 | debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n"); |
| @@ -987,6 +989,7 @@ bool is_tap_key(key_t key) | |||
| 987 | default: | 989 | default: |
| 988 | return false; | 990 | return false; |
| 989 | } | 991 | } |
| 992 | case ACT_MACRO: | ||
| 990 | case ACT_FUNCTION: | 993 | case ACT_FUNCTION: |
| 991 | if (action.func.opt & FUNC_TAP) { return true; } | 994 | if (action.func.opt & FUNC_TAP) { return true; } |
| 992 | return false; | 995 | return false; |
| @@ -1006,7 +1009,8 @@ static void debug_event(keyevent_t event) | |||
| 1006 | } | 1009 | } |
| 1007 | static void debug_record(keyrecord_t record) | 1010 | static void debug_record(keyrecord_t record) |
| 1008 | { | 1011 | { |
| 1009 | debug_event(record.event); debug(":"); debug_dec(record.tap_count); | 1012 | debug_event(record.event); debug(":"); debug_dec(record.tap.count); |
| 1013 | if (record.tap.interrupted) debug("-"); | ||
| 1010 | } | 1014 | } |
| 1011 | static void debug_action(action_t action) | 1015 | static void debug_action(action_t action) |
| 1012 | { | 1016 | { |
diff --git a/common/action.h b/common/action.h index 9dea4b0aa..39e0ae328 100644 --- a/common/action.h +++ b/common/action.h | |||
| @@ -23,9 +23,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | /* Struct to record event and tap count */ | 25 | /* Struct to record event and tap count */ |
| 26 | typedef union { | ||
| 27 | struct { | ||
| 28 | bool interrupted :1; | ||
| 29 | bool reserved2 :1; | ||
| 30 | bool reserved1 :1; | ||
| 31 | bool reserved0 :1; | ||
| 32 | uint8_t count :4; | ||
| 33 | }; | ||
| 34 | } tap_t; | ||
| 35 | |||
| 26 | typedef struct { | 36 | typedef struct { |
| 27 | keyevent_t event; | 37 | keyevent_t event; |
| 28 | uint8_t tap_count; | 38 | tap_t tap; |
| 29 | } keyrecord_t; | 39 | } keyrecord_t; |
| 30 | 40 | ||
| 31 | /* Action struct. | 41 | /* Action struct. |
| @@ -377,6 +387,7 @@ enum layer_params { | |||
| 377 | */ | 387 | */ |
| 378 | /* Macro */ | 388 | /* Macro */ |
| 379 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) | 389 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) |
| 390 | #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) | ||
| 380 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) | 391 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) |
| 381 | 392 | ||
| 382 | /* Command */ | 393 | /* Command */ |
| @@ -386,7 +397,8 @@ enum layer_params { | |||
| 386 | enum function_opts { | 397 | enum function_opts { |
| 387 | FUNC_TAP = 0x8, /* indciates function is tappable */ | 398 | FUNC_TAP = 0x8, /* indciates function is tappable */ |
| 388 | }; | 399 | }; |
| 389 | #define ACTION_FUNCTION(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | id) | 400 | #define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id)) |
| 390 | #define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | id) | 401 | #define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | (id)) |
| 402 | #define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | (id)) | ||
| 391 | 403 | ||
| 392 | #endif /* ACTION_H */ | 404 | #endif /* ACTION_H */ |
diff --git a/common/action_macro.c b/common/action_macro.c index 72859c0dd..ca7ffa822 100644 --- a/common/action_macro.c +++ b/common/action_macro.c | |||
| @@ -41,7 +41,6 @@ void action_macro_play(const prog_macro_t *macro_p) | |||
| 41 | case MODS_DOWN: | 41 | case MODS_DOWN: |
| 42 | MACRO_READ(); | 42 | MACRO_READ(); |
| 43 | debug("MODS_DOWN("); debug_hex(macro); debug(")\n"); | 43 | debug("MODS_DOWN("); debug_hex(macro); debug(")\n"); |
| 44 | debug("MODS_UP("); debug_hex(macro); debug(")\n"); | ||
| 45 | add_mods(macro); | 44 | add_mods(macro); |
| 46 | break; | 45 | break; |
| 47 | case MODS_UP: | 46 | case MODS_UP: |
diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c index d4e009ede..0d07c79cf 100644 --- a/keyboard/hhkb/keymap.c +++ b/keyboard/hhkb/keymap.c | |||
| @@ -56,18 +56,18 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 56 | * |-----------------------------------------------------------| | 56 | * |-----------------------------------------------------------| |
| 57 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| | 57 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| |
| 58 | * |-----------------------------------------------------------| | 58 | * |-----------------------------------------------------------| |
| 59 | * |Fn6 | A| S| D| F| G| H| J| K| L|Fn3| '|Return | | 59 | * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn4 | |
| 60 | * |-----------------------------------------------------------| | 60 | * |-----------------------------------------------------------| |
| 61 | * |Fn8 | Z| X| C| V| B| N| M| ,| .|Fn2|Fn12 |Fn1| | 61 | * |Fn5 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1| |
| 62 | * `-----------------------------------------------------------' | 62 | * `-----------------------------------------------------------' |
| 63 | * |Gui|Alt | Fn5 |Alt |Fn4| | 63 | * |Gui|Alt | Fn6 |Alt |Fn7| |
| 64 | * `-------------------------------------------' | 64 | * `-------------------------------------------' |
| 65 | */ | 65 | */ |
| 66 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ | 66 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ |
| 67 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ | 67 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ |
| 68 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN7, \ | 68 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN4, \ |
| 69 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, FN12,FN9, \ | 69 | FN5,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ |
| 70 | LGUI,LALT, FN5, FN14,FN4), | 70 | LGUI,LALT, FN6, RALT,FN7), |
| 71 | 71 | ||
| 72 | /* Layer 1: HHKB mode (HHKB Fn) | 72 | /* Layer 1: HHKB mode (HHKB Fn) |
| 73 | * ,-----------------------------------------------------------. | 73 | * ,-----------------------------------------------------------. |
| @@ -77,7 +77,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 77 | * |-----------------------------------------------------------| | 77 | * |-----------------------------------------------------------| |
| 78 | * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | 78 | * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | |
| 79 | * |-----------------------------------------------------------| | 79 | * |-----------------------------------------------------------| |
| 80 | * |Shift | | | | | | +| -|End|PgD|Dow|Shift |Fn0| | 80 | * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | |
| 81 | * `-----------------------------------------------------------' | 81 | * `-----------------------------------------------------------' |
| 82 | * |Gui|Alt | Space |Alt |Gui| | 82 | * |Gui|Alt | Space |Alt |Gui| |
| 83 | * `-------------------------------------------' | 83 | * `-------------------------------------------' |
| @@ -127,7 +127,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 127 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,NO, \ | 127 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,NO, \ |
| 128 | LGUI,LALT, BTN1, RALT,TRNS), | 128 | LGUI,LALT, BTN1, RALT,TRNS), |
| 129 | 129 | ||
| 130 | /* Layer 4: Matias half keyboard style (Space) | 130 | /* Layer 4: Matias half-qwerty keyboard style (Space) |
| 131 | * ,-----------------------------------------------------------. | 131 | * ,-----------------------------------------------------------. |
| 132 | * | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc| | 132 | * | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc| |
| 133 | * |-----------------------------------------------------------| | 133 | * |-----------------------------------------------------------| |
| @@ -176,7 +176,8 @@ enum function_id { | |||
| 176 | }; | 176 | }; |
| 177 | 177 | ||
| 178 | enum macro_id { | 178 | enum macro_id { |
| 179 | SHIFT_D, | 179 | LSHIFT_PAREN, |
| 180 | RSHIFT_PAREN, | ||
| 180 | HELLO, | 181 | HELLO, |
| 181 | }; | 182 | }; |
| 182 | 183 | ||
| @@ -184,26 +185,26 @@ enum macro_id { | |||
| 184 | /* | 185 | /* |
| 185 | * Fn action definition | 186 | * Fn action definition |
| 186 | */ | 187 | */ |
| 187 | // TODO: use [1] = KEYMAP(...) to prevent from changing index of element? | ||
| 188 | static const uint16_t PROGMEM fn_actions[] = { | 188 | static const uint16_t PROGMEM fn_actions[] = { |
| 189 | ACTION_DEFAULT_LAYER, // FN0 | 189 | [0] = ACTION_DEFAULT_LAYER, // Default layer(not used) |
| 190 | ACTION_KEYMAP(1), // FN1 | 190 | // [1] = ACTION_KEYMAP(1), // HHKB layer |
| 191 | ACTION_KEYMAP_TAP_KEY(2, KC_SLASH), // FN2 Layer with Slash | 191 | [1] = ACTION_KEYMAP_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) |
| 192 | ACTION_KEYMAP_TAP_KEY(3, KC_SCLN), // FN3 Layer with Semicolon | 192 | [2] = ACTION_KEYMAP_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* |
| 193 | 193 | [3] = ACTION_KEYMAP_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* | |
| 194 | ACTION_KEYMAP(3), // FN4 | 194 | [4] = ACTION_RMOD_TAP_KEY(KC_RCTL, KC_ENT), // RControl with tap Enter* |
| 195 | // ACTION_KEYMAP_TOGGLE(3), // FN4 | 195 | [5] = ACTION_LMOD_ONESHOT(KC_LSFT), // Oneshot Shift* |
| 196 | // ACTION_FUNCTION(MACRO, 0), // FN4 | 196 | // [6] = ACTION_KEYMAP_TAP_KEY(4, KC_SPC), // Half-qwerty layer with Space |
| 197 | ACTION_KEYMAP_TAP_KEY(5, KC_SPC), // FN5 | 197 | [6] = ACTION_KEYMAP_TAP_KEY(5, KC_SPC), // Mousekey layer with Space |
| 198 | // ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // FN6 Control with tap Backspace | 198 | // [7] = ACTION_KEYMAP(3), // Mousekey layer |
| 199 | ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // FN6 Control with tap Backspace | 199 | [7] = ACTION_KEYMAP_TOGGLE(3), // Mousekey layer(toggle) |
| 200 | ACTION_RMOD_TAP_KEY(KC_RCTL, KC_ENT), // FN7 Control with tap Enter | 200 | |
| 201 | ACTION_LMOD_ONESHOT(KC_LSFT), // FN8 Oneshot Shift | 201 | // [8] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace |
| 202 | [9] = ACTION_KEYMAP_TAP_TOGGLE(1), // FN9 | 202 | // [9] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc |
| 203 | [11] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // FN11 Function: LShift with tap '(' | 203 | // [11] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '(' |
| 204 | [12] = ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // FN12 Function: RShift with tap ')' | 204 | // [12] = ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // Function: RShift with tap ')' |
| 205 | [13] = ACTION_MACRO(SHIFT_D), | 205 | // [13] = ACTION_MACRO_TAP(LSHIFT_PAREN), // Macro: LShift with tap '(' |
| 206 | [14] = ACTION_MACRO(HELLO), | 206 | // [14] = ACTION_MACRO_TAP(RSHIFT_PAREN), // Macro: RShift with tap ')' |
| 207 | // [15] = ACTION_MACRO(HELLO), // Macro: say hello | ||
| 207 | }; | 208 | }; |
| 208 | 209 | ||
| 209 | 210 | ||
| @@ -213,13 +214,25 @@ static const uint16_t PROGMEM fn_actions[] = { | |||
| 213 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | 214 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 214 | { | 215 | { |
| 215 | keyevent_t event = record->event; | 216 | keyevent_t event = record->event; |
| 216 | //uint8_t tap_count = record->tap_count; | 217 | tap_t tap = record->tap; |
| 217 | 218 | ||
| 218 | switch (id) { | 219 | switch (id) { |
| 219 | case SHIFT_D: | 220 | case LSHIFT_PAREN: |
| 220 | return (event.pressed ? | 221 | if (tap.count > 0 && !tap.interrupted) { |
| 221 | MACRO( MD(LSHIFT), D(D), END ) : | 222 | return (event.pressed ? |
| 222 | MACRO( U(D), MU(LSHIFT), END ) ); | 223 | MACRO( MD(LSHIFT), D(9), U(9), MU(LSHIFT), END ) : MACRO_NONE); |
| 224 | } else { | ||
| 225 | return (event.pressed ? | ||
| 226 | MACRO( MD(LSHIFT), END ) : MACRO( MU(LSHIFT), END ) ); | ||
| 227 | } | ||
| 228 | case RSHIFT_PAREN: | ||
| 229 | if (tap.count > 0 && !tap.interrupted) { | ||
| 230 | return (event.pressed ? | ||
| 231 | MACRO( MD(RSHIFT), D(0), U(0), MU(RSHIFT), END ) : MACRO_NONE); | ||
| 232 | } else { | ||
| 233 | return (event.pressed ? | ||
| 234 | MACRO( MD(RSHIFT), END ) : MACRO( MU(RSHIFT), END ) ); | ||
| 235 | } | ||
| 223 | case HELLO: | 236 | case HELLO: |
| 224 | return (event.pressed ? | 237 | return (event.pressed ? |
| 225 | MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : | 238 | MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : |
| @@ -236,74 +249,46 @@ const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t op | |||
| 236 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | 249 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 237 | { | 250 | { |
| 238 | keyevent_t event = record->event; | 251 | keyevent_t event = record->event; |
| 239 | uint8_t tap_count = record->tap_count; | 252 | tap_t tap = record->tap; |
| 240 | |||
| 241 | debug("action_call_function: "); | ||
| 242 | if (event.pressed) debug("pressed"); else debug("released"); | ||
| 243 | debug(" id: "); debug_hex(id); | ||
| 244 | debug(" tap_count: "); debug_dec(tap_count); | ||
| 245 | debug("\n"); | ||
| 246 | 253 | ||
| 247 | switch (id) { | 254 | switch (id) { |
| 248 | case LSHIFT_LPAREN: | 255 | case LSHIFT_LPAREN: |
| 249 | // LShft + tap '(' | 256 | // LShft + tap '(' |
| 257 | // NOTE: cant use register_code to avoid conflicting with magic key bind | ||
| 250 | if (event.pressed) { | 258 | if (event.pressed) { |
| 251 | if (tap_count == 0) { | 259 | if (tap.count == 0 || tap.interrupted) { |
| 252 | add_mods(MOD_BIT(KC_LSHIFT)); | 260 | add_mods(MOD_BIT(KC_LSHIFT)); |
| 253 | } else { | 261 | } else { |
| 254 | if (waiting_buffer_has_anykey_pressed()) { | 262 | host_add_mods(MOD_BIT(KC_LSHIFT)); |
| 255 | // ad hoc: set 0 to cancel tap | 263 | host_add_key(KC_9); |
| 256 | record->tap_count = 0; | 264 | host_send_keyboard_report(); |
| 257 | add_mods(MOD_BIT(KC_LSHIFT)); | ||
| 258 | } else { | ||
| 259 | // NOTE to avoid conflicting command key bind(LShift+RShift) | ||
| 260 | //register_code(KC_LSHIFT); | ||
| 261 | //register_code(KC_9); | ||
| 262 | host_add_mods(MOD_BIT(KC_LSHIFT)); | ||
| 263 | host_add_key(KC_9); | ||
| 264 | host_send_keyboard_report(); | ||
| 265 | } | ||
| 266 | } | ||
| 267 | } else { | ||
| 268 | if (tap_count == 0) { | ||
| 269 | del_mods(MOD_BIT(KC_LSHIFT)); | ||
| 270 | } else { | ||
| 271 | //unregister_code(KC_9); | ||
| 272 | //unregister_code(KC_LSHIFT); | ||
| 273 | host_del_mods(MOD_BIT(KC_LSHIFT)); | 265 | host_del_mods(MOD_BIT(KC_LSHIFT)); |
| 274 | host_del_key(KC_9); | 266 | host_del_key(KC_9); |
| 275 | host_send_keyboard_report(); | 267 | host_send_keyboard_report(); |
| 276 | } | 268 | } |
| 269 | } else { | ||
| 270 | if (tap.count == 0 || tap.interrupted) { | ||
| 271 | del_mods(MOD_BIT(KC_LSHIFT)); | ||
| 272 | } | ||
| 277 | } | 273 | } |
| 278 | break; | 274 | break; |
| 279 | case RSHIFT_RPAREN: | 275 | case RSHIFT_RPAREN: |
| 280 | // RShift + tap ')' | 276 | // RShift + tap ')' |
| 281 | if (event.pressed) { | 277 | if (event.pressed) { |
| 282 | if (tap_count == 0) { | 278 | if (tap.count == 0 || tap.interrupted) { |
| 283 | add_mods(MOD_BIT(KC_RSHIFT)); | 279 | add_mods(MOD_BIT(KC_RSHIFT)); |
| 284 | } else { | 280 | } else { |
| 285 | if (waiting_buffer_has_anykey_pressed()) { | 281 | host_add_mods(MOD_BIT(KC_RSHIFT)); |
| 286 | // ad hoc: set 0 to cancel tap | 282 | host_add_key(KC_0); |
| 287 | record->tap_count = 0; | 283 | host_send_keyboard_report(); |
| 288 | add_mods(MOD_BIT(KC_RSHIFT)); | ||
| 289 | } else { | ||
| 290 | //register_code(KC_RSHIFT); | ||
| 291 | //register_code(KC_0); | ||
| 292 | host_add_mods(MOD_BIT(KC_RSHIFT)); | ||
| 293 | host_add_key(KC_0); | ||
| 294 | host_send_keyboard_report(); | ||
| 295 | } | ||
| 296 | } | ||
| 297 | } else { | ||
| 298 | if (tap_count == 0) { | ||
| 299 | del_mods(MOD_BIT(KC_RSHIFT)); | ||
| 300 | } else { | ||
| 301 | //unregister_code(KC_0); | ||
| 302 | //unregister_code(KC_RSHIFT); | ||
| 303 | host_del_mods(MOD_BIT(KC_RSHIFT)); | 284 | host_del_mods(MOD_BIT(KC_RSHIFT)); |
| 304 | host_del_key(KC_0); | 285 | host_del_key(KC_0); |
| 305 | host_send_keyboard_report(); | 286 | host_send_keyboard_report(); |
| 306 | } | 287 | } |
| 288 | } else { | ||
| 289 | if (tap.count == 0 || tap.interrupted) { | ||
| 290 | del_mods(MOD_BIT(KC_RSHIFT)); | ||
| 291 | } | ||
| 307 | } | 292 | } |
| 308 | break; | 293 | break; |
| 309 | } | 294 | } |
