2019-03-07 02:20:51 +06:00
|
|
|
#include "stanrc85.h"
|
|
|
|
|
2019-03-23 09:50:56 +06:00
|
|
|
static td_state_t td_state;
|
|
|
|
|
2019-03-07 02:20:51 +06:00
|
|
|
__attribute__ ((weak))
|
|
|
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-23 09:50:56 +06:00
|
|
|
// determine the tapdance state to return
|
|
|
|
int cur_dance (qk_tap_dance_state_t *state) {
|
|
|
|
if (state->count == 1) {
|
|
|
|
if (state->interrupted || !state->pressed) { return SINGLE_TAP; }
|
|
|
|
else { return SINGLE_HOLD; }
|
|
|
|
}
|
|
|
|
if (state->count == 2) { return DOUBLE_TAP; }
|
|
|
|
else { return 3; } // any number higher than the maximum state value you return above
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle the possible states for each tapdance keycode you define:
|
|
|
|
void ctl_copy_finished (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
td_state = cur_dance(state);
|
|
|
|
switch (td_state) {
|
|
|
|
case SINGLE_TAP:
|
|
|
|
SEND_STRING(SS_LCTRL("c"));
|
|
|
|
break;
|
|
|
|
case SINGLE_HOLD:
|
|
|
|
register_mods(MOD_BIT(KC_RCTL));
|
|
|
|
break;
|
|
|
|
case DOUBLE_TAP:
|
|
|
|
SEND_STRING(SS_LCTRL("v"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ctl_copy_reset (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
switch (td_state) {
|
|
|
|
case SINGLE_TAP:
|
|
|
|
break;
|
|
|
|
case SINGLE_HOLD:
|
|
|
|
unregister_mods(MOD_BIT(KC_RCTL));
|
|
|
|
break;
|
|
|
|
case DOUBLE_TAP:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 08:45:33 +06:00
|
|
|
qk_tap_dance_action_t tap_dance_actions[] = {
|
|
|
|
[TD_WIN] = ACTION_TAP_DANCE_DOUBLE(KC_CAD, KC_LOCK),
|
2019-03-23 09:50:56 +06:00
|
|
|
[TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_GRV),
|
|
|
|
[TD_RCTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctl_copy_finished, ctl_copy_reset)
|
2019-03-20 08:45:33 +06:00
|
|
|
};
|
|
|
|
|
2019-03-07 02:20:51 +06:00
|
|
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
switch (keycode) {
|
|
|
|
case KC_MAKE:
|
|
|
|
if (!record->event.pressed) {
|
2019-03-08 07:13:02 +06:00
|
|
|
uint8_t mods = get_mods();
|
2019-03-07 02:20:51 +06:00
|
|
|
clear_mods();
|
|
|
|
send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), 10);
|
2019-03-08 07:13:02 +06:00
|
|
|
if (mods & MOD_MASK_SHIFT) {
|
2019-03-07 02:20:51 +06:00
|
|
|
//RESET board for flashing if SHIFT held or tapped with KC_MAKE
|
|
|
|
#if defined(__arm__)
|
|
|
|
send_string_with_delay_P(PSTR(":dfu-util"), 10);
|
|
|
|
#elif defined(BOOTLOADER_DFU)
|
|
|
|
send_string_with_delay_P(PSTR(":dfu"), 10);
|
|
|
|
#elif defined(BOOTLOADER_HALFKAY)
|
|
|
|
send_string_with_delay_P(PSTR(":teensy"), 10);
|
|
|
|
#elif defined(BOOTLOADER_CATERINA)
|
|
|
|
send_string_with_delay_P(PSTR(":avrdude"), 10);
|
|
|
|
#endif // bootloader options
|
2019-03-08 07:13:02 +06:00
|
|
|
send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), 10);
|
|
|
|
reset_keyboard();
|
|
|
|
}
|
|
|
|
if (mods & MOD_MASK_CTRL) {
|
|
|
|
send_string_with_delay_P(PSTR(" -j8 --output-sync"), 10);
|
2019-03-07 02:20:51 +06:00
|
|
|
}
|
|
|
|
send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), 10);
|
2019-03-08 07:13:02 +06:00
|
|
|
set_mods(mods);
|
2019-03-07 02:20:51 +06:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return process_record_keymap(keycode, record);
|
|
|
|
}
|