2021-06-30 01:43:11 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stddef.h>
|
2022-09-10 12:10:44 +02:00
|
|
|
#include "quantum/action.h"
|
2021-06-30 01:43:11 +02:00
|
|
|
|
|
|
|
/* take qmk config macros and set up helper variables for default settings */
|
|
|
|
|
2021-07-09 05:02:17 +02:00
|
|
|
#ifndef TAP_CODE_DELAY
|
2021-07-10 04:34:41 +02:00
|
|
|
# define TAP_CODE_DELAY 10
|
2021-07-09 05:02:17 +02:00
|
|
|
#endif
|
|
|
|
#ifndef TAP_HOLD_CAPS_DELAY
|
|
|
|
# define TAP_HOLD_CAPS_DELAY 80
|
|
|
|
#endif
|
|
|
|
|
2021-06-30 01:43:11 +02:00
|
|
|
/* ========================================================================== */
|
|
|
|
/* Grave escape */
|
|
|
|
/* ========================================================================== */
|
|
|
|
#ifdef GRAVE_ESC_ALT_OVERRIDE
|
|
|
|
#define GRAVE_ESC_ALT_OVERRIDE_Defined 1
|
|
|
|
#else
|
|
|
|
#define GRAVE_ESC_ALT_OVERRIDE_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GRAVE_ESC_CTRL_OVERRIDE
|
|
|
|
#define GRAVE_ESC_CTRL_OVERRIDE_Defined 1
|
|
|
|
#else
|
|
|
|
#define GRAVE_ESC_CTRL_OVERRIDE_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GRAVE_ESC_GUI_OVERRIDE
|
|
|
|
#define GRAVE_ESC_GUI_OVERRIDE_Defined 1
|
|
|
|
#else
|
|
|
|
#define GRAVE_ESC_GUI_OVERRIDE_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GRAVE_ESC_SHIFT_OVERRIDE
|
|
|
|
#define GRAVE_ESC_SHIFT_OVERRIDE_Defined 1
|
|
|
|
#else
|
|
|
|
#define GRAVE_ESC_SHIFT_OVERRIDE_Defined 0
|
|
|
|
#endif
|
|
|
|
|
2021-07-01 22:17:15 +02:00
|
|
|
/* ========================================================================== */
|
|
|
|
/* Auto shift */
|
|
|
|
/* ========================================================================== */
|
|
|
|
#ifdef AUTO_SHIFT_ENABLE
|
|
|
|
#define AUTO_SHIFT_ENABLE_Defined 1
|
|
|
|
#else
|
|
|
|
#define AUTO_SHIFT_ENABLE_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUTO_SHIFT_MODIFIERS
|
|
|
|
#define AUTO_SHIFT_MODIFIERS_Defined 1
|
|
|
|
#else
|
|
|
|
#define AUTO_SHIFT_MODIFIERS_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NO_AUTO_SHIFT_SPECIAL
|
|
|
|
#define NO_AUTO_SHIFT_SPECIAL_Defined 1
|
|
|
|
#else
|
|
|
|
#define NO_AUTO_SHIFT_SPECIAL_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NO_AUTO_SHIFT_NUMERIC
|
|
|
|
#define NO_AUTO_SHIFT_NUMERIC_Defined 1
|
|
|
|
#else
|
|
|
|
#define NO_AUTO_SHIFT_NUMERIC_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NO_AUTO_SHIFT_ALPHA
|
|
|
|
#define NO_AUTO_SHIFT_ALPHA_Defined 1
|
|
|
|
#else
|
|
|
|
#define NO_AUTO_SHIFT_ALPHA_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUTO_SHIFT_REPEAT
|
|
|
|
#define AUTO_SHIFT_REPEAT_Defined 1
|
|
|
|
#else
|
|
|
|
#define AUTO_SHIFT_REPEAT_Defined 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUTO_SHIFT_NO_AUTO_REPEAT
|
|
|
|
#define AUTO_SHIFT_NO_AUTO_REPEAT_Defined 1
|
|
|
|
#else
|
|
|
|
#define AUTO_SHIFT_NO_AUTO_REPEAT_Defined 0
|
|
|
|
#endif
|
|
|
|
|
2021-07-05 05:15:06 +02:00
|
|
|
/* ========================================================================== */
|
|
|
|
/* One shot keys */
|
|
|
|
/* ========================================================================== */
|
|
|
|
#ifndef ONESHOT_TAP_TOGGLE
|
|
|
|
#define ONESHOT_TAP_TOGGLE 5
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ONESHOT_TIMEOUT
|
|
|
|
#define ONESHOT_TIMEOUT 5000
|
|
|
|
#endif
|
|
|
|
|
2021-06-30 01:43:11 +02:00
|
|
|
#ifdef QMK_SETTINGS
|
|
|
|
/* dynamic settings framework is enabled */
|
|
|
|
|
2021-07-01 05:42:40 +02:00
|
|
|
/* actual settings - stored in RAM and backed by EEPROM
|
|
|
|
these are in arbitrary order to ensure they are aligned w/o any holes, and the order can be changed at will */
|
2021-06-30 01:43:11 +02:00
|
|
|
typedef struct {
|
2021-07-01 05:42:40 +02:00
|
|
|
uint16_t auto_shift_timeout;
|
|
|
|
uint16_t osk_timeout;
|
2021-07-02 02:43:35 +02:00
|
|
|
uint16_t mousekey_delay;
|
|
|
|
uint16_t mousekey_interval;
|
|
|
|
uint16_t mousekey_move_delta;
|
|
|
|
uint16_t mousekey_max_speed;
|
|
|
|
uint16_t mousekey_time_to_max;
|
|
|
|
uint16_t mousekey_wheel_delay;
|
|
|
|
uint16_t mousekey_wheel_interval;
|
|
|
|
uint16_t mousekey_wheel_max_speed;
|
|
|
|
uint16_t mousekey_wheel_time_to_max;
|
2021-07-05 01:04:46 +02:00
|
|
|
uint16_t combo_term;
|
2021-07-09 00:12:13 +02:00
|
|
|
uint16_t tapping_term;
|
2021-07-02 02:47:26 +02:00
|
|
|
uint8_t grave_esc_override;
|
|
|
|
uint8_t auto_shift;
|
|
|
|
uint8_t osk_tap_toggle;
|
2021-07-09 00:12:13 +02:00
|
|
|
uint8_t tapping;
|
2021-07-09 05:02:17 +02:00
|
|
|
uint16_t tap_code_delay;
|
|
|
|
uint16_t tap_hold_caps_delay;
|
2022-04-03 00:39:12 +02:00
|
|
|
uint8_t tapping_toggle;
|
|
|
|
uint8_t unused;
|
2021-06-30 01:43:11 +02:00
|
|
|
} qmk_settings_t;
|
2022-04-03 00:39:12 +02:00
|
|
|
_Static_assert(sizeof(qmk_settings_t) == 36, "unexpected size of the qmk_settings_t structure");
|
2021-06-30 01:43:11 +02:00
|
|
|
|
2022-04-20 08:33:08 +02:00
|
|
|
struct qmk_settings_proto_t;
|
2021-07-01 22:17:15 +02:00
|
|
|
|
2022-04-20 08:33:08 +02:00
|
|
|
typedef void (*qmk_settings_notify_t)(void);
|
|
|
|
typedef int (*qmk_settings_get_t)(const struct qmk_settings_proto_t *proto, void *setting, size_t maxsz);
|
|
|
|
typedef int (*qmk_settings_set_t)(const struct qmk_settings_proto_t *proto, const void *setting, size_t maxsz);
|
|
|
|
|
|
|
|
/* setting prototype - describes how to get/set settings; this structure is stored in flash */
|
|
|
|
typedef struct qmk_settings_proto_t {
|
2021-06-30 01:43:11 +02:00
|
|
|
uint16_t qsid;
|
|
|
|
uint16_t sz;
|
|
|
|
void *ptr;
|
2022-04-20 08:33:08 +02:00
|
|
|
qmk_settings_get_t get;
|
|
|
|
qmk_settings_set_t set;
|
|
|
|
qmk_settings_notify_t notify;
|
2021-06-30 01:43:11 +02:00
|
|
|
} qmk_settings_proto_t;
|
|
|
|
|
2021-07-01 20:33:37 +02:00
|
|
|
void qmk_settings_init(void);
|
|
|
|
void qmk_settings_reset(void);
|
2021-07-01 21:10:05 +02:00
|
|
|
void qmk_settings_query(uint16_t qsid_gt, void *buffer, size_t sz);
|
2021-06-30 01:43:11 +02:00
|
|
|
int qmk_settings_get(uint16_t qsid, void *setting, size_t maxsz);
|
|
|
|
int qmk_settings_set(uint16_t qsid, const void *setting, size_t maxsz);
|
|
|
|
|
2022-09-10 12:10:44 +02:00
|
|
|
uint16_t qs_get_tapping_term(uint16_t keycode, keyrecord_t *record);
|
|
|
|
|
2021-06-30 01:43:11 +02:00
|
|
|
extern qmk_settings_t QS;
|
|
|
|
|
|
|
|
/* Grave escape */
|
|
|
|
#define QS_grave_esc_alt_override (QS.grave_esc_override & 1)
|
|
|
|
#define QS_grave_esc_ctrl_override (QS.grave_esc_override & 2)
|
|
|
|
#define QS_grave_esc_gui_override (QS.grave_esc_override & 4)
|
|
|
|
#define QS_grave_esc_shift_override (QS.grave_esc_override & 8)
|
|
|
|
|
2021-07-01 22:17:15 +02:00
|
|
|
/* 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)
|
|
|
|
|
2021-07-02 02:13:00 +02:00
|
|
|
/* One Shot Keys */
|
|
|
|
#define QS_oneshot_tap_toggle (QS.osk_tap_toggle)
|
|
|
|
#define QS_oneshot_timeout (QS.osk_timeout)
|
|
|
|
|
2021-07-02 02:43:35 +02:00
|
|
|
/* Mouse keys */
|
|
|
|
#define QS_mousekey_move_delta (QS.mousekey_move_delta)
|
|
|
|
|
2021-07-05 01:04:46 +02:00
|
|
|
/* Combo */
|
|
|
|
#define QS_combo_term (QS.combo_term)
|
|
|
|
|
2021-07-09 05:02:17 +02:00
|
|
|
/* Tap delays */
|
|
|
|
#define QS_tap_code_delay (QS.tap_code_delay)
|
|
|
|
#define QS_tap_hold_caps_delay (QS.tap_hold_caps_delay)
|
|
|
|
|
2022-04-03 00:39:12 +02:00
|
|
|
/* Tapping Toggle */
|
|
|
|
#define QS_tapping_toggle (QS.tapping_toggle)
|
|
|
|
|
2021-06-30 01:43:11 +02:00
|
|
|
#else
|
|
|
|
/* dynamic settings framework is disabled => hardcode the settings and let the compiler optimize extra branches out */
|
|
|
|
|
|
|
|
/* Grave escape */
|
|
|
|
#define QS_grave_esc_alt_override GRAVE_ESC_ALT_OVERRIDE_Defined
|
|
|
|
#define QS_grave_esc_ctrl_override GRAVE_ESC_CTRL_OVERRIDE_Defined
|
|
|
|
#define QS_grave_esc_gui_override GRAVE_ESC_GUI_OVERRIDE_Defined
|
|
|
|
#define QS_grave_esc_shift_override GRAVE_ESC_SHIFT_OVERRIDE_Defined
|
|
|
|
|
2021-07-01 22:17:15 +02:00
|
|
|
/* Auto shift */
|
|
|
|
#define QS_auto_shift_enable AUTO_SHIFT_ENABLE_Defined
|
|
|
|
#define QS_auto_shift_modifiers AUTO_SHIFT_MODIFIERS_Defined
|
|
|
|
#define QS_auto_shift_no_auto_shift_special NO_AUTO_SHIFT_SPECIAL_Defined
|
|
|
|
#define QS_auto_shift_no_auto_shift_numeric NO_AUTO_SHIFT_NUMERIC_Defined
|
|
|
|
#define QS_auto_shift_no_auto_shift_alpha NO_AUTO_SHIFT_ALPHA_Defined
|
|
|
|
#define QS_auto_shift_repeat AUTO_SHIFT_REPEAT_Defined
|
|
|
|
#define QS_auto_shift_no_auto_repeat AUTO_SHIFT_NO_AUTO_REPEAT_Defined
|
|
|
|
|
2021-07-02 02:13:00 +02:00
|
|
|
/* One Shot Keys */
|
|
|
|
#define QS_oneshot_tap_toggle ONESHOT_TAP_TOGGLE
|
|
|
|
#define QS_oneshot_timeout ONESHOT_TIMEOUT
|
|
|
|
|
2021-07-02 02:43:35 +02:00
|
|
|
/* Mouse keys */
|
|
|
|
#define QS_mousekey_move_delta MOUSEKEY_MOVE_DELTA
|
|
|
|
|
2021-07-05 01:04:46 +02:00
|
|
|
/* Combo */
|
|
|
|
#define QS_combo_term COMBO_TERM
|
|
|
|
|
2021-07-09 05:02:17 +02:00
|
|
|
/* Tap delays */
|
|
|
|
#define QS_tap_code_delay TAP_CODE_DELAY
|
|
|
|
#define QS_tap_hold_caps_delay TAP_HOLD_CAPS_DELAY
|
|
|
|
|
2022-04-03 00:39:12 +02:00
|
|
|
/* Tapping Toggle */
|
|
|
|
#define QS_tapping_toggle TAPPING_TOGGLE
|
|
|
|
|
2021-07-01 22:17:15 +02:00
|
|
|
#endif
|
2021-07-12 05:41:53 +02:00
|
|
|
|
|
|
|
#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
|