2019-06-01 14:39:31 -07:00
|
|
|
#include "custom_tap_dance.h"
|
|
|
|
#include "custom_keycodes.h"
|
|
|
|
|
|
|
|
#ifdef TAP_DANCE_ENABLE
|
|
|
|
|
|
|
|
//Tap Dance Definitions
|
2022-12-14 12:40:25 -08:00
|
|
|
tap_dance_action_t tap_dance_actions[] = {
|
2019-06-01 14:39:31 -07:00
|
|
|
[COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT),
|
2022-10-13 10:28:14 -07:00
|
|
|
[BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BACKSPACE, LCTL(KC_BACKSPACE)),
|
2019-07-25 11:56:29 -07:00
|
|
|
[DELETE] = ACTION_TAP_DANCE_DOUBLE (KC_DELETE, LCTL(KC_DELETE))
|
2019-06-01 14:39:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static uint16_t td_keycode;
|
|
|
|
static uint16_t td_timer;
|
|
|
|
|
|
|
|
const uint16_t PROGMEM td_keymaps[TD_MAX - TD_MIN][2] = {
|
|
|
|
[TD_COMM - TD_MIN] = { KC_COMM, KC_QUOT },
|
2022-10-13 10:28:14 -07:00
|
|
|
[TD_BSPC - TD_MIN] = { KC_BACKSPACE, LCTL(KC_BACKSPACE) },
|
2019-07-25 11:56:29 -07:00
|
|
|
[TD_DEL - TD_MIN] = { KC_DELETE, LCTL(KC_DELETE) }
|
2019-06-01 14:39:31 -07:00
|
|
|
};
|
|
|
|
|
2019-07-25 11:56:29 -07:00
|
|
|
static void run_custom_tap_dance(uint8_t i)
|
2019-06-01 14:39:31 -07:00
|
|
|
{
|
|
|
|
tap_code16(pgm_read_word(&td_keymaps[td_keycode - TD_MIN][i]));
|
|
|
|
td_keycode = KC_TRANSPARENT;
|
|
|
|
td_timer = timer_read() + TAPPING_TERM;
|
|
|
|
}
|
|
|
|
|
2019-07-25 11:56:29 -07:00
|
|
|
bool process_custom_tap_dance(uint16_t keycode, keyrecord_t *record)
|
2019-06-01 14:39:31 -07:00
|
|
|
{
|
|
|
|
if (TD_MIN <= keycode && keycode < TD_MAX)
|
|
|
|
{
|
|
|
|
if (record->event.pressed)
|
|
|
|
{
|
|
|
|
if (td_keycode != keycode || timer_expired(td_timer))
|
|
|
|
{
|
|
|
|
td_keycode = keycode;
|
|
|
|
td_timer = timer_read() + TAPPING_TERM;
|
|
|
|
}
|
|
|
|
else
|
2019-07-25 11:56:29 -07:00
|
|
|
run_custom_tap_dance(1);
|
2019-06-01 14:39:31 -07:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (td_keycode != KC_TRANSPARENT)
|
2019-07-25 11:56:29 -07:00
|
|
|
run_custom_tap_dance(0);
|
2019-06-01 14:39:31 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void matrix_scan_user(void)
|
|
|
|
{
|
|
|
|
if (td_keycode != KC_TRANSPARENT && timer_expired(td_timer))
|
2019-07-25 11:56:29 -07:00
|
|
|
run_custom_tap_dance(0);
|
2019-06-01 14:39:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|