qmk_settings: wrap TAPPING_TOGGLE

This commit is contained in:
Ilya Zhuravlev 2022-04-02 16:39:12 -06:00
parent 67e10a43cb
commit e1fbf6f13d
4 changed files with 18 additions and 7 deletions

View File

@ -392,11 +392,11 @@ if (QS_oneshot_tap_toggle > 1) {
# endif
case MODS_TAP_TOGGLE:
if (event.pressed) {
if (tap_count <= TAPPING_TOGGLE) {
if (tap_count <= QS_tapping_toggle) {
register_mods(mods);
}
} else {
if (tap_count < TAPPING_TOGGLE) {
if (tap_count < QS_tapping_toggle) {
unregister_mods(mods);
}
}
@ -549,11 +549,11 @@ if (QS_oneshot_tap_toggle > 1) {
case OP_TAP_TOGGLE:
/* tap toggle */
if (event.pressed) {
if (tap_count < TAPPING_TOGGLE) {
if (tap_count < QS_tapping_toggle) {
layer_invert(action.layer_tap.val);
}
} else {
if (tap_count <= TAPPING_TOGGLE) {
if (tap_count <= QS_tapping_toggle) {
layer_invert(action.layer_tap.val);
}
}
@ -688,7 +688,7 @@ if (QS_oneshot_tap_toggle > 1) {
swap_hands = !swap_hands;
}
} else {
if (tap_count < TAPPING_TOGGLE) {
if (tap_count < QS_tapping_toggle) {
swap_hands = !swap_hands;
}
}

View File

@ -18,6 +18,7 @@
#include "quantum_keycodes.h"
#include "action_tapping.h"
#include "usb_device_state.h"
#include "qmk_settings.h"
__attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
@ -26,7 +27,7 @@ __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t
if (record->tap.count == 0) return false;
break;
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
if (record->tap.count != TAPPING_TOGGLE) return false;
if (record->tap.count != QS_tapping_toggle) return false;
break;
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
if (record->tap.count == 0) return false;

View File

@ -54,6 +54,7 @@ static const qmk_settings_proto_t protos[] PROGMEM = {
#endif
DECLARE_SETTING(18, tap_code_delay),
DECLARE_SETTING(19, tap_hold_caps_delay),
DECLARE_SETTING(20, tapping_toggle),
};
static const qmk_settings_proto_t *find_setting(uint16_t qsid) {
@ -116,6 +117,7 @@ void qmk_settings_reset(void) {
QS.tapping = 0;
QS.tap_code_delay = TAP_CODE_DELAY;
QS.tap_hold_caps_delay = TAP_HOLD_CAPS_DELAY;
QS.tapping_toggle = TAPPING_TOGGLE;
save_settings();
/* to trigger all callbacks */

View File

@ -120,8 +120,10 @@ typedef struct {
uint8_t tapping;
uint16_t tap_code_delay;
uint16_t tap_hold_caps_delay;
uint8_t tapping_toggle;
uint8_t unused;
} qmk_settings_t;
_Static_assert(sizeof(qmk_settings_t) == 34, "unexpected size of the qmk_settings_t structure");
_Static_assert(sizeof(qmk_settings_t) == 36, "unexpected size of the qmk_settings_t structure");
typedef void (*qmk_setting_callback_t)(void);
@ -170,6 +172,9 @@ extern qmk_settings_t QS;
#define QS_tap_code_delay (QS.tap_code_delay)
#define QS_tap_hold_caps_delay (QS.tap_hold_caps_delay)
/* Tapping Toggle */
#define QS_tapping_toggle (QS.tapping_toggle)
#else
/* dynamic settings framework is disabled => hardcode the settings and let the compiler optimize extra branches out */
@ -202,6 +207,9 @@ extern qmk_settings_t QS;
#define QS_tap_code_delay TAP_CODE_DELAY
#define QS_tap_hold_caps_delay TAP_HOLD_CAPS_DELAY
/* Tapping Toggle */
#define QS_tapping_toggle TAPPING_TOGGLE
#endif
#if defined(__AVR__) && defined(QMK_SETTINGS)