2018-08-17 23:11:21 +00:00
|
|
|
//Tap Dance Settings
|
|
|
|
#include "wanleg.h"
|
|
|
|
|
2018-10-19 18:01:40 +00:00
|
|
|
//audio settings for one of the tap dances below
|
|
|
|
#ifdef AUDIO_ENABLE
|
|
|
|
float lyrup_song[][2] = SONG(MUSIC_ON_SOUND);
|
|
|
|
float lyrdown_song[][2] = SONG(MUSIC_OFF_SOUND);
|
|
|
|
#endif
|
|
|
|
|
2018-08-17 23:11:21 +00:00
|
|
|
///// QUAD FUNCTION TAP DANCE GENERAL SETUP SECTION START /////
|
|
|
|
///// (no need to edit this section) /////
|
|
|
|
//Enums used to clearly convey the state of the tap dance
|
|
|
|
enum {
|
|
|
|
SINGLE_TAP = 1,
|
|
|
|
SINGLE_HOLD = 2,
|
|
|
|
DOUBLE_TAP = 3,
|
|
|
|
DOUBLE_HOLD = 4,
|
2018-10-19 18:01:40 +00:00
|
|
|
DOUBLE_SINGLE_TAP = 5, //send SINGLE_TAP twice - NOT DOUBLE_TAP
|
|
|
|
TRIPLE_TAP = 6,
|
|
|
|
TRIPLE_HOLD = 7,
|
|
|
|
TRIPLE_SINGLE_TAP = 8
|
2018-08-17 23:11:21 +00:00
|
|
|
// Add more enums here if you want for triple, quadruple, etc.
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool is_press_action;
|
|
|
|
int state;
|
|
|
|
} tap;
|
|
|
|
|
|
|
|
int cur_dance (qk_tap_dance_state_t *state) {
|
|
|
|
if (state->count == 1) {
|
|
|
|
//If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP
|
|
|
|
if (state->interrupted || !state->pressed) return SINGLE_TAP;
|
|
|
|
if (state->interrupted) return SINGLE_TAP;
|
|
|
|
else return SINGLE_HOLD;
|
|
|
|
}
|
|
|
|
//If count = 2, and it has been interrupted - assume that user is trying to type the letter associated
|
|
|
|
//with single tap.
|
|
|
|
else if (state->count == 2) {
|
|
|
|
if (state->interrupted) return DOUBLE_SINGLE_TAP;
|
|
|
|
else if (state->pressed) return DOUBLE_HOLD;
|
|
|
|
else return DOUBLE_TAP;
|
|
|
|
}
|
|
|
|
|
2018-10-19 18:01:40 +00:00
|
|
|
//If count = 3, and it has been interrupted - assume that user is trying to type the letter associated
|
|
|
|
//with double tap.
|
|
|
|
else if (state->count == 3) {
|
|
|
|
if (state->interrupted) return TRIPLE_SINGLE_TAP;
|
|
|
|
else if (state->pressed) return TRIPLE_HOLD;
|
|
|
|
else return TRIPLE_TAP;
|
2018-08-17 23:11:21 +00:00
|
|
|
}
|
2018-10-19 18:01:40 +00:00
|
|
|
else return 9; //magic number. At some point this method will expand to work for more presses
|
2018-08-17 23:11:21 +00:00
|
|
|
}
|
2018-10-19 18:01:40 +00:00
|
|
|
///// QUAD FUNCTION TAP DANCE GENERAL SETUP SECTION END /////
|
|
|
|
///// QUAD FUNCTION TAP DANCE PERSONALIZATION SECTION START /////
|
2018-09-25 22:39:41 +00:00
|
|
|
//instantiate 'tap' for the 'CAD' tap dance.
|
2018-09-17 20:41:59 +00:00
|
|
|
static tap CADtap_state = {
|
|
|
|
.is_press_action = true,
|
|
|
|
.state = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
void CAD_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
CADtap_state.state = cur_dance(state);
|
|
|
|
switch (CADtap_state.state) {
|
2018-10-19 18:01:40 +00:00
|
|
|
case SINGLE_TAP:
|
|
|
|
//register_code(KC_SPC);
|
2018-09-17 20:41:59 +00:00
|
|
|
SEND_STRING(SS_LGUI("l"));
|
2018-09-25 22:39:41 +00:00
|
|
|
#ifdef BACKLIGHT_ENABLE
|
2018-10-19 18:01:40 +00:00
|
|
|
backlight_level(3);
|
2018-09-25 22:39:41 +00:00
|
|
|
#endif
|
2018-09-17 20:41:59 +00:00
|
|
|
break;
|
2018-10-19 18:01:40 +00:00
|
|
|
case SINGLE_HOLD:
|
2018-09-17 20:41:59 +00:00
|
|
|
//register_code(KC_NO);
|
|
|
|
//take a screenshot of a single window, open Paint and paste
|
|
|
|
SEND_STRING(SS_LALT(SS_TAP(X_PSCREEN)) SS_LGUI("r"));
|
2018-12-05 16:42:50 +00:00
|
|
|
wait_ms(500);
|
2018-09-17 20:41:59 +00:00
|
|
|
SEND_STRING("mspaint" SS_TAP(X_ENTER));
|
2018-12-05 16:42:50 +00:00
|
|
|
wait_ms(700);
|
2018-09-17 20:41:59 +00:00
|
|
|
SEND_STRING(SS_LCTRL("v"));
|
|
|
|
break; //register this keycode when button is held
|
2018-10-19 18:01:40 +00:00
|
|
|
case DOUBLE_TAP:
|
|
|
|
//register_code(KC_ENT);
|
2018-09-17 20:41:59 +00:00
|
|
|
SEND_STRING(SS_LCTRL(SS_LALT(SS_TAP(X_DELETE))));
|
2018-09-25 22:39:41 +00:00
|
|
|
#ifdef BACKLIGHT_ENABLE
|
2018-10-19 18:01:40 +00:00
|
|
|
backlight_level(0);
|
2018-09-25 22:39:41 +00:00
|
|
|
#endif
|
2018-09-17 20:41:59 +00:00
|
|
|
break;
|
|
|
|
//case DOUBLE_HOLD: register_code(KC_NO); break; //register this keycode when button is tapped and then held
|
2018-10-19 18:01:40 +00:00
|
|
|
case DOUBLE_HOLD:
|
|
|
|
reset_keyboard();
|
2018-09-17 20:41:59 +00:00
|
|
|
break; //register this keycode when button is tapped and then held
|
2018-10-19 18:01:40 +00:00
|
|
|
case TRIPLE_TAP:
|
|
|
|
SEND_STRING("wanleg@github.com");
|
|
|
|
break;
|
|
|
|
case TRIPLE_HOLD:
|
|
|
|
set_single_persistent_default_layer(1);
|
|
|
|
#ifdef AUDIO_ENABLE
|
|
|
|
stop_all_notes();
|
|
|
|
PLAY_SONG(lyrup_song);
|
|
|
|
#endif
|
|
|
|
break;
|
2018-09-17 20:41:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CAD_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (CADtap_state.state) {
|
2018-10-19 18:01:40 +00:00
|
|
|
//nothing to do
|
2018-09-17 20:41:59 +00:00
|
|
|
}
|
|
|
|
CADtap_state.state = 0;
|
2018-10-19 18:01:40 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 22:39:41 +00:00
|
|
|
//instantiate 'tap' for the 'RST' tap dance.
|
|
|
|
static tap RSTtap_state = {
|
|
|
|
.is_press_action = true,
|
|
|
|
.state = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
void RST_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
RSTtap_state.state = cur_dance(state);
|
|
|
|
switch (RSTtap_state.state) {
|
|
|
|
case SINGLE_TAP: register_code(KC_LCTL); break;
|
|
|
|
case SINGLE_HOLD: register_code(KC_LCTL); break;
|
|
|
|
case DOUBLE_TAP: reset_keyboard(); break;
|
2018-10-19 18:01:40 +00:00
|
|
|
case DOUBLE_SINGLE_TAP: register_code(KC_LCTL); unregister_code(KC_LCTL); register_code(KC_LCTL); break;
|
2018-09-25 22:39:41 +00:00
|
|
|
}
|
2018-10-19 18:01:40 +00:00
|
|
|
}
|
2018-09-25 22:39:41 +00:00
|
|
|
|
|
|
|
void RST_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (RSTtap_state.state) {
|
|
|
|
case SINGLE_TAP: unregister_code(KC_LCTL); break;
|
|
|
|
case SINGLE_HOLD: unregister_code(KC_LCTL); break;
|
2018-10-19 18:01:40 +00:00
|
|
|
case DOUBLE_SINGLE_TAP: unregister_code(KC_LCTL); break;
|
2018-09-25 22:39:41 +00:00
|
|
|
}
|
|
|
|
RSTtap_state.state = 0;
|
2018-10-19 18:01:40 +00:00
|
|
|
}
|
2018-09-25 22:39:41 +00:00
|
|
|
|
|
|
|
//instantiate 'tap' for the 'LYR' tap dance.
|
|
|
|
static tap LYRtap_state = {
|
|
|
|
.is_press_action = true,
|
|
|
|
.state = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
void LYR_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
LYRtap_state.state = cur_dance(state);
|
|
|
|
switch (LYRtap_state.state) {
|
|
|
|
case SINGLE_TAP: register_code(KC_PSLS); break;
|
|
|
|
case DOUBLE_TAP: set_single_persistent_default_layer(_GK); break;
|
|
|
|
case DOUBLE_SINGLE_TAP: register_code(KC_PSLS); unregister_code(KC_PSLS); register_code(KC_PSLS);
|
|
|
|
}
|
2018-10-19 18:01:40 +00:00
|
|
|
}
|
2018-09-25 22:39:41 +00:00
|
|
|
|
|
|
|
void LYR_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (LYRtap_state.state) {
|
|
|
|
case SINGLE_TAP: unregister_code(KC_PSLS); break;
|
|
|
|
case DOUBLE_TAP: set_single_persistent_default_layer(_GK); break;
|
|
|
|
case DOUBLE_SINGLE_TAP: unregister_code(KC_PSLS);
|
|
|
|
}
|
|
|
|
LYRtap_state.state = 0;
|
2018-10-19 18:01:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//instantiate 'tap' for the 'LYR75' tap dance.
|
|
|
|
static tap LYR75tap_state = {
|
|
|
|
.is_press_action = true,
|
|
|
|
.state = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
void LYR75_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
LYR75tap_state.state = cur_dance(state);
|
|
|
|
switch (LYR75tap_state.state) {
|
|
|
|
case SINGLE_TAP: register_code(KC_PSLS); break;
|
2018-12-30 15:53:02 +00:00
|
|
|
case DOUBLE_TAP: set_single_persistent_default_layer(_GK); break;
|
2018-10-19 18:01:40 +00:00
|
|
|
case DOUBLE_SINGLE_TAP: register_code(KC_PSLS); unregister_code(KC_PSLS); register_code(KC_PSLS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LYR75_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (LYR75tap_state.state) {
|
|
|
|
case SINGLE_TAP: unregister_code(KC_PSLS); break;
|
2018-12-30 15:53:02 +00:00
|
|
|
case DOUBLE_TAP: set_single_persistent_default_layer(_GK); break;
|
2018-10-19 18:01:40 +00:00
|
|
|
case DOUBLE_SINGLE_TAP: unregister_code(KC_PSLS);
|
|
|
|
}
|
|
|
|
LYR75tap_state.state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//instantiate 'tap' for the 'LYR50' tap dance.
|
|
|
|
static tap LYR50tap_state = {
|
|
|
|
.is_press_action = true,
|
|
|
|
.state = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
void LYR50_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
LYR50tap_state.state = cur_dance(state);
|
|
|
|
switch (LYR75tap_state.state) {
|
|
|
|
case SINGLE_TAP: register_code(KC_PSLS); break;
|
|
|
|
case DOUBLE_TAP: set_single_persistent_default_layer(GK50); break;
|
|
|
|
case DOUBLE_SINGLE_TAP: register_code(KC_PSLS); unregister_code(KC_PSLS); register_code(KC_PSLS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LYR50_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (LYR50tap_state.state) {
|
|
|
|
case SINGLE_TAP: unregister_code(KC_PSLS); break;
|
|
|
|
case DOUBLE_TAP: set_single_persistent_default_layer(GK50); break;
|
|
|
|
case DOUBLE_SINGLE_TAP: unregister_code(KC_PSLS);
|
|
|
|
}
|
|
|
|
LYR50tap_state.state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//instantiate 'tap' for the 'BSW' tap dance.
|
|
|
|
static tap BSWtap_state = {
|
|
|
|
.is_press_action = true,
|
|
|
|
.state = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
void BSW_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
BSWtap_state.state = cur_dance(state);
|
|
|
|
switch (BSWtap_state.state) {
|
|
|
|
case SINGLE_TAP: register_code(KC_ENTER); break;
|
|
|
|
case SINGLE_HOLD:
|
|
|
|
set_single_persistent_default_layer(0);
|
|
|
|
#ifdef AUDIO_ENABLE
|
|
|
|
stop_all_notes();
|
|
|
|
PLAY_SONG(lyrdown_song);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case DOUBLE_TAP:
|
2022-10-16 13:14:40 +00:00
|
|
|
register_code(KC_LCTL);
|
2018-10-19 18:01:40 +00:00
|
|
|
register_code(KC_C);
|
|
|
|
break;
|
|
|
|
case DOUBLE_HOLD:
|
|
|
|
reset_keyboard();
|
|
|
|
break; //register this keycode when button is tapped and then held
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BSW_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (BSWtap_state.state) {
|
|
|
|
case SINGLE_TAP: unregister_code(KC_ENTER); break;
|
|
|
|
case DOUBLE_TAP:
|
2022-10-16 13:14:40 +00:00
|
|
|
unregister_code(KC_LCTL);
|
2018-10-19 18:01:40 +00:00
|
|
|
unregister_code(KC_C);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
BSWtap_state.state = 0;
|
|
|
|
}
|
|
|
|
|
2018-08-17 23:11:21 +00:00
|
|
|
///// QUAD FUNCTION TAP DANCE PERSONALIZATION SECTION END /////
|
|
|
|
|
|
|
|
//Tap Dance Definitions
|
|
|
|
//THIS SECTION HAS TO BE AT THE END OF THE TAP DANCE SECTION
|
|
|
|
qk_tap_dance_action_t tap_dance_actions[] = {
|
|
|
|
[TD_SFT_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS)
|
|
|
|
// Other declarations would go here, separated by commas, if you have them
|
|
|
|
,[TD_Q_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_Q, KC_ESC)
|
2018-09-25 22:39:41 +00:00
|
|
|
,[RST_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, RST_finished, RST_reset)
|
2018-09-17 20:41:59 +00:00
|
|
|
,[CAD_TD] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, CAD_finished, CAD_reset)
|
2018-09-25 22:39:41 +00:00
|
|
|
,[LYR_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, LYR_finished, LYR_reset)
|
2018-10-19 18:01:40 +00:00
|
|
|
,[LYR75_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, LYR75_finished, LYR75_reset)
|
|
|
|
,[LYR50_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, LYR50_finished, LYR50_reset)
|
|
|
|
,[BSW_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, BSW_finished, BSW_reset)
|
2018-08-17 23:11:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//In Layer declaration, add tap dance item in place of a key code
|
2018-09-25 22:39:41 +00:00
|
|
|
//TD(TD_SFT_CAPS)
|