diff options
author | Alex Ong <the.onga@gmail.com> | 2019-01-04 19:39:14 +1100 |
---|---|---|
committer | Alex Ong <the.onga@gmail.com> | 2019-01-04 19:39:14 +1100 |
commit | 47c91fc7f75ae0a477e55b687aa0fc30da0a283c (patch) | |
tree | 65ad39452748ff2e6d4a83ce54ede6ca22c9ada9 /keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance | |
parent | ac9b88e8ccbbf38762871504cd827ff0d941c426 (diff) | |
parent | 563ce3f225d981ce460c12ca5130dfe47af41df0 (diff) |
Merge branch 'master' of https://github.com/qmk/qmk_firmware
Diffstat (limited to 'keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance')
4 files changed, 209 insertions, 0 deletions
diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c new file mode 100644 index 0000000000..6debc1ce45 --- /dev/null +++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c @@ -0,0 +1,40 @@ +//instanalize an instance of 'tap' for the None - Lead tap dance. +static tap none_lead_state = { + .is_press_action = true, + .state = 0 +}; + +void none_lead_finished(qk_tap_dance_state_t *state, void *user_data) { + none_lead_state.state = current_dance(state); + switch (none_lead_state.state) { + case SINGLE_TAP: + register_code(KC_NO); + break; + + case SINGLE_HOLD: + register_code(KC_LALT); + register_code(KC_LSFT); + break; + + case DOUBLE_TAP: + qk_leader_start(); + break; + } +} + +void none_lead_reset(qk_tap_dance_state_t *state, void *user_data) { + switch (none_lead_state.state) { + case SINGLE_TAP: + unregister_code(KC_NO); + break; + + case SINGLE_HOLD: + unregister_code(KC_LALT); + unregister_code(KC_LSFT); + break; + + case DOUBLE_TAP: + break; + } + none_lead_state.state = 0; +} diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dance_actions.c b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dance_actions.c new file mode 100644 index 0000000000..550e1f7c84 --- /dev/null +++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dance_actions.c @@ -0,0 +1,20 @@ +// Register the double tap dances: +qk_tap_dance_action_t tap_dance_actions[] = { + [EQL_PLUS] = ACTION_TAP_DANCE_DOUBLE(KC_EQL, KC_PLUS), + [MINS_UNDS] = ACTION_TAP_DANCE_DOUBLE(KC_MINS, KC_UNDS), + [SLSH_BSLS] = ACTION_TAP_DANCE_DOUBLE(KC_SLSH, KC_BSLS), + [GRV_TILD] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_TILD), + [QUOT_DQUO] = ACTION_TAP_DANCE_DOUBLE(KC_QUOT, KC_DQUO), + [SCLN_COLN] = ACTION_TAP_DANCE_DOUBLE(KC_SCLN, KC_COLN), + [ASTR_CIRC] = ACTION_TAP_DANCE_DOUBLE(KC_ASTR, KC_CIRC), + [APMR_PIPE] = ACTION_TAP_DANCE_DOUBLE(KC_AMPR, KC_PIPE), + [EXLM_QUES] = ACTION_TAP_DANCE_DOUBLE(KC_EXLM, KC_QUES), + [HASH_PERC] = ACTION_TAP_DANCE_DOUBLE(KC_HASH, KC_PERC), + [AT_DLR] = ACTION_TAP_DANCE_DOUBLE(KC_AT, KC_DLR), + [LPRN_LBRC] = ACTION_TAP_DANCE_DOUBLE(KC_LPRN, KC_LBRC), + [RPRN_RBRC] = ACTION_TAP_DANCE_DOUBLE(KC_RPRN, KC_RBRC), + [LCBR_LABK] = ACTION_TAP_DANCE_DOUBLE(KC_LCBR, KC_LABK), + [RCBR_RABK] = ACTION_TAP_DANCE_DOUBLE(KC_RCBR, KC_RABK), + [DOT_COMM] = ACTION_TAP_DANCE_DOUBLE(KC_DOT, KC_COMM), + [NONE_LEAD] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, none_lead_finished, none_lead_reset, DANCING_TERM) +}; diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dance_setup.c b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dance_setup.c new file mode 100644 index 0000000000..340ccca133 --- /dev/null +++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dance_setup.c @@ -0,0 +1,75 @@ +typedef struct { + bool is_press_action; + int state; +} tap; + +enum { + SINGLE_TAP = 1, + SINGLE_HOLD = 2, + DOUBLE_TAP = 3, + DOUBLE_HOLD = 4, + DOUBLE_SINGLE_TAP = 5, // Send two single taps. + TRIPLE_TAP = 6, + TRIPLE_HOLD = 7, + TRIPLE_SINGLE_TAP = 8 // Send three single taps. +}; + +/* Return an integer that corresponds to what kind of tap dance should be executed. + * + * How to figure out tap dance state: interrupted and pressed. + * + * Interrupted: If the state of a dance dance is "interrupted", that means that another key has been hit + * under the tapping term. This is typically indicitive that you are trying to "tap" the key. + * + * Pressed: Whether or not the key is still being pressed. If this value is true, that means the tapping term + * has ended, but the key is still being pressed down. This generally means the key is being "held". + * + * One thing that is currenlty not possible with qmk software in regards to tap dance is to mimic the "permissive hold" + * feature. In general, advanced tap dances do not work well if they are used with commonly typed letters. + * For example "A". Tap dances are best used on non-letter keys that are not hit while typing letters. + * + * Good places to put an advanced tap dance: + * z,q,x,j,k,v,b, any function key, home/end, comma, semi-colon + * + * Criteria for "good placement" of a tap dance key: + * Not a key that is hit frequently in a sentence + * Not a key that is used frequently to double tap, for example 'tab' is often double tapped in a terminal, or + * in a web form. So 'tab' would be a poor choice for a tap dance. + * Letters used in common words as a double. For example 'p' in 'pepper'. If a tap dance function existed on the + * letter 'p', the word 'pepper' would be quite frustating to type. + * + * For the third point, there does exist the 'DOUBLE_SINGLE_TAP', however this is not fully tested + * + */ +int current_dance(qk_tap_dance_state_t *state) { + int current_state = 0; + if (state->count == 1) { + if (state->interrupted || !state->pressed) { + current_state = SINGLE_TAP; + } else { + current_state = SINGLE_HOLD; //key has not been interrupted, but they key is still held. Means you want to send a 'HOLD'. + } + } else if (state->count == 2) { + /* + * DOUBLE_SINGLE_TAP is to distinguish between typing "pepper", and actually wanting a double tap + * action when hitting 'pp'. Suggested use case for this return value is when you want to send two + * keystrokes of the key, and not the 'double tap' action/macro. + */ + if (state->interrupted) { + current_state = DOUBLE_SINGLE_TAP; + } else if (state->pressed) { + current_state = DOUBLE_HOLD; + } else { + current_state = DOUBLE_TAP; + } + } else if (state->count == 3) { + if (state->interrupted) { + current_state = TRIPLE_SINGLE_TAP; + } else if (state->pressed) { + current_state = TRIPLE_HOLD; + } else { + current_state = TRIPLE_TAP; + } + } + return current_state; +} diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dances.c b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dances.c new file mode 100644 index 0000000000..3d44698729 --- /dev/null +++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/tap_dances.c @@ -0,0 +1,74 @@ + //--------------------------------------------------------------------------------------------// + // | | | | | // + // Single tap | Single hold | Double tap | Double hold | Triple tap | Triple hold // +// Mod tap dances: // | | | | | // +enum tap_dances { //--------------------------------------------------------------------------------------------// + // | | | | | // + EQL_PLUS = 0, // = | + | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + MINS_UNDS = 1, // - | _ | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + SLSH_BSLS = 2, // / | \ | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + GRV_TILD = 3, // ` | ~ | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + QUOT_DQUO = 4, // ' | " | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + SCLN_COLN = 5, // ; | : | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + ASTR_CIRC = 6, // * | ^ | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + APMR_PIPE = 7, // & | | | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + EXLM_QUES = 8, // ! | ? | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + HASH_PERC = 9, // # | % | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + AT_DLR = 10, // @ | $ | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + LPRN_LBRC = 11, // ( | [ | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + RPRN_RBRC = 12, // ) | ] | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + LCBR_LABK = 13, // { | < | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + RCBR_RABK = 14, // } | > | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + DOT_COMM = 15, // . | , | | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// + // | | | | | // + NONE_LEAD = 16, // NONE | ALT+SHIFT | LEAD | | | // + // | | | | | // + //--------------------------------------------------------------------------------------------// +}; |