Tweak double tap mouse keys functionality

This commit is contained in:
kemonine 2020-09-29 17:41:04 -04:00
parent aa5d14331e
commit c7aac62d07
2 changed files with 10 additions and 10 deletions

View file

@ -46,7 +46,7 @@ enum {
}; };
enum td_keycodes { enum td_keycodes {
ALT_LAYER // Our example key: `LALT` when held, `(` when tapped. Add additional keycodes for each tapdance. LAYERS // Our example key: `MOD(1)` when held, `TG(2)` when tapped. Add additional keycodes for each tapdance.
}; };
qk_tap_dance_action_t tap_dance_actions[] = { qk_tap_dance_action_t tap_dance_actions[] = {
@ -64,7 +64,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
LM(1, MOD_LALT), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN, LM(1, MOD_LALT), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
KC_LCTL, KC_LGUI, TD(ALT_LAYER), KC_SPC, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, TT(LAYERS), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
[1] = LAYOUT_65_ansi_blocker(KC_GRV, 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_DEL, KC_DEL, [1] = LAYOUT_65_ansi_blocker(KC_GRV, 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_DEL, KC_DEL,
KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_INS, KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_INS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR,
@ -126,10 +126,10 @@ void al_finished(qk_tap_dance_state_t *state, void *user_data) {
al_tap_state.state = cur_dance(state); al_tap_state.state = cur_dance(state);
switch (al_tap_state.state) { switch (al_tap_state.state) {
case SINGLE_TAP: case SINGLE_TAP:
tap_code(KC_LALT); // Do nothing ; Should be held to get layer 1
break; break;
case SINGLE_HOLD: case SINGLE_HOLD:
register_mods(MOD_BIT(KC_LALT)); layer_on(1); // Activate layer 1 since that's what the intent is
break; break;
case DOUBLE_TAP: case DOUBLE_TAP:
// Check to see if the layer is already set // Check to see if the layer is already set
@ -147,7 +147,7 @@ void al_finished(qk_tap_dance_state_t *state, void *user_data) {
void al_reset(qk_tap_dance_state_t *state, void *user_data) { void al_reset(qk_tap_dance_state_t *state, void *user_data) {
// If the key was held down and now is released then switch off the layer // If the key was held down and now is released then switch off the layer
if (al_tap_state.state == SINGLE_HOLD) { if (al_tap_state.state == SINGLE_HOLD) {
unregister_mods(MOD_BIT(KC_LALT)); layer_off(1); // Reset state appropriately
} }
al_tap_state.state = 0; al_tap_state.state = 0;
} }

View file

@ -46,7 +46,7 @@ enum {
}; };
enum td_keycodes { enum td_keycodes {
ALT_LAYER // Our example key: `LALT` when held, `(` when tapped. Add additional keycodes for each tapdance. LAYERS // Our example key: `MOD(1)` when held, `TG(2)` when tapped. Add additional keycodes for each tapdance.
}; };
qk_tap_dance_action_t tap_dance_actions[] = { qk_tap_dance_action_t tap_dance_actions[] = {
@ -64,7 +64,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
LM(1, MOD_LALT), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN, LM(1, MOD_LALT), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
KC_LCTL, KC_LGUI, TD(ALT_LAYER), KC_SPC, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, TT(LAYERS), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
[1] = LAYOUT_65_ansi_blocker(KC_GRV, 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_DEL, KC_DEL, [1] = LAYOUT_65_ansi_blocker(KC_GRV, 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_DEL, KC_DEL,
KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_INS, KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_INS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR,
@ -126,10 +126,10 @@ void al_finished(qk_tap_dance_state_t *state, void *user_data) {
al_tap_state.state = cur_dance(state); al_tap_state.state = cur_dance(state);
switch (al_tap_state.state) { switch (al_tap_state.state) {
case SINGLE_TAP: case SINGLE_TAP:
tap_code(KC_LALT); // Do nothing ; Should be held to get layer 1
break; break;
case SINGLE_HOLD: case SINGLE_HOLD:
register_mods(MOD_BIT(KC_LALT)); layer_on(1); // Activate layer 1 since that's what the intent is
break; break;
case DOUBLE_TAP: case DOUBLE_TAP:
// Check to see if the layer is already set // Check to see if the layer is already set
@ -147,7 +147,7 @@ void al_finished(qk_tap_dance_state_t *state, void *user_data) {
void al_reset(qk_tap_dance_state_t *state, void *user_data) { void al_reset(qk_tap_dance_state_t *state, void *user_data) {
// If the key was held down and now is released then switch off the layer // If the key was held down and now is released then switch off the layer
if (al_tap_state.state == SINGLE_HOLD) { if (al_tap_state.state == SINGLE_HOLD) {
unregister_mods(MOD_BIT(KC_LALT)); layer_off(1); // Reset state appropriately
} }
al_tap_state.state = 0; al_tap_state.state = 0;
} }