Created
July 7, 2017 20:30
-
-
Save JeanOlivier/d9436c914decede804a1ae048b24a1d1 to your computer and use it in GitHub Desktop.
keymap.c snippet: QMK LGUI hold as F(1).
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
const int GUILAY = 1; | |
typedef struct { | |
bool layer_toggle; | |
bool sticky; | |
} td_ta_state_t; | |
static void ang_tap_dance_ta_finished (qk_tap_dance_state_t *state, void *user_data) { | |
td_ta_state_t *td_ta = (td_ta_state_t *) user_data; | |
if (td_ta->sticky) { | |
td_ta->sticky = false; | |
td_ta->layer_toggle = false; | |
layer_off (GUILAY); | |
return; | |
} | |
if (state->count == 1 && !state->pressed) { | |
register_code (KC_LGUI); | |
td_ta->sticky = false; | |
td_ta->layer_toggle = false; | |
} else { | |
td_ta->layer_toggle = true; | |
layer_on (GUILAY); | |
td_ta->sticky = 0; /*(state->count == 2);*/ | |
} | |
} | |
static void ang_tap_dance_ta_reset (qk_tap_dance_state_t *state, void *user_data) { | |
td_ta_state_t *td_ta = (td_ta_state_t *) user_data; | |
if (!td_ta->layer_toggle) | |
unregister_code (KC_LGUI); | |
if (!td_ta->sticky) | |
layer_off (GUILAY); | |
} | |
qk_tap_dance_action_t tap_dance_actions[] = { | |
[0] = { | |
.fn = { NULL, ang_tap_dance_ta_finished, ang_tap_dance_ta_reset }, | |
.user_data = (void *)&((td_ta_state_t) { false, false }) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment