qmk_settings: wrap TAP_CODE_DELAY and TAP_HOLD_CAPS_DELAY
This commit is contained in:
parent
a284336819
commit
fa26d6e1bc
@ -110,9 +110,7 @@ if (QS_auto_shift_repeat && !QS_auto_shift_no_auto_repeat) {
|
||||
}
|
||||
}
|
||||
|
||||
# if TAP_CODE_DELAY > 0
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
# endif
|
||||
wait_ms(QS_tap_code_delay);
|
||||
unregister_code(autoshift_lastkey);
|
||||
del_weak_mods(MOD_BIT(KC_LSFT));
|
||||
} else {
|
||||
|
@ -48,6 +48,8 @@ static const qmk_settings_proto_t protos[] PROGMEM = {
|
||||
DECLARE_SETTING_CB(15, mousekey_wheel_interval, mousekey_apply),
|
||||
DECLARE_SETTING_CB(16, mousekey_wheel_max_speed, mousekey_apply),
|
||||
DECLARE_SETTING_CB(17, mousekey_wheel_time_to_max, mousekey_apply),
|
||||
DECLARE_SETTING(18, tap_code_delay),
|
||||
DECLARE_SETTING(19, tap_hold_caps_delay),
|
||||
};
|
||||
|
||||
static const qmk_settings_proto_t *find_setting(uint16_t qsid) {
|
||||
@ -106,6 +108,8 @@ void qmk_settings_reset(void) {
|
||||
QS.combo_term = COMBO_TERM;
|
||||
QS.tapping_term = TAPPING_TERM;
|
||||
QS.tapping = 0;
|
||||
QS.tap_code_delay = TAP_CODE_DELAY;
|
||||
QS.tap_hold_caps_delay = TAP_HOLD_CAPS_DELAY;
|
||||
|
||||
save_settings();
|
||||
/* to trigger all callbacks */
|
||||
|
@ -5,6 +5,13 @@
|
||||
|
||||
/* take qmk config macros and set up helper variables for default settings */
|
||||
|
||||
#ifndef TAP_CODE_DELAY
|
||||
# define TAP_CODE_DELAY 0
|
||||
#endif
|
||||
#ifndef TAP_HOLD_CAPS_DELAY
|
||||
# define TAP_HOLD_CAPS_DELAY 80
|
||||
#endif
|
||||
|
||||
/* ========================================================================== */
|
||||
/* Grave escape */
|
||||
/* ========================================================================== */
|
||||
@ -111,8 +118,10 @@ typedef struct {
|
||||
uint8_t auto_shift;
|
||||
uint8_t osk_tap_toggle;
|
||||
uint8_t tapping;
|
||||
uint16_t tap_code_delay;
|
||||
uint16_t tap_hold_caps_delay;
|
||||
} qmk_settings_t;
|
||||
_Static_assert(sizeof(qmk_settings_t) == 30, "unexpected size of the qmk_settings_t structure");
|
||||
_Static_assert(sizeof(qmk_settings_t) == 34, "unexpected size of the qmk_settings_t structure");
|
||||
|
||||
typedef void (*qmk_setting_callback_t)(void);
|
||||
|
||||
@ -157,6 +166,10 @@ extern qmk_settings_t QS;
|
||||
/* Combo */
|
||||
#define QS_combo_term (QS.combo_term)
|
||||
|
||||
/* Tap delays */
|
||||
#define QS_tap_code_delay (QS.tap_code_delay)
|
||||
#define QS_tap_hold_caps_delay (QS.tap_hold_caps_delay)
|
||||
|
||||
#else
|
||||
/* dynamic settings framework is disabled => hardcode the settings and let the compiler optimize extra branches out */
|
||||
|
||||
@ -185,4 +198,8 @@ extern qmk_settings_t QS;
|
||||
/* Combo */
|
||||
#define QS_combo_term COMBO_TERM
|
||||
|
||||
/* Tap delays */
|
||||
#define QS_tap_code_delay TAP_CODE_DELAY
|
||||
#define QS_tap_hold_caps_delay TAP_HOLD_CAPS_DELAY
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "quantum.h"
|
||||
#include "magic.h"
|
||||
#include "qmk_settings.h"
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
# include "outputselect.h"
|
||||
@ -107,9 +108,7 @@ void unregister_code16(uint16_t code) {
|
||||
|
||||
void tap_code16(uint16_t code) {
|
||||
register_code16(code);
|
||||
#if TAP_CODE_DELAY > 0
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
#endif
|
||||
wait_ms(QS_tap_code_delay);
|
||||
unregister_code16(code);
|
||||
}
|
||||
|
||||
|
@ -286,11 +286,7 @@ static void vial_keycode_tap(uint16_t keycode) __attribute__((unused));
|
||||
|
||||
static void vial_keycode_tap(uint16_t keycode) {
|
||||
vial_keycode_down(keycode);
|
||||
|
||||
#if TAP_CODE_DELAY > 0
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
#endif
|
||||
|
||||
wait_ms(QS_tap_code_delay);
|
||||
vial_keycode_up(keycode);
|
||||
}
|
||||
|
||||
@ -429,6 +425,7 @@ static void on_dance_reset(qk_tap_dance_state_t *state, void *user_data) {
|
||||
uint8_t index = (uintptr_t)user_data;
|
||||
if (dynamic_keymap_get_tap_dance(index, &td_entry) != 0)
|
||||
return;
|
||||
wait_ms(QS_tap_code_delay);
|
||||
uint8_t st = dance_state[index];
|
||||
state->count = 0;
|
||||
dance_state[index] = 0;
|
||||
|
@ -56,12 +56,6 @@ __attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrec
|
||||
__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; }
|
||||
#endif
|
||||
|
||||
#ifndef TAP_CODE_DELAY
|
||||
# define TAP_CODE_DELAY 0
|
||||
#endif
|
||||
#ifndef TAP_HOLD_CAPS_DELAY
|
||||
# define TAP_HOLD_CAPS_DELAY 80
|
||||
#endif
|
||||
/** \brief Called to execute an action.
|
||||
*
|
||||
* FIXME: Needs documentation.
|
||||
@ -370,9 +364,9 @@ if (QS_oneshot_tap_toggle > 1) {
|
||||
if (tap_count > 0) {
|
||||
dprint("MODS_TAP: Tap: unregister_code\n");
|
||||
if (action.layer_tap.code == KC_CAPS) {
|
||||
wait_ms(TAP_HOLD_CAPS_DELAY);
|
||||
wait_ms(QS_tap_hold_caps_delay);
|
||||
} else {
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
wait_ms(QS_tap_code_delay);
|
||||
}
|
||||
unregister_code(action.key.code);
|
||||
} else {
|
||||
@ -595,9 +589,9 @@ if (QS_oneshot_tap_toggle > 1) {
|
||||
if (tap_count > 0) {
|
||||
dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
|
||||
if (action.layer_tap.code == KC_CAPS) {
|
||||
wait_ms(TAP_HOLD_CAPS_DELAY);
|
||||
wait_ms(QS_tap_hold_caps_delay);
|
||||
} else {
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
wait_ms(QS_tap_code_delay);
|
||||
}
|
||||
unregister_code(action.layer_tap.code);
|
||||
} else {
|
||||
@ -676,7 +670,7 @@ if (QS_oneshot_tap_toggle > 1) {
|
||||
if (event.pressed) {
|
||||
register_code(action.swap.code);
|
||||
} else {
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
wait_ms(QS_tap_code_delay);
|
||||
unregister_code(action.swap.code);
|
||||
*record = (keyrecord_t){}; // hack: reset tap mode
|
||||
}
|
||||
@ -932,7 +926,7 @@ void tap_code_delay(uint8_t code, uint16_t delay) {
|
||||
*
|
||||
* \param code The basic keycode to tap. If `code` is `KC_CAPS`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
|
||||
*/
|
||||
void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); }
|
||||
void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS ? QS_tap_hold_caps_delay : QS_tap_code_delay); }
|
||||
|
||||
/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user