2019-03-06 21:20:51 +01:00
|
|
|
#include "stanrc85.h"
|
|
|
|
|
2019-03-23 04:50:56 +01:00
|
|
|
static td_state_t td_state;
|
|
|
|
|
2019-03-06 21:20:51 +01:00
|
|
|
__attribute__ ((weak))
|
|
|
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-23 04:50:56 +01: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 02:18:04 +01:00
|
|
|
#if defined(HAS_ROTARY)
|
|
|
|
void encoder_update_user(uint8_t index, bool clockwise) {
|
|
|
|
if (index == 0) { /* First encoder */
|
|
|
|
if (clockwise) {
|
|
|
|
tap_code(KC_VOLD);
|
|
|
|
} else {
|
|
|
|
tap_code(KC_VOLU);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-09-07 00:04:29 +02:00
|
|
|
#if defined(HAS_INDICATORS)
|
|
|
|
static uint8_t led_user = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lock_unlock (qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
td_state = cur_dance(state);
|
|
|
|
switch (td_state) {
|
|
|
|
case SINGLE_TAP: // Ctl + Alt + Del to unlock workstation
|
|
|
|
tap_code16(KC_CAD);
|
|
|
|
#if defined(HAS_INDICATORS)
|
|
|
|
led_user = 0;
|
2020-12-08 02:18:04 +01:00
|
|
|
#if defined(KEYBOARD_sneakbox_aliceclone)
|
|
|
|
led_user = 1;
|
|
|
|
#endif
|
2020-09-07 00:04:29 +02:00
|
|
|
writePin(INDICATOR_PIN_0, !led_user);
|
|
|
|
wait_ms(200);
|
|
|
|
writePin(INDICATOR_PIN_1, !led_user);
|
|
|
|
wait_ms(200);
|
|
|
|
writePin(INDICATOR_PIN_2, !led_user);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case SINGLE_HOLD:
|
|
|
|
break;
|
|
|
|
case DOUBLE_TAP: //Lock workstation
|
|
|
|
tap_code16(KC_LOCK);
|
|
|
|
#if defined(HAS_INDICATORS)
|
|
|
|
led_user = 1;
|
2020-12-08 02:18:04 +01:00
|
|
|
#if defined(KEYBOARD_sneakbox_aliceclone)
|
|
|
|
led_user = 0;
|
|
|
|
#endif
|
2020-09-07 00:04:29 +02:00
|
|
|
writePin(INDICATOR_PIN_2, !led_user);
|
|
|
|
wait_ms(200);
|
|
|
|
writePin(INDICATOR_PIN_1, !led_user);
|
|
|
|
wait_ms(200);
|
|
|
|
writePin(INDICATOR_PIN_0, !led_user);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 03:45:33 +01:00
|
|
|
qk_tap_dance_action_t tap_dance_actions[] = {
|
2020-09-07 00:04:29 +02:00
|
|
|
[TD_WIN] = ACTION_TAP_DANCE_FN(lock_unlock),
|
2019-05-12 02:51:37 +02:00
|
|
|
[TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_GRV),
|
2019-03-23 04:50:56 +01:00
|
|
|
[TD_RCTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctl_copy_finished, ctl_copy_reset)
|
2019-03-20 03:45:33 +01:00
|
|
|
};
|
|
|
|
|
2019-03-06 21:20:51 +01:00
|
|
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
switch (keycode) {
|
|
|
|
case KC_MAKE:
|
|
|
|
if (!record->event.pressed) {
|
2019-03-08 02:13:02 +01:00
|
|
|
uint8_t mods = get_mods();
|
2019-03-06 21:20:51 +01:00
|
|
|
clear_mods();
|
2019-03-08 02:13:02 +01:00
|
|
|
if (mods & MOD_MASK_SHIFT) {
|
2020-05-15 19:59:25 +02:00
|
|
|
send_string_with_delay_P(PSTR("qmk flash -kb " QMK_KEYBOARD " -km " QMK_KEYMAP "\n"), 10); //New way
|
2019-03-08 02:13:02 +01:00
|
|
|
reset_keyboard();
|
|
|
|
}
|
2020-05-15 19:59:25 +02:00
|
|
|
else
|
|
|
|
send_string_with_delay_P(PSTR("qmk compile -kb " QMK_KEYBOARD " -km " QMK_KEYMAP "\n"), 10); //New way
|
2019-11-28 07:55:29 +01:00
|
|
|
set_mods(mods);
|
2019-03-06 21:20:51 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-03-28 19:46:34 +01:00
|
|
|
case KC_RDP: //Opens Windows RDP
|
|
|
|
if (!record->event.pressed) {
|
|
|
|
register_code(KC_LGUI);
|
|
|
|
tap_code(KC_R);
|
|
|
|
unregister_code(KC_LGUI);
|
|
|
|
wait_ms(200);
|
|
|
|
send_string_with_delay_P(PSTR("mstsc"), 10);
|
|
|
|
send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), 10);
|
|
|
|
}
|
|
|
|
break;
|
2019-03-06 21:20:51 +01:00
|
|
|
}
|
|
|
|
return process_record_keymap(keycode, record);
|
|
|
|
}
|