Skip to content

Commit

Permalink
Make qmk_settings respect AUTO_SHIFT definitions.
Browse files Browse the repository at this point in the history
Previously when `qmk_settings_reset()` was called, it would always
reset `auto_shift` to 0 (i.e. totally disabled). With this change,
all defined AUTO_SHIFT config macros will instead be used as the
default value.
  • Loading branch information
riannucci committed Aug 18, 2022
1 parent a05537e commit 1b404e6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
25 changes: 24 additions & 1 deletion quantum/qmk_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,30 @@ void qmk_settings_init(void) {

void qmk_settings_reset(void) {
QS.grave_esc_override = 0;
QS.auto_shift = 0;
QS.auto_shift = (
0
#ifdef AUTO_SHIFT_ENABLE
| _QS_auto_shift_enable_bit
#endif
#ifdef AUTO_SHIFT_MODIFIERS
| _QS_auto_shift_modifiers_bit
#endif
#ifdef NO_AUTO_SHIFT_SPECIAL
| _QS_auto_shift_no_auto_shift_special_bit
#endif
#ifdef NO_AUTO_SHIFT_NUMERIC
| _QS_auto_shift_no_auto_shift_numeric_bit
#endif
#ifdef NO_AUTO_SHIFT_ALPHA
| _QS_auto_shift_no_auto_shift_alpha_bit
#endif
#ifdef AUTO_SHIFT_REPEAT
| _QS_auto_shift_repeat_bit
#endif
#ifdef AUTO_SHIFT_NO_AUTO_REPEAT
| _QS_auto_shift_no_auto_repeat_bit
#endif
);
QS.auto_shift_timeout = AUTO_SHIFT_TIMEOUT;
QS.osk_tap_toggle = ONESHOT_TAP_TOGGLE;
QS.osk_timeout = ONESHOT_TIMEOUT;
Expand Down
22 changes: 15 additions & 7 deletions quantum/qmk_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,21 @@ extern qmk_settings_t QS;
#define QS_grave_esc_shift_override (QS.grave_esc_override & 8)

/* Auto shift */
#define QS_auto_shift_enable (QS.auto_shift & 1)
#define QS_auto_shift_modifiers (QS.auto_shift & 2)
#define QS_auto_shift_no_auto_shift_special (QS.auto_shift & 4)
#define QS_auto_shift_no_auto_shift_numeric (QS.auto_shift & 8)
#define QS_auto_shift_no_auto_shift_alpha (QS.auto_shift & 16)
#define QS_auto_shift_repeat (QS.auto_shift & 32)
#define QS_auto_shift_no_auto_repeat (QS.auto_shift & 64)
#define _QS_auto_shift_enable_bit 1
#define _QS_auto_shift_modifiers_bit 2
#define _QS_auto_shift_no_auto_shift_special_bit 4
#define _QS_auto_shift_no_auto_shift_numeric_bit 8
#define _QS_auto_shift_no_auto_shift_alpha_bit 16
#define _QS_auto_shift_repeat_bit 32
#define _QS_auto_shift_no_auto_repeat_bit 64

#define QS_auto_shift_enable (QS.auto_shift & _QS_auto_shift_enable_bit)
#define QS_auto_shift_modifiers (QS.auto_shift & _QS_auto_shift_modifiers_bit)
#define QS_auto_shift_no_auto_shift_special (QS.auto_shift & _QS_auto_shift_no_auto_shift_special_bit)
#define QS_auto_shift_no_auto_shift_numeric (QS.auto_shift & _QS_auto_shift_no_auto_shift_numeric_bit)
#define QS_auto_shift_no_auto_shift_alpha (QS.auto_shift & _QS_auto_shift_no_auto_shift_alpha_bit)
#define QS_auto_shift_repeat (QS.auto_shift & _QS_auto_shift_no_auto_repeat_bit)
#define QS_auto_shift_no_auto_repeat (QS.auto_shift & _QS_auto_shift_no_auto_repeat_bit)

/* One Shot Keys */
#define QS_oneshot_tap_toggle (QS.osk_tap_toggle)
Expand Down

0 comments on commit 1b404e6

Please sign in to comment.