qmk_settings: fix variable delays on avr

This commit is contained in:
Ilya Zhuravlev 2021-07-11 23:41:53 -04:00
parent e165e8c94a
commit 14c7ba62b0
5 changed files with 18 additions and 9 deletions

View File

@ -110,7 +110,7 @@ if (QS_auto_shift_repeat && !QS_auto_shift_no_auto_repeat) {
}
}
wait_ms(QS_tap_code_delay);
qs_wait_ms(QS_tap_code_delay);
unregister_code(autoshift_lastkey);
del_weak_mods(MOD_BIT(KC_LSFT));
} else {

View File

@ -203,3 +203,12 @@ extern qmk_settings_t QS;
#define QS_tap_hold_caps_delay TAP_HOLD_CAPS_DELAY
#endif
#if defined(__AVR__) && defined(QMK_SETTINGS)
#include <util/delay.h>
static inline void qs_wait_ms(uint16_t timer) {
while (timer--) _delay_ms(1);
}
#else
#define qs_wait_ms wait_ms
#endif

View File

@ -108,7 +108,7 @@ void unregister_code16(uint16_t code) {
void tap_code16(uint16_t code) {
register_code16(code);
wait_ms(QS_tap_code_delay);
qs_wait_ms(QS_tap_code_delay);
unregister_code16(code);
}

View File

@ -286,7 +286,7 @@ static void vial_keycode_tap(uint16_t keycode) __attribute__((unused));
static void vial_keycode_tap(uint16_t keycode) {
vial_keycode_down(keycode);
wait_ms(QS_tap_code_delay);
qs_wait_ms(QS_tap_code_delay);
vial_keycode_up(keycode);
}
@ -425,7 +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);
qs_wait_ms(QS_tap_code_delay);
uint8_t st = dance_state[index];
state->count = 0;
dance_state[index] = 0;

View File

@ -364,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(QS_tap_hold_caps_delay);
qs_wait_ms(QS_tap_hold_caps_delay);
} else {
wait_ms(QS_tap_code_delay);
qs_wait_ms(QS_tap_code_delay);
}
unregister_code(action.key.code);
} else {
@ -589,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(QS_tap_hold_caps_delay);
qs_wait_ms(QS_tap_hold_caps_delay);
} else {
wait_ms(QS_tap_code_delay);
qs_wait_ms(QS_tap_code_delay);
}
unregister_code(action.layer_tap.code);
} else {
@ -670,7 +670,7 @@ if (QS_oneshot_tap_toggle > 1) {
if (event.pressed) {
register_code(action.swap.code);
} else {
wait_ms(QS_tap_code_delay);
qs_wait_ms(QS_tap_code_delay);
unregister_code(action.swap.code);
*record = (keyrecord_t){}; // hack: reset tap mode
}