Last active
January 31, 2017 03:39
-
-
Save SjB/1071122648256b849ea5ab8e732cc0c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "process_keycode/process_tap_dance.h" | |
#include "action.h" | |
#include "action_layer.h" | |
#include "action_util.h" | |
#include "quantum.h" | |
#include "wait.h" | |
#define TD_PRESSED_EVENT 0xFF | |
#define ACTION_TAP_DANCE_MOD_TAP(kc1, kc2) { \ | |
.fn = { NULL, td_mod_tap_on_finished, td_mod_tap_on_reset }, \ | |
.user_data = (void *)&((qk_tap_dance_pair_t) { kc1, kc2 }), \ | |
} | |
void td_mod_tap_on_finished(qk_tap_dance_state_t *state, void *user_data) { | |
qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data; | |
if (state->pressed && state->count == 1) { | |
register_mods(pair->kc2); | |
state->count = TD_PRESSED_EVENT; // magic number for reset | |
} else if (state->count >= 1) { | |
register_code16(pair->kc1); | |
} | |
} | |
void td_mod_tap_on_reset(qk_tap_dance_state_t *state, void *user_data) { | |
qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data; | |
if (state->count == TD_PRESSED_EVENT) { | |
unregister_mods(pair->kc2); | |
} else if (state->count >= 1) { | |
unregister_code16(pair->kc1); | |
} | |
} | |
qk_tap_dance_action_t tap_dance_actions[] = { | |
[0] = ACTION_TAP_DANCE_MOD_TAP(KC_LBRC, MOD_LALT), | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment