Merge pull request #1323 from nikchi/master

Variable tapping terms
master
Jack Humbert 2017-05-30 15:38:22 -04:00 committed by GitHub
commit 328bde1624
5 changed files with 62 additions and 22 deletions

View File

@ -3,8 +3,8 @@
#include "../../config.h"
#define TAPPING_TERM 300
#define LEADER_TIMEOUT 400
#define TAPPING_TERM 200
#define LEADER_TIMEOUT 800
#define DISABLE_SPACE_CADET_ROLLOVER
@ -21,4 +21,3 @@
// place overrides here
#endif

View File

@ -6,6 +6,7 @@
#include "quantum.h"
#define _______ KC_TRNS
#define EMOJIBLOCK 5
//declarations for tap dancing emojis
@ -13,6 +14,7 @@ void register_hex32(uint32_t hex);
void cycleEmojis(qk_tap_dance_state_t *state, void *user_data);
void cycleAnimals(qk_tap_dance_state_t *state, void *user_data);
void cycleHands(qk_tap_dance_state_t *state, void *user_data);
void cycleMemes(qk_tap_dance_state_t *state, void *user_data);
void tap(uint16_t keycode){
register_code(keycode);
@ -24,7 +26,8 @@ enum taps{
TD_CTCPS = 0,
EMOJIS,
ANIMAL,
HAND
HAND,
MEMES
};
enum unicode_name { // split every five emojis
@ -62,22 +65,16 @@ enum my_macros {
RIGHTDESK,
CLOSEDESK
};
enum quick {
DISFACE = 0,
TFLIP,
TPUT,
SHRUG,
FACE,
RANDIG
};
// Tap Dance Definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// Tap once for CTRL, twice for Caps Lock
[TD_CTCPS] = ACTION_TAP_DANCE_DOUBLE(KC_LCTL, KC_CAPS),
[EMOJIS] = ACTION_TAP_DANCE_FN_ADVANCED(cycleEmojis, NULL, NULL),
[ANIMAL] = ACTION_TAP_DANCE_FN_ADVANCED(cycleAnimals, NULL, NULL),
[HAND] = ACTION_TAP_DANCE_FN_ADVANCED(cycleHands, NULL, NULL)
[EMOJIS] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(cycleEmojis, NULL, NULL, 800),
[ANIMAL] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(cycleAnimals, NULL, NULL, 800),
[HAND] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(cycleHands, NULL, NULL, 800),
[MEMES] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(cycleMemes, NULL, NULL, 800)
// Other declarations would go here, separated by commas, if you have them
};
@ -143,7 +140,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
TD(TD_CTCPS),KC_LGUI,KC_LALT, KC_SPC, KC_LEAD,KC_RGUI, KC_APP,MO(1) , KC_LEFT,KC_DOWN,KC_RGHT, KC_P0,KC_PDOT),
[1] = KEYMAP(\
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \
TD(EMOJIS),TD(ANIMAL),TD(HAND),X(SMRK),X(WEARY),X(UNAMU), KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL,KC_BSPC, KC_MPRV,KC_MPLY,KC_MNXT, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, \
TD(EMOJIS),TD(ANIMAL),TD(HAND),TD(MEMES),X(WEARY),X(UNAMU), KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL,KC_BSPC, KC_MPRV,KC_MPLY,KC_MNXT, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, \
KC_TAB, KC_Q, M(0), KC_E, KC_R,X(EGGPL),X(WATER), KC_U, KC_I, KC_O, KC_P, KC_UP ,KC_RBRC,KC_BSLS, KC_MUTE,KC_VOLD,KC_VOLU, KC_P7, KC_P8, KC_P9,KC_PPLS, \
KC_LCTL, M(1), M(3), M(2), KC_F, X(LIT), X(SNEK), KC_J, KC_K, KC_L,KC_LEFT,KC_RGHT, KC_ENT, KC_P4, KC_P5, KC_P6, \
KC_LSFT,KC_NUBS, KC_Z, KC_X, KC_C, X(HUNDR), X(BBB), X(POO), KC_M,KC_COMM, KC_DOT,KC_DOWN, KC_RSFT, KC_MS_U, KC_P1, KC_P2, KC_P3,KC_PENT, \
@ -170,6 +167,11 @@ void matrix_scan_user(void) {
tap(KC_C);
unregister_code(KC_LCTL);
}
SEQ_THREE_KEYS(KC_L,KC_I,KC_T) { // 🔥🔥
unicode_input_start();
register_hex32(pgm_read_dword(&unicode_map[LIT]));
unicode_input_finish();
}
}
}
@ -186,7 +188,7 @@ void cycleEmojis(qk_tap_dance_state_t *state, void *user_data) {
register_hex32(pgm_read_dword(&unicode_map[state->count]));
unicode_input_finish();
}
else if(state->count <= 5) {
else if(state->count <= EMOJIBLOCK) {
tap(KC_BSPC);
unicode_input_start();
register_hex32(pgm_read_dword(&unicode_map[state->count]));
@ -200,7 +202,7 @@ void cycleAnimals(qk_tap_dance_state_t *state, void *user_data) {
register_hex32(pgm_read_dword(&unicode_map[state->count+5]));
unicode_input_finish();
}
else if(state->count <= 5) {
else if(state->count <= EMOJIBLOCK) {
tap(KC_BSPC);
unicode_input_start();
register_hex32(pgm_read_dword(&unicode_map[state->count+5]));
@ -214,7 +216,7 @@ void cycleHands(qk_tap_dance_state_t *state, void *user_data) {
register_hex32(pgm_read_dword(&unicode_map[state->count+10]));
unicode_input_finish();
}
else if(state->count <= 5) {
else if(state->count <= EMOJIBLOCK) {
tap(KC_BSPC);
unicode_input_start();
register_hex32(pgm_read_dword(&unicode_map[state->count+10]));
@ -222,3 +224,18 @@ void cycleHands(qk_tap_dance_state_t *state, void *user_data) {
}
};
void cycleMemes(qk_tap_dance_state_t *state, void *user_data) {
if(state->count == 1) {
unicode_input_start();
register_hex32(pgm_read_dword(&unicode_map[state->count+15]));
unicode_input_finish();
}
else if(state->count <= EMOJIBLOCK) {
tap(KC_BSPC);
unicode_input_start();
register_hex32(pgm_read_dword(&unicode_map[state->count+15]));
unicode_input_finish();
}
};

View File

@ -0,0 +1,9 @@
# Tap Dancing to different beats.
Tap Dance is constrained normally by `TAPPING_TERM` defined in your keyboard's config.h This proves to be challenging to work with when sometimes you just need more time to tap out your dance, or even a different "beat".
- `ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term)` : This works the same as `ACTION_TAP_DANCE_FN_ADVANCED` just with the extra `tap_specific_tapping_term` arguement at the end. This way you can set a specific tap dance to have a longer or shorter tap in between your taps, giving you more, or less, time in between each tap.
`tap_specific_tapping_term` should be the same type and range of values that one would put into the `TAPPING_TERM` definition in the config.h file.

View File

@ -127,14 +127,22 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
return true;
}
void matrix_scan_tap_dance () {
if (highest_td == -1)
return;
uint16_t tap_user_defined;
for (int i = 0; i <= highest_td; i++) {
for (uint8_t i = 0; i <= highest_td; i++) {
qk_tap_dance_action_t *action = &tap_dance_actions[i];
if (action->state.count && timer_elapsed (action->state.timer) > TAPPING_TERM) {
if(action->custom_tapping_term > 0 ) {
tap_user_defined = action->custom_tapping_term;
}
else{
tap_user_defined = TAPPING_TERM;
}
if (action->state.count && timer_elapsed (action->state.timer) > tap_user_defined) {
process_tap_dance_action_on_dance_finished (action);
reset_tap_dance (&action->state);
}

View File

@ -44,6 +44,7 @@ typedef struct
qk_tap_dance_user_fn_t on_reset;
} fn;
qk_tap_dance_state_t state;
uint16_t custom_tapping_term;
void *user_data;
} qk_tap_dance_action_t;
@ -68,6 +69,12 @@ typedef struct
.user_data = NULL, \
}
#define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) { \
.fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset }, \
.user_data = NULL, \
.custom_tapping_term = tap_specific_tapping_term, \
}
extern qk_tap_dance_action_t tap_dance_actions[];
/* To be used internally */