summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c123
-rw-r--r--quantum/action.h14
-rw-r--r--quantum/action_layer.c22
-rw-r--r--quantum/action_tapping.c266
-rw-r--r--quantum/action_tapping.h13
-rw-r--r--quantum/keyboard.h7
-rw-r--r--quantum/keymap_extras/keymap_uk.h96
-rw-r--r--quantum/keymap_extras/keymap_us.h75
-rw-r--r--quantum/led.c10
-rw-r--r--quantum/led.h5
-rw-r--r--quantum/logging/nodebug.h26
-rw-r--r--quantum/main.c6
-rw-r--r--quantum/matrix.c10
-rw-r--r--quantum/os_detection.c129
-rw-r--r--quantum/os_detection.h38
-rw-r--r--quantum/os_detection/tests/os_detection.cpp164
-rw-r--r--quantum/os_detection/tests/rules.mk5
-rw-r--r--quantum/os_detection/tests/testlist.mk1
-rw-r--r--quantum/painter/lvgl/qp_lvgl.c144
-rw-r--r--quantum/painter/lvgl/qp_lvgl.h25
-rw-r--r--quantum/painter/lvgl/rules.mk24
-rw-r--r--quantum/painter/qp.h7
-rw-r--r--quantum/painter/qp_draw_image.c12
-rw-r--r--quantum/painter/rules.mk6
-rw-r--r--quantum/process_keycode/process_auto_shift.c41
-rw-r--r--quantum/process_keycode/process_auto_shift.h5
-rw-r--r--quantum/process_keycode/process_leader.c42
-rw-r--r--quantum/process_keycode/process_leader.h4
-rw-r--r--quantum/process_keycode/process_tap_dance.c44
-rw-r--r--quantum/process_keycode/process_tap_dance.h42
-rw-r--r--quantum/process_keycode/process_ucis.c52
-rw-r--r--quantum/process_keycode/process_ucis.h16
-rw-r--r--quantum/rgblight/rgblight.h17
33 files changed, 967 insertions, 524 deletions
diff --git a/quantum/action.c b/quantum/action.c
index abf9834d2f..f6fbb999c8 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -16,12 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <limits.h>
-#ifdef DEBUG_ACTION
-# include "debug.h"
-#else
-# include "nodebug.h"
-#endif
-
#include "host.h"
#include "keycode.h"
#include "keyboard.h"
@@ -55,8 +49,8 @@ int retro_tapping_counter = 0;
# include "process_auto_shift.h"
#endif
-#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
-__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
+#ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
return false;
}
#endif
@@ -76,11 +70,11 @@ __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) {
* FIXME: Needs documentation.
*/
void action_exec(keyevent_t event) {
- if (!IS_NOEVENT(event)) {
- dprint("\n---- action_exec: start -----\n");
- dprint("EVENT: ");
+ if (IS_EVENT(event)) {
+ ac_dprintf("\n---- action_exec: start -----\n");
+ ac_dprintf("EVENT: ");
debug_event(event);
- dprintln();
+ ac_dprintf("\n");
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
retro_tapping_counter++;
#endif
@@ -93,7 +87,7 @@ void action_exec(keyevent_t event) {
#ifdef SWAP_HANDS_ENABLE
// Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined.
- if (!IS_NOEVENT(event)) {
+ if (IS_EVENT(event)) {
process_hand_swap(&event);
}
#endif
@@ -131,8 +125,8 @@ void action_exec(keyevent_t event) {
if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
process_record(&record);
}
- if (!IS_NOEVENT(record.event)) {
- dprint("processed: ");
+ if (IS_EVENT(record.event)) {
+ ac_dprintf("processed: ");
debug_record(record);
dprintln();
}
@@ -280,15 +274,15 @@ void process_record_handler(keyrecord_t *record) {
#else
action_t action = store_or_get_action(record->event.pressed, record->event.key);
#endif
- dprint("ACTION: ");
+ ac_dprintf("ACTION: ");
debug_action(action);
#ifndef NO_ACTION_LAYER
- dprint(" layer_state: ");
+ ac_dprintf(" layer_state: ");
layer_debug();
- dprint(" default_layer_state: ");
+ ac_dprintf(" default_layer_state: ");
default_layer_debug();
#endif
- dprintln();
+ ac_dprintf("\n");
process_action(record, action);
}
@@ -432,14 +426,14 @@ void process_action(keyrecord_t *record, action_t action) {
} else {
if (event.pressed) {
if (tap_count == 0) {
- dprint("MODS_TAP: Oneshot: 0\n");
+ ac_dprintf("MODS_TAP: Oneshot: 0\n");
register_mods(mods | get_oneshot_mods());
} else if (tap_count == 1) {
- dprint("MODS_TAP: Oneshot: start\n");
+ ac_dprintf("MODS_TAP: Oneshot: start\n");
set_oneshot_mods(mods | get_oneshot_mods());
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
- dprint("MODS_TAP: Toggling oneshot");
+ ac_dprintf("MODS_TAP: Toggling oneshot");
register_mods(mods);
clear_oneshot_mods();
set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
@@ -484,29 +478,29 @@ void process_action(keyrecord_t *record, action_t action) {
default:
if (event.pressed) {
if (tap_count > 0) {
-# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
+# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
if (
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- !get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false), record) &&
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+ get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
# endif
record->tap.interrupted) {
- dprint("mods_tap: tap: cancel: add_mods\n");
+ ac_dprintf("mods_tap: tap: cancel: add_mods\n");
// ad hoc: set 0 to cancel tap
record->tap.count = 0;
register_mods(mods);
} else
# endif
{
- dprint("MODS_TAP: Tap: register_code\n");
+ ac_dprintf("MODS_TAP: Tap: register_code\n");
register_code(action.key.code);
}
} else {
- dprint("MODS_TAP: No tap: add_mods\n");
+ ac_dprintf("MODS_TAP: No tap: add_mods\n");
register_mods(mods);
}
} else {
if (tap_count > 0) {
- dprint("MODS_TAP: Tap: unregister_code\n");
+ ac_dprintf("MODS_TAP: Tap: unregister_code\n");
if (action.layer_tap.code == KC_CAPS_LOCK) {
wait_ms(TAP_HOLD_CAPS_DELAY);
} else {
@@ -514,7 +508,7 @@ void process_action(keyrecord_t *record, action_t action) {
}
unregister_code(action.key.code);
} else {
- dprint("MODS_TAP: No tap: add_mods\n");
+ ac_dprintf("MODS_TAP: No tap: add_mods\n");
unregister_mods(mods);
}
}
@@ -666,15 +660,15 @@ void process_action(keyrecord_t *record, action_t action) {
/* tap key */
if (event.pressed) {
if (tap_count > 0) {
- dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
+ ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n");
register_code(action.layer_tap.code);
} else {
- dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
+ ac_dprintf("KEYMAP_TAP_KEY: No tap: On on press\n");
layer_on(action.layer_tap.val);
}
} else {
if (tap_count > 0) {
- dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
+ ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n");
if (action.layer_tap.code == KC_CAPS_LOCK) {
wait_ms(TAP_HOLD_CAPS_DELAY);
} else {
@@ -682,7 +676,7 @@ void process_action(keyrecord_t *record, action_t action) {
}
unregister_code(action.layer_tap.code);
} else {
- dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
+ ac_dprintf("KEYMAP_TAP_KEY: No tap: Off on release\n");
layer_off(action.layer_tap.val);
}
}
@@ -882,32 +876,15 @@ __attribute__((weak)) void register_code(uint8_t code) {
// TODO: should push command_proc out of this block?
if (command_proc(code)) return;
-#ifndef NO_ACTION_ONESHOT
-/* TODO: remove
- if (oneshot_state.mods && !oneshot_state.disabled) {
- uint8_t tmp_mods = get_mods();
- add_mods(oneshot_state.mods);
-
- add_key(code);
- send_keyboard_report();
-
- set_mods(tmp_mods);
- send_keyboard_report();
- oneshot_cancel();
- } else
-*/
-#endif
- {
- // Force a new key press if the key is already pressed
- // without this, keys with the same keycode, but different
- // modifiers will be reported incorrectly, see issue #1708
- if (is_key_pressed(keyboard_report, code)) {
- del_key(code);
- send_keyboard_report();
- }
- add_key(code);
+ // Force a new key press if the key is already pressed
+ // without this, keys with the same keycode, but different
+ // modifiers will be reported incorrectly, see issue #1708
+ if (is_key_pressed(keyboard_report, code)) {
+ del_key(code);
send_keyboard_report();
}
+ add_key(code);
+ send_keyboard_report();
} else if IS_MOD (code) {
add_mods(MOD_BIT(code));
send_keyboard_report();
@@ -1139,7 +1116,7 @@ bool is_tap_action(action_t action) {
* FIXME: Needs documentation.
*/
void debug_event(keyevent_t event) {
- dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
+ ac_dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
}
/** \brief Debug print (FIXME: Needs better description)
*
@@ -1148,7 +1125,7 @@ void debug_event(keyevent_t event) {
void debug_record(keyrecord_t record) {
debug_event(record.event);
#ifndef NO_ACTION_TAPPING
- dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
+ ac_dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
#endif
}
@@ -1159,41 +1136,41 @@ void debug_record(keyrecord_t record) {
void debug_action(action_t action) {
switch (action.kind.id) {
case ACT_LMODS:
- dprint("ACT_LMODS");
+ ac_dprintf("ACT_LMODS");
break;
case ACT_RMODS:
- dprint("ACT_RMODS");
+ ac_dprintf("ACT_RMODS");
break;
case ACT_LMODS_TAP:
- dprint("ACT_LMODS_TAP");
+ ac_dprintf("ACT_LMODS_TAP");
break;
case ACT_RMODS_TAP:
- dprint("ACT_RMODS_TAP");
+ ac_dprintf("ACT_RMODS_TAP");
break;
case ACT_USAGE:
- dprint("ACT_USAGE");
+ ac_dprintf("ACT_USAGE");
break;
case ACT_MOUSEKEY:
- dprint("ACT_MOUSEKEY");
+ ac_dprintf("ACT_MOUSEKEY");
break;
case ACT_LAYER:
- dprint("ACT_LAYER");
+ ac_dprintf("ACT_LAYER");
break;
case ACT_LAYER_MODS:
- dprint("ACT_LAYER_MODS");
+ ac_dprintf("ACT_LAYER_MODS");
break;
case ACT_LAYER_TAP:
- dprint("ACT_LAYER_TAP");
+ ac_dprintf("ACT_LAYER_TAP");
break;
case ACT_LAYER_TAP_EXT:
- dprint("ACT_LAYER_TAP_EXT");
+ ac_dprintf("ACT_LAYER_TAP_EXT");
break;
case ACT_SWAP_HANDS:
- dprint("ACT_SWAP_HANDS");
+ ac_dprintf("ACT_SWAP_HANDS");
break;
default:
- dprint("UNKNOWN");
+ ac_dprintf("UNKNOWN");
break;
}
- dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
+ ac_dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
}
diff --git a/quantum/action.h b/quantum/action.h
index 2bc46429b2..e4d28ba947 100644
--- a/quantum/action.h
+++ b/quantum/action.h
@@ -112,7 +112,19 @@ bool is_tap_action(action_t action);
void process_record_tap_hint(keyrecord_t *record);
#endif
-/* debug */
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Helpers
+
+#ifdef ACTION_DEBUG
+# include "debug.h"
+# include "print.h"
+# define ac_dprintf(...) dprintf(__VA_ARGS__)
+#else
+# define ac_dprintf(...) \
+ do { \
+ } while (0)
+#endif
+
void debug_event(keyevent_t event);
void debug_record(keyrecord_t record);
void debug_action(action_t action);
diff --git a/quantum/action_layer.c b/quantum/action_layer.c
index 31cfdfe13a..74e8137920 100644
--- a/quantum/action_layer.c
+++ b/quantum/action_layer.c
@@ -1,12 +1,6 @@
#include <limits.h>
#include <stdint.h>
-#ifdef DEBUG_ACTION
-# include "debug.h"
-#else
-# include "nodebug.h"
-#endif
-
#include "keyboard.h"
#include "keymap.h"
#include "action.h"
@@ -39,12 +33,12 @@ __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t sta
*/
static void default_layer_state_set(layer_state_t state) {
state = default_layer_state_set_kb(state);
- debug("default_layer_state: ");
+ ac_dprintf("default_layer_state: ");
default_layer_debug();
- debug(" to ");
+ ac_dprintf(" to ");
default_layer_state = state;
default_layer_debug();
- debug("\n");
+ ac_dprintf("\n");
#if defined(STRICT_LAYER_RELEASE)
clear_keyboard_but_mods(); // To avoid stuck keys
#elif defined(SEMI_STRICT_LAYER_RELEASE)
@@ -57,7 +51,7 @@ static void default_layer_state_set(layer_state_t state) {
* Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit.
*/
void default_layer_debug(void) {
- dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state));
+ ac_dprintf("%08hX(%u)", default_layer_state, get_highest_layer(default_layer_state));
}
/** \brief Default Layer Set
@@ -119,12 +113,12 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) {
*/
void layer_state_set(layer_state_t state) {
state = layer_state_set_kb(state);
- dprint("layer_state: ");
+ ac_dprintf("layer_state: ");
layer_debug();
- dprint(" to ");
+ ac_dprintf(" to ");
layer_state = state;
layer_debug();
- dprintln();
+ ac_dprintf("\n");
# if defined(STRICT_LAYER_RELEASE)
clear_keyboard_but_mods(); // To avoid stuck keys
# elif defined(SEMI_STRICT_LAYER_RELEASE)
@@ -218,7 +212,7 @@ void layer_xor(layer_state_t state) {
* Print out the hex value of the 32-bit layer state, as well as the value of the highest bit.
*/
void layer_debug(void) {
- dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state));
+ ac_dprintf("%08hX(%u)", layer_state, get_highest_layer(layer_state));
}
#endif
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index df3317ac05..821265d399 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -1,12 +1,6 @@
#include <stdint.h>
#include <stdbool.h>
-#ifdef DEBUG_ACTION
-# include "debug.h"
-#else
-# include "nodebug.h"
-#endif
-
#include "action.h"
#include "action_layer.h"
#include "action_tapping.h"
@@ -15,7 +9,15 @@
#ifndef NO_ACTION_TAPPING
-# define IS_TAPPING() !IS_NOEVENT(tapping_key.event)
+# if defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
+# error "IGNORE_MOD_TAP_INTERRUPT_PER_KEY has been removed; the code needs to be ported to use HOLD_ON_OTHER_KEY_PRESS_PER_KEY instead."
+# elif !defined(IGNORE_MOD_TAP_INTERRUPT)
+# if !defined(PERMISSIVE_HOLD) && !defined(PERMISSIVE_HOLD_PER_KEY) && !defined(HOLD_ON_OTHER_KEY_PRESS) && !defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+# pragma message "The default behavior of mod-taps will change to mimic IGNORE_MOD_TAP_INTERRUPT in the future.\nIf you wish to keep the old default behavior of mod-taps, please use HOLD_ON_OTHER_KEY_PRESS."
+# endif
+# endif
+
+# define IS_TAPPING() IS_EVENT(tapping_key.event)
# define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed)
# define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
# define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
@@ -25,6 +27,7 @@
# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode)
# endif
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < GET_TAPPING_TERM(get_record_keycode(&tapping_key, false), &tapping_key))
+# define WITHIN_QUICK_TAP_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < GET_QUICK_TAP_TERM(get_record_keycode(&tapping_key, false), &tapping_key))
# ifdef DYNAMIC_TAPPING_TERM_ENABLE
uint16_t g_tapping_term = TAPPING_TERM;
@@ -40,9 +43,9 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *r
}
# endif
-# ifdef TAPPING_FORCE_HOLD_PER_KEY
-__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
- return false;
+# ifdef QUICK_TAP_TERM_PER_KEY
+__attribute__((weak)) uint16_t get_quick_tap_term(uint16_t keycode, keyrecord_t *record) {
+ return QUICK_TAP_TERM;
}
# endif
@@ -82,15 +85,15 @@ static void debug_waiting_buffer(void);
*/
void action_tapping_process(keyrecord_t record) {
if (process_tapping(&record)) {
- if (!IS_NOEVENT(record.event)) {
- debug("processed: ");
+ if (IS_EVENT(record.event)) {
+ ac_dprintf("processed: ");
debug_record(record);
- debug("\n");
+ ac_dprintf("\n");
}
} else {
if (!waiting_buffer_enq(record)) {
// clear all in case of overflow.
- debug("OVERFLOW: CLEAR ALL STATES\n");
+ ac_dprintf("OVERFLOW: CLEAR ALL STATES\n");
clear_keyboard();
waiting_buffer_clear();
tapping_key = (keyrecord_t){};
@@ -98,25 +101,73 @@ void action_tapping_process(keyrecord_t record) {
}
// process waiting_buffer
- if (!IS_NOEVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) {
- debug("---- action_exec: process waiting_buffer -----\n");
+ if (IS_EVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) {
+ ac_dprintf("---- action_exec: process waiting_buffer -----\n");
}
for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) {
if (process_tapping(&waiting_buffer[waiting_buffer_tail])) {
- debug("processed: waiting_buffer[");
- debug_dec(waiting_buffer_tail);
- debug("] = ");
+ ac_dprintf("processed: waiting_buffer[%u] =", waiting_buffer_tail);
debug_record(waiting_buffer[waiting_buffer_tail]);
- debug("\n\n");
+ ac_dprintf("\n\n");
} else {
break;
}
}
- if (!IS_NOEVENT(record.event)) {
- debug("\n");
+ if (IS_EVENT(record.event)) {
+ ac_dprintf("\n");
}
}
+/* Some conditionally defined helper macros to keep process_tapping more
+ * readable. The conditional definition of tapping_keycode and all the
+ * conditional uses of it are hidden inside macros named TAP_...
+ */
+# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(QUICK_TAP_TERM_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+# define TAP_DEFINE_KEYCODE uint16_t tapping_keycode = get_record_keycode(&tapping_key, false)
+# else
+# define TAP_DEFINE_KEYCODE
+# endif
+
+# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
+# ifdef RETRO_TAPPING_PER_KEY
+# define TAP_GET_RETRO_TAPPING get_retro_tapping(tapping_keycode, &tapping_key)
+# else
+# define TAP_GET_RETRO_TAPPING true
+# endif
+# define MAYBE_RETRO_SHIFTING(ev) (TAP_GET_RETRO_TAPPING && (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16((ev).time, tapping_key.event.time) < (RETRO_SHIFT + 0))
+# define TAP_IS_LT IS_QK_LAYER_TAP(tapping_keycode)
+# define TAP_IS_MT IS_QK_MOD_TAP(tapping_keycode)
+# define TAP_IS_RETRO IS_RETRO(tapping_keycode)
+# else
+# define TAP_GET_RETRO_TAPPING false
+# define MAYBE_RETRO_SHIFTING(ev) false
+# define TAP_IS_LT false
+# define TAP_IS_MT false
+# define TAP_IS_RETRO false
+# endif
+
+# ifdef PERMISSIVE_HOLD_PER_KEY
+# define TAP_GET_PERMISSIVE_HOLD get_permissive_hold(tapping_keycode, &tapping_key)
+# elif defined(PERMISSIVE_HOLD)
+# define TAP_GET_PERMISSIVE_HOLD true
+# else
+# define TAP_GET_PERMISSIVE_HOLD false
+# endif
+
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS get_hold_on_other_key_press(tapping_keycode, &tapping_key)
+# elif defined(HOLD_ON_OTHER_KEY_PRESS)
+# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS true
+# else
+# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS false
+# endif
+
+# if defined(IGNORE_MOD_TAP_INTERRUPT)
+# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT true
+# else
+# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT false
+# endif
+
/** \brief Tapping
*
* Rule: Tap key is typed(pressed and released) within TAPPING_TERM.
@@ -125,31 +176,18 @@ void action_tapping_process(keyrecord_t record) {
/* return true when key event is processed or consumed. */
bool process_tapping(keyrecord_t *keyp) {
keyevent_t event = keyp->event;
-# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(TAPPING_FORCE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- uint16_t tapping_keycode = get_record_keycode(&tapping_key, false);
-# endif
+ TAP_DEFINE_KEYCODE;
// if tapping
if (IS_TAPPING_PRESSED()) {
- // clang-format off
- if (WITHIN_TAPPING_TERM(event)
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- || (
-# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(tapping_keycode, &tapping_key) &&
-# endif
- (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0)
- )
-# endif
- ) {
- // clang-format on
+ if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
if (tapping_key.tap.count == 0) {
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
retroshift_swap_times();
# endif
// first tap!
- debug("Tapping: First tap(0->1).\n");
+ ac_dprintf("Tapping: First tap(0->1).\n");
tapping_key.tap.count = 1;
debug_tapping_key();
process_record(&tapping_key);
@@ -164,73 +202,46 @@ bool process_tapping(keyrecord_t *keyp) {
* useful for long TAPPING_TERM but may prevent fast typing.
*/
// clang-format off
-# if defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
else if (
(
- IS_RELEASED(event) && waiting_buffer_typed(event)
-# ifdef PERMISSIVE_HOLD_PER_KEY
- && get_permissive_hold(tapping_keycode, &tapping_key)
-# elif defined(PERMISSIVE_HOLD)
- && true
-# endif
+ IS_RELEASED(event) && waiting_buffer_typed(event) &&
+ TAP_GET_PERMISSIVE_HOLD
)
// Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT
// unnecessarily and fixes them for Layer Taps.
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- || (
-# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(tapping_keycode, &tapping_key) &&
-# endif
+ || (TAP_GET_RETRO_TAPPING &&
(
// Rolled over the two keys.
- (
- (
- false
-# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- || (
- IS_LT(tapping_keycode)
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- && get_hold_on_other_key_press(tapping_keycode, &tapping_key)
-# endif
- )
-# endif
-# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
- || (
- IS_MT(tapping_keycode)
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- && !get_ignore_mod_tap_interrupt(tapping_keycode, &tapping_key)
-# endif
- )
-# endif
- ) && tapping_key.tap.interrupted == true
+ (tapping_key.tap.interrupted == true && (
+ (TAP_IS_LT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS) ||
+ (TAP_IS_MT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS)
+ )
)
// Makes Retro Shift ignore [IGNORE_MOD_TAP_INTERRUPT's
// effects on nested taps for MTs and the default
// behavior of LTs] below TAPPING_TERM or RETRO_SHIFT.
|| (
- IS_RETRO(tapping_keycode)
+ TAP_IS_RETRO
&& (event.key.col != tapping_key.event.key.col || event.key.row != tapping_key.event.key.row)
&& IS_RELEASED(event) && waiting_buffer_typed(event)
)
)
)
-# endif
) {
// clang-format on
- debug("Tapping: End. No tap. Interfered by typing key\n");
+ ac_dprintf("Tapping: End. No tap. Interfered by typing key\n");
process_record(&tapping_key);
tapping_key = (keyrecord_t){};
debug_tapping_key();
// enqueue
return false;
}
-# endif
/* Process release event of a key pressed before tapping starts
* Without this unexpected repeating will occur with having fast repeating setting
* https://github.com/tmk/tmk_keyboard/issues/60
*/
else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) {
- // Modifier should be retained till end of this tapping.
+ // Modifier/Layer should be retained till end of this tapping.
action_t action = layer_switch_get_action(event.key);
switch (action.kind.id) {
case ACT_LMODS:
@@ -243,28 +254,33 @@ bool process_tapping(keyrecord_t *keyp) {
if (action.key.mods && keyp->tap.count == 0) return false;
if (IS_MOD(action.key.code)) return false;
break;
+ case ACT_LAYER_TAP:
+ case ACT_LAYER_TAP_EXT:
+ switch (action.layer_tap.code) {
+ case 0 ...(OP_TAP_TOGGLE - 1):
+ case OP_ON_OFF:
+ case OP_OFF_ON:
+ case OP_SET_CLEAR:
+ return false;
+ }
+ break;
}
// Release of key should be process immediately.
- debug("Tapping: release event of a key pressed before tapping\n");
+ ac_dprintf("Tapping: release event of a key pressed before tapping\n");
process_record(keyp);
return true;
} else {
// set interrupted flag when other key preesed during tapping
if (event.pressed) {
tapping_key.tap.interrupted = true;
-# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
-# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- if (get_hold_on_other_key_press(tapping_keycode, &tapping_key))
-# endif
- {
- debug("Tapping: End. No tap. Interfered by pressed key\n");
+ if (TAP_GET_HOLD_ON_OTHER_KEY_PRESS) {
+ ac_dprintf("Tapping: End. No tap. Interfered by pressed key\n");
process_record(&tapping_key);
tapping_key = (keyrecord_t){};
debug_tapping_key();
// enqueue
return false;
}
-# endif
}
// enqueue
return false;
@@ -273,9 +289,7 @@ bool process_tapping(keyrecord_t *keyp) {
// tap_count > 0
else {
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
- debug("Tapping: Tap release(");
- debug_dec(tapping_key.tap.count);
- debug(")\n");
+ ac_dprintf("Tapping: Tap release(%u)\n", tapping_key.tap.count);
keyp->tap = tapping_key.tap;
process_record(keyp);
tapping_key = *keyp;
@@ -283,7 +297,7 @@ bool process_tapping(keyrecord_t *keyp) {
return true;
} else if (is_tap_record(keyp) && event.pressed) {
if (tapping_key.tap.count > 1) {
- debug("Tapping: Start new tap with releasing last tap(>1).\n");
+ ac_dprintf("Tapping: Start new tap with releasing last tap(>1).\n");
// unregister key
process_record(&(keyrecord_t){
.tap = tapping_key.tap,
@@ -295,15 +309,15 @@ bool process_tapping(keyrecord_t *keyp) {
# endif
});
} else {
- debug("Tapping: Start while last tap(1).\n");
+ ac_dprintf("Tapping: Start while last tap(1).\n");
}
tapping_key = *keyp;
waiting_buffer_scan_tap();
debug_tapping_key();
return true;
} else {
- if (!IS_NOEVENT(event)) {
- debug("Tapping: key event while last tap(>0).\n");
+ if (IS_EVENT(event)) {
+ ac_dprintf("Tapping: key event while last tap(>0).\n");
}
process_record(keyp);
return true;
@@ -313,23 +327,23 @@ bool process_tapping(keyrecord_t *keyp) {
// after TAPPING_TERM
else {
if (tapping_key.tap.count == 0) {
- debug("Tapping: End. Timeout. Not tap(0): ");
+ ac_dprintf("Tapping: End. Timeout. Not tap(0): ");
debug_event(event);
- debug("\n");
+ ac_dprintf("\n");
process_record(&tapping_key);
tapping_key = (keyrecord_t){};
debug_tapping_key();
return false;
} else {
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
- debug("Tapping: End. last timeout tap release(>0).");
+ ac_dprintf("Tapping: End. last timeout tap release(>0).");
keyp->tap = tapping_key.tap;
process_record(keyp);
tapping_key = (keyrecord_t){};
return true;
} else if (is_tap_record(keyp) && event.pressed) {
if (tapping_key.tap.count > 1) {
- debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
+ ac_dprintf("Tapping: Start new tap with releasing last timeout tap(>1).\n");
// unregister key
process_record(&(keyrecord_t){
.tap = tapping_key.tap,
@@ -341,15 +355,15 @@ bool process_tapping(keyrecord_t *keyp) {
# endif
});
} else {
- debug("Tapping: Start while last timeout tap(1).\n");
+ ac_dprintf("Tapping: Start while last timeout tap(1).\n");
}
tapping_key = *keyp;
waiting_buffer_scan_tap();
debug_tapping_key();
return true;
} else {
- if (!IS_NOEVENT(event)) {
- debug("Tapping: key event while last timeout tap(>0).\n");
+ if (IS_EVENT(event)) {
+ ac_dprintf("Tapping: key event while last timeout tap(>0).\n");
}
process_record(keyp);
return true;
@@ -357,45 +371,25 @@ bool process_tapping(keyrecord_t *keyp) {
}
}
} else if (IS_TAPPING_RELEASED()) {
- // clang-format off
- if (WITHIN_TAPPING_TERM(event)
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- || (
-# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(tapping_keycode, &tapping_key) &&
-# endif
- (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0)
- )
-# endif
- ) {
- // clang-format on
+ if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
if (event.pressed) {
if (IS_TAPPING_RECORD(keyp)) {
-//# ifndef TAPPING_FORCE_HOLD
-# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY)
- if (
-# ifdef TAPPING_FORCE_HOLD_PER_KEY
- !get_tapping_force_hold(tapping_keycode, &tapping_key) &&
-# endif
- !tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
+ if (WITHIN_QUICK_TAP_TERM(event) && !tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
// sequential tap.
keyp->tap = tapping_key.tap;
if (keyp->tap.count < 15) keyp->tap.count += 1;
- debug("Tapping: Tap press(");
- debug_dec(keyp->tap.count);
- debug(")\n");
+ ac_dprintf("Tapping: Tap press(%u)\n", keyp->tap.count);
process_record(keyp);
tapping_key = *keyp;
debug_tapping_key();
return true;
}
-# endif
// FIX: start new tap again
tapping_key = *keyp;
return true;
} else if (is_tap_record(keyp)) {
// Sequential tap can be interfered with other tap key.
- debug("Tapping: Start with interfering other tap.\n");
+ ac_dprintf("Tapping: Start with interfering other tap.\n");
tapping_key = *keyp;
waiting_buffer_scan_tap();
debug_tapping_key();
@@ -408,16 +402,16 @@ bool process_tapping(keyrecord_t *keyp) {
return true;
}
} else {
- if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n");
+ if (IS_EVENT(event)) ac_dprintf("Tapping: other key just after tap.\n");
process_record(keyp);
return true;
}
} else {
// FIX: process_action here?
// timeout. no sequential tap.
- debug("Tapping: End(Timeout after releasing last tap): ");
+ ac_dprintf("Tapping: End(Timeout after releasing last tap): ");
debug_event(event);
- debug("\n");
+ ac_dprintf("\n");
tapping_key = (keyrecord_t){};
debug_tapping_key();
return false;
@@ -426,7 +420,7 @@ bool process_tapping(keyrecord_t *keyp) {
// not tapping state
else {
if (event.pressed && is_tap_record(keyp)) {
- debug("Tapping: Start(Press tap key).\n");
+ ac_dprintf("Tapping: Start(Press tap key).\n");
tapping_key = *keyp;
process_record_tap_hint(&tapping_key);
waiting_buffer_scan_tap();
@@ -449,14 +443,14 @@ bool waiting_buffer_enq(keyrecord_t record) {
}
if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) {
- debug("waiting_buffer_enq: Over flow.\n");
+ ac_dprintf("waiting_buffer_enq: Over flow.\n");
return false;
}
waiting_buffer[waiting_buffer_head] = record;
waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE;
- debug("waiting_buffer_enq: ");
+ ac_dprintf("waiting_buffer_enq: ");
debug_waiting_buffer();
return true;
}
@@ -510,9 +504,7 @@ void waiting_buffer_scan_tap(void) {
waiting_buffer[i].tap.count = 1;
process_record(&tapping_key);
- debug("waiting_buffer_scan_tap: found at [");
- debug_dec(i);
- debug("]\n");
+ ac_dprintf("waiting_buffer_scan_tap: found at [%u]\n", i);
debug_waiting_buffer();
return;
}
@@ -524,9 +516,9 @@ void waiting_buffer_scan_tap(void) {
* FIXME: Needs docs
*/
static void debug_tapping_key(void) {
- debug("TAPPING_KEY=");
+ ac_dprintf("TAPPING_KEY=");
debug_record(tapping_key);
- debug("\n");
+ ac_dprintf("\n");
}
/** \brief Waiting buffer debug print
@@ -534,15 +526,13 @@ static void debug_tapping_key(void) {
* FIXME: Needs docs
*/
static void debug_waiting_buffer(void) {
- debug("{ ");
+ ac_dprintf("{ ");
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
- debug("[");
- debug_dec(i);
- debug("]=");
+ ac_dprintf("[%u]=", i);
debug_record(waiting_buffer[i]);
- debug(" ");
+ ac_dprintf(" ");
}
- debug("}\n");
+ ac_dprintf("}\n");
}
#endif
diff --git a/quantum/action_tapping.h b/quantum/action_tapping.h
index bcccc7ac45..c078488c04 100644
--- a/quantum/action_tapping.h
+++ b/quantum/action_tapping.h
@@ -22,6 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define TAPPING_TERM 200
#endif
+/* period of quick tap(ms) */
+#if !defined(QUICK_TAP_TERM) || QUICK_TAP_TERM > TAPPING_TERM
+# define QUICK_TAP_TERM TAPPING_TERM
+#endif
+
/* tap count needed for toggling a feature */
#ifndef TAPPING_TOGGLE
# define TAPPING_TOGGLE 5
@@ -36,9 +41,9 @@ void action_tapping_process(keyrecord_t record);
#endif
uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record);
+uint16_t get_quick_tap_term(uint16_t keycode, keyrecord_t *record);
bool get_permissive_hold(uint16_t keycode, keyrecord_t *record);
bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record);
-bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record);
bool get_retro_tapping(uint16_t keycode, keyrecord_t *record);
bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record);
@@ -53,3 +58,9 @@ extern uint16_t g_tapping_term;
#else
# define GET_TAPPING_TERM(keycode, record) (TAPPING_TERM)
#endif
+
+#ifdef QUICK_TAP_TERM_PER_KEY
+# define GET_QUICK_TAP_TERM(keycode, record) get_quick_tap_term(keycode, record)
+#else
+# define GET_QUICK_TAP_TERM(keycode, record) (QUICK_TAP_TERM)
+#endif
diff --git a/quantum/keyboard.h b/quantum/keyboard.h
index 86ce65aac1..d0b52dd13a 100644
--- a/quantum/keyboard.h
+++ b/quantum/keyboard.h
@@ -53,6 +53,9 @@ typedef struct {
static inline bool IS_NOEVENT(keyevent_t event) {
return event.time == 0 || (event.key.row == KEYLOC_TICK && event.key.col == KEYLOC_TICK);
}
+static inline bool IS_EVENT(keyevent_t event) {
+ return !IS_NOEVENT(event);
+}
static inline bool IS_KEYEVENT(keyevent_t event) {
return event.key.row < MATRIX_ROWS && event.key.col < MATRIX_COLS;
}
@@ -63,10 +66,10 @@ static inline bool IS_ENCODEREVENT(keyevent_t event) {
return event.key.row == KEYLOC_ENCODER_CW || event.key.row == KEYLOC_ENCODER_CCW;
}
static inline bool IS_PRESSED(keyevent_t event) {
- return !IS_NOEVENT(event) && event.pressed;
+ return IS_EVENT(event) && event.pressed;
}
static inline bool IS_RELEASED(keyevent_t event) {
- return !IS_NOEVENT(event) && !event.pressed;
+ return IS_EVENT(event) && !event.pressed;
}
/* Common keyevent object factory */
diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h
index 03fe8149f0..a6c42eafbf 100644
--- a/quantum/keymap_extras/keymap_uk.h
+++ b/quantum/keymap_extras/keymap_uk.h
@@ -1,39 +1,33 @@
-/* Copyright 2015-2016 Jack Humbert
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
-#pragma once
+/*******************************************************************************
+ 88888888888 888 d8b .d888 d8b 888 d8b
+ 888 888 Y8P d88P" Y8P 888 Y8P
+ 888 888 888 888
+ 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
+ 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
+ 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
+ 888 888 888 888 X88 888 888 888 Y8b. 888 X88
+ 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
+ 888 888
+ 888 888
+ 888 888
+ .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
+ d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
+ 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
+ Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
+ "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
+ 888
+ Y8b d88P
+ "Y88P"
+*******************************************************************************/
+#pragma once
#include "keymap.h"
-
// clang-format off
-/*
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ # │ │
- * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ \ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ │
- * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-// Row 1
+// Aliases
#define UK_GRV KC_GRV // `
#define UK_1 KC_1 // 1
#define UK_2 KC_2 // 2
@@ -47,7 +41,6 @@
#define UK_0 KC_0 // 0
#define UK_MINS KC_MINS // -
#define UK_EQL KC_EQL // =
-// Row 2
#define UK_Q KC_Q // Q
#define UK_W KC_W // W
#define UK_E KC_E // E
@@ -60,7 +53,6 @@
#define UK_P KC_P // P
#define UK_LBRC KC_LBRC // [
#define UK_RBRC KC_RBRC // ]
-// Row 3
#define UK_A KC_A // A
#define UK_S KC_S // S
#define UK_D KC_D // D
@@ -73,7 +65,6 @@
#define UK_SCLN KC_SCLN // ;
#define UK_QUOT KC_QUOT // '
#define UK_HASH KC_NUHS // #
-// Row 4
#define UK_BSLS KC_NUBS // (backslash)
#define UK_Z KC_Z // Z
#define UK_X KC_X // X
@@ -85,21 +76,6 @@
#define UK_COMM KC_COMM // ,
#define UK_DOT KC_DOT // .
#define UK_SLSH KC_SLSH // /
-
-/* Shifted symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ¬ │ ! │ " │ £ │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ │ │ │ │ │ │ │ │ │ : │ @ │ ~ │ │
- * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ | │ │ │ │ │ │ │ │ < │ > │ ? │ │
- * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-// Row 1
#define UK_NOT S(UK_GRV) // ¬
#define UK_EXLM S(UK_1) // !
#define UK_DQUO S(UK_2) // "
@@ -113,39 +89,21 @@
#define UK_RPRN S(UK_0) // )
#define UK_UNDS S(UK_MINS) // _
#define UK_PLUS S(UK_EQL) // +
-// Row 2
#define UK_LCBR S(UK_LBRC) // {
#define UK_RCBR S(UK_RBRC) // }
-// Row 3
#define UK_COLN S(UK_SCLN) // :
#define UK_AT S(UK_QUOT) // @
#define UK_TILD S(UK_HASH) // ~
-// Row 4
#define UK_PIPE S(UK_BSLS) // |
#define UK_LABK S(UK_COMM) // <
#define UK_RABK S(UK_DOT) // >
#define UK_QUES S(UK_SLSH) // ?
-
-/* AltGr symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ¦ │ │ │ │ € │ │ │ │ │ │ │ │ │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ É │ │ │ │ Ú │ Í │ Ó │ │ │ │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ Á │ │ │ │ │ │ │ │ │ │ │ │ │
- * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ │ │
- * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-// Row 1
#define UK_BRKP ALGR(UK_GRV) // ¦
#define UK_EURO ALGR(UK_4) // €
-// Row 2
#define UK_EACU ALGR(KC_E) // É
#define UK_UACU ALGR(KC_U) // Ú
#define UK_IACU ALGR(KC_I) // Í
#define UK_OACU ALGR(KC_O) // Ó
-// Row 3
#define UK_AACU ALGR(KC_A) // Á
+
+
diff --git a/quantum/keymap_extras/keymap_us.h b/quantum/keymap_extras/keymap_us.h
index b18c701679..c5c5285848 100644
--- a/quantum/keymap_extras/keymap_us.h
+++ b/quantum/keymap_extras/keymap_us.h
@@ -1,52 +1,55 @@
// Copyright 2022 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
-#pragma once
+/*******************************************************************************
+ 88888888888 888 d8b .d888 d8b 888 d8b
+ 888 888 Y8P d88P" Y8P 888 Y8P
+ 888 888 888 888
+ 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
+ 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
+ 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
+ 888 888 888 888 X88 888 888 888 Y8b. 888 X88
+ 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
+ 888 888
+ 888 888
+ 888 888
+ .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
+ d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
+ 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
+ Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
+ "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
+ 888
+ Y8b d88P
+ "Y88P"
+*******************************************************************************/
+#pragma once
#include "keymap.h"
-
// clang-format off
-/* Shifted symbols
- * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │
- * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ { │ } │ | │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │ │ │ │ │ │ │ │ │ │ │ : │ " │ │
- * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
- * │ │ │ │ │ │ │ │ │ < │ > │ ? │ │
- * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
- * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
- */
-// Row 1
+// Aliases
#define KC_TILD S(KC_GRAVE) // ~
-#define KC_EXLM S(KC_1) // !
-#define KC_AT S(KC_2) // @
-#define KC_HASH S(KC_3) // #
-#define KC_DLR S(KC_4) // $
-#define KC_PERC S(KC_5) // %
-#define KC_CIRC S(KC_6) // ^
-#define KC_AMPR S(KC_7) // &
-#define KC_ASTR S(KC_8) // *
-#define KC_LPRN S(KC_9) // (
-#define KC_RPRN S(KC_0) // )
+#define KC_EXLM S(KC_1) // !
+#define KC_AT S(KC_2) // @
+#define KC_HASH S(KC_3) // #
+#define KC_DLR S(KC_4) // $
+#define KC_PERC S(KC_5) // %
+#define KC_CIRC S(KC_6) // ^
+#define KC_AMPR S(KC_7) // &
+#define KC_ASTR S(KC_8) // *
+#define KC_LPRN S(KC_9) // (
+#define KC_RPRN S(KC_0) // )
#define KC_UNDS S(KC_MINUS) // _
#define KC_PLUS S(KC_EQUAL) // +
-// Row 2
-#define KC_LCBR S(KC_LEFT_BRACKET) // {
+#define KC_LCBR S(KC_LEFT_BRACKET) // {
#define KC_RCBR S(KC_RIGHT_BRACKET) // }
-#define KC_PIPE S(KC_BACKSLASH) // |
-// Row 3
+#define KC_PIPE S(KC_BACKSLASH) // |
#define KC_COLN S(KC_SEMICOLON) // :
-#define KC_DQUO S(KC_QUOTE) // "
-// Row 4
+#define KC_DQUO S(KC_QUOTE) // "
#define KC_LABK S(KC_COMMA) // <
-#define KC_RABK S(KC_DOT) // >
+#define KC_RABK S(KC_DOT) // >
#define KC_QUES S(KC_SLASH) // ?
-// alias stuff
#define KC_TILDE KC_TILD
#define KC_EXCLAIM KC_EXLM
#define KC_DOLLAR KC_DLR
@@ -57,16 +60,14 @@
#define KC_LEFT_PAREN KC_LPRN
#define KC_RIGHT_PAREN KC_RPRN
#define KC_UNDERSCORE KC_UNDS
-
#define KC_LEFT_CURLY_BRACE KC_LCBR
#define KC_RIGHT_CURLY_BRACE KC_RCBR
-
#define KC_COLON KC_COLN
#define KC_DOUBLE_QUOTE KC_DQUO
#define KC_DQT KC_DQUO
-
#define KC_LEFT_ANGLE_BRACKET KC_LABK
#define KC_LT KC_LABK
#define KC_RIGHT_ANGLE_BRACKET KC_RABK
#define KC_GT KC_RABK
#define KC_QUESTION KC_QUES
+
diff --git a/quantum/led.c b/quantum/led.c
index 7db38bb88c..42144566fd 100644
--- a/quantum/led.c
+++ b/quantum/led.c
@@ -69,14 +69,6 @@ uint32_t last_led_activity_elapsed(void) {
*/
__attribute__((weak)) void led_set_user(uint8_t usb_led) {}
-/** \brief Lock LED set callback - keyboard level
- *
- * \deprecated Use led_update_kb() instead.
- */
-__attribute__((weak)) void led_set_kb(uint8_t usb_led) {
- led_set_user(usb_led);
-}
-
/** \brief Lock LED update callback - keymap/user level
*
* \return True if led_update_kb() should run its own code, false otherwise.
@@ -154,7 +146,7 @@ __attribute__((weak)) void led_set(uint8_t usb_led) {
handle_backlight_caps_lock((led_t)usb_led);
#endif
- led_set_kb(usb_led);
+ led_set_user(usb_led);
led_update_kb((led_t)usb_led);
}
diff --git a/quantum/led.h b/quantum/led.h
index d12e519ea2..b9ad7ed9ae 100644
--- a/quantum/led.h
+++ b/quantum/led.h
@@ -55,9 +55,10 @@ void led_wakeup(void);
void led_task(void);
-/* Callbacks */
+/* Deprecated callbacks */
void led_set_user(uint8_t usb_led);
-void led_set_kb(uint8_t usb_led);
+
+/* Callbacks */
bool led_update_user(led_t led_state);
bool led_update_kb(led_t led_state);
void led_update_ports(led_t led_state);
diff --git a/quantum/logging/nodebug.h b/quantum/logging/nodebug.h
deleted file mode 100644
index 0b176684bd..0000000000
--- a/quantum/logging/nodebug.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-Copyright 2013 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#pragma once
-
-#ifndef NO_DEBUG
-# define NO_DEBUG
-# include "debug.h"
-# undef NO_DEBUG
-#else
-# include "debug.h"
-#endif
diff --git a/quantum/main.c b/quantum/main.c
index 2d5911b708..3b101c522c 100644
--- a/quantum/main.c
+++ b/quantum/main.c
@@ -60,9 +60,9 @@ int main(void) {
protocol_task();
#ifdef QUANTUM_PAINTER_ENABLE
- // Run Quantum Painter animations
- void qp_internal_animation_tick(void);
- qp_internal_animation_tick();
+ // Run Quantum Painter task
+ void qp_internal_task(void);
+ qp_internal_task();
#endif
#ifdef DEFERRED_EXEC_ENABLE
diff --git a/quantum/matrix.c b/quantum/matrix.c
index db683104ed..0de65c6cdd 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -46,6 +46,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define SPLIT_MUTABLE_COL const
#endif
+#ifndef MATRIX_INPUT_PRESSED_STATE
+# define MATRIX_INPUT_PRESSED_STATE 0
+#endif
+
#ifdef DIRECT_PINS
static SPLIT_MUTABLE pin_t direct_pins[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS;
#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
@@ -93,7 +97,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) {
static inline uint8_t readMatrixPin(pin_t pin) {
if (pin != NO_PIN) {
- return readPin(pin);
+ return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
} else {
return 1;
}
@@ -121,9 +125,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[]
matrix_row_t row_shifter = MATRIX_ROW_SHIFTER;
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) {
pin_t pin = direct_pins[current_row][col_index];
- if (pin != NO_PIN) {
- current_row_value |= readPin(pin) ? 0 : row_shifter;
- }
+ current_row_value |= readMatrixPin(pin) ? 0 : row_shifter;
}
// Update the matrix
diff --git a/quantum/os_detection.c b/quantum/os_detection.c
new file mode 100644
index 0000000000..b1511afb14
--- /dev/null
+++ b/quantum/os_detection.c
@@ -0,0 +1,129 @@
+/* Copyright 2022 Ruslan Sayfutdinov (@KapJI)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "os_detection.h"
+
+#include <string.h>
+
+#ifdef OS_DETECTION_DEBUG_ENABLE
+# include "eeconfig.h"
+# include "eeprom.h"
+# include "print.h"
+
+# define STORED_USB_SETUPS 50
+# define EEPROM_USER_OFFSET (uint8_t*)EECONFIG_SIZE
+
+uint16_t usb_setups[STORED_USB_SETUPS];
+#endif
+
+#ifdef OS_DETECTION_ENABLE
+struct setups_data_t {
+ uint8_t count;
+ uint8_t cnt_02;
+ uint8_t cnt_04;
+ uint8_t cnt_ff;
+ uint16_t last_wlength;
+ os_variant_t detected_os;
+};
+
+struct setups_data_t setups_data = {
+ .count = 0,
+ .cnt_02 = 0,
+ .cnt_04 = 0,
+ .cnt_ff = 0,
+ .detected_os = OS_UNSURE,
+};
+
+// Some collected sequences of wLength can be found in tests.
+void make_guess(void) {
+ if (setups_data.count < 3) {
+ return;
+ }
+ if (setups_data.cnt_ff >= 2 && setups_data.cnt_04 >= 1) {
+ setups_data.detected_os = OS_WINDOWS;
+ return;
+ }
+ if (setups_data.count == setups_data.cnt_ff) {
+ // Linux has 3 packets with 0xFF.
+ setups_data.detected_os = OS_LINUX;
+ return;
+ }
+ if (setups_data.count == 5 && setups_data.last_wlength == 0xFF && setups_data.cnt_ff == 1 && setups_data.cnt_02 == 2) {
+ setups_data.detected_os = OS_MACOS;
+ return;
+ }
+ if (setups_data.count == 4 && setups_data.cnt_ff == 0 && setups_data.cnt_02 == 2) {
+ // iOS and iPadOS don't have the last 0xFF packet.
+ setups_data.detected_os = OS_IOS;
+ return;
+ }
+ if (setups_data.cnt_ff == 0 && setups_data.cnt_02 == 3 && setups_data.cnt_04 == 1) {
+ // This is actually PS5.
+ setups_data.detected_os = OS_LINUX;
+ return;
+ }
+ if (setups_data.cnt_ff >= 1 && setups_data.cnt_02 == 0 && setups_data.cnt_04 == 0) {
+ // This is actually Quest 2 or Nintendo Switch.
+ setups_data.detected_os = OS_LINUX;
+ return;
+ }
+}
+
+void process_wlength(const uint16_t w_length) {
+# ifdef OS_DETECTION_DEBUG_ENABLE
+ usb_setups[setups_data.count] = w_length;
+# endif
+ setups_data.count++;
+ setups_data.last_wlength = w_length;
+ if (w_length == 0x2) {
+ setups_data.cnt_02++;
+ } else if (w_length == 0x4) {
+ setups_data.cnt_04++;
+ } else if (w_length == 0xFF) {
+ setups_data.cnt_ff++;
+ }
+ make_guess();
+}
+
+os_variant_t detected_host_os(void) {
+ return setups_data.detected_os;
+}
+
+void erase_wlength_data(void) {
+ memset(&setups_data, 0, sizeof(setups_data));
+}
+#endif // OS_DETECTION_ENABLE
+
+#ifdef OS_DETECTION_DEBUG_ENABLE
+void print_stored_setups(void) {
+# ifdef CONSOLE_ENABLE
+ uint8_t cnt = eeprom_read_byte(EEPROM_USER_OFFSET);
+ for (uint16_t i = 0; i < cnt; ++i) {
+ uint16_t* addr = (uint16_t*)EEPROM_USER_OFFSET + i * sizeof(uint16_t) + sizeof(uint8_t);
+ xprintf("i: %d, wLength: 0x%02X\n", i, eeprom_read_word(addr));
+ }
+# endif
+}
+
+void store_setups_in_eeprom(void) {
+ eeprom_update_byte(EEPROM_USER_OFFSET, setups_data.count);
+ for (uint16_t i = 0; i < setups_data.count; ++i) {
+ uint16_t* addr = (uint16_t*)EEPROM_USER_OFFSET + i * sizeof(uint16_t) + sizeof(uint8_t);
+ eeprom_update_word(addr, usb_setups[i]);
+ }
+}
+
+#endif // OS_DETECTION_DEBUG_ENABLE
diff --git a/quantum/os_detection.h b/quantum/os_detection.h
new file mode 100644
index 0000000000..e643dcd27f
--- /dev/null
+++ b/quantum/os_detection.h
@@ -0,0 +1,38 @@
+/* Copyright 2022 Ruslan Sayfutdinov (@KapJI)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#ifdef OS_DETECTION_ENABLE
+typedef enum {
+ OS_UNSURE,
+ OS_LINUX,
+ OS_WINDOWS,
+ OS_MACOS,
+ OS_IOS,
+} os_variant_t;
+
+void process_wlength(const uint16_t w_length);
+os_variant_t detected_host_os(void);
+void erase_wlength_data(void);
+#endif
+
+#ifdef OS_DETECTION_DEBUG_ENABLE
+void print_stored_setups(void);
+void store_setups_in_eeprom(void);
+#endif
diff --git a/quantum/os_detection/tests/os_detection.cpp b/quantum/os_detection/tests/os_detection.cpp
new file mode 100644
index 0000000000..102349852e
--- /dev/null
+++ b/quantum/os_detection/tests/os_detection.cpp
@@ -0,0 +1,164 @@
+/* Copyright 2022 Ruslan Sayfutdinov (@KapJI)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gtest/gtest.h"
+
+extern "C" {
+#include "os_detection.h"
+}
+
+class OsDetectionTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ erase_wlength_data();
+ }
+};
+
+os_variant_t check_sequence(const std::vector<uint16_t> &w_lengths) {
+ for (auto &w_length : w_lengths) {
+ process_wlength(w_length);
+ }
+ return detected_host_os();
+}
+
+/* Some collected data.
+
+ChibiOS:
+Windows 10: [FF, FF, 4, 24, 4, 24, 4, FF, 24, FF, 4, FF, 24, 4, 24, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A]
+Windows 10 (another host): [FF, FF, 4, 24, 4, 24, 4, 24, 4, 24, 4, 24]
+macOS 12.5: [2, 24, 2, 28, FF]
+iOS/iPadOS 15.6: [2, 24, 2, 28]
+Linux (including Android, Raspberry Pi and WebOS TV): [FF, FF, FF]
+PS5: [2, 4, 2, 28, 2, 24]
+Nintendo Switch: [82, FF, 40, 40, FF, 40, 40, FF, 40, 40, FF, 40, 40, FF, 40, 40]
+Quest 2: [FF, FF, FF, FE, FF, FE, FF, FE, FF, FE, FF]
+
+LUFA:
+Windows 10 (first connect): [12, FF, FF, 4, 10, FF, FF, FF, 4, 10, 20A, 20A, 20A, 20A, 20A, 20A]
+Windows 10 (subsequent connect): [FF, FF, 4, 10, FF, 4, FF, 10, FF, 20A, 20A, 20A, 20A, 20A, 20A]
+Windows 10 (another host): [FF, FF, 4, 10, 4, 10]
+macOS: [2, 10, 2, E, FF]
+iOS/iPadOS: [2, 10, 2, E]
+Linux: [FF, FF, FF]
+PS5: [2, 4, 2, E, 2, 10]
+Nintendo Switch: [82, FF, 40, 40, FF, 40, 40]
+
+V-USB:
+Windows 10: [FF, FF, 4, E, FF]
+Windows 10 (another host): [FF, FF, 4, E, 4]
+macOS: [2, E, 2, E, FF]
+iOS/iPadOS: [2, E, 2, E]
+Linux: [FF, FF, FF]
+PS5: [2, 4, 2, E, 2]
+Nintendo Switch: [82, FF, 40, 40]
+Quest 2: [FF, FF, FF, FE]
+
+Common parts:
+Windows: [..., FF, FF, 4, ...]
+macOS: [2, _, 2, _, FF]
+iOS/iPadOS: [2, _, 2, _]
+Linux: [FF, FF, FF]
+PS5: [2, 4, 2, _, 2, ...]
+Nintendo Switch: [82, FF, 40, 40, ...]
+Quest 2: [FF, FF, FF, FE, ...]
+*/
+TEST_F(OsDetectionTest, TestLinux) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestChibiosMacos) {
+ EXPECT_EQ(check_sequence({0x2, 0x24, 0x2, 0x28, 0xFF}), OS_MACOS);
+}
+
+TEST_F(OsDetectionTest, TestLufaMacos) {
+ EXPECT_EQ(check_sequence({0x2, 0x10, 0x2, 0xE, 0xFF}), OS_MACOS);
+}
+
+TEST_F(OsDetectionTest, TestVusbMacos) {
+ EXPECT_EQ(check_sequence({0x2, 0xE, 0x2, 0xE, 0xFF}), OS_MACOS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosIos) {
+ EXPECT_EQ(check_sequence({0x2, 0x24, 0x2, 0x28}), OS_IOS);
+}
+
+TEST_F(OsDetectionTest, TestLufaIos) {
+ EXPECT_EQ(check_sequence({0x2, 0x10, 0x2, 0xE}), OS_IOS);
+}
+
+TEST_F(OsDetectionTest, TestVusbIos) {
+ EXPECT_EQ(check_sequence({0x2, 0xE, 0x2, 0xE}), OS_IOS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosWindows10) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x24, 0x4, 0x24, 0x4, 0xFF, 0x24, 0xFF, 0x4, 0xFF, 0x24, 0x4, 0x24, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosWindows10_2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x24, 0x4, 0x24, 0x4, 0x24, 0x4, 0x24, 0x4, 0x24}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestLufaWindows10) {
+ EXPECT_EQ(check_sequence({0x12, 0xFF, 0xFF, 0x4, 0x10, 0xFF, 0xFF, 0xFF, 0x4, 0x10, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestLufaWindows10_2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x10, 0xFF, 0x4, 0xFF, 0x10, 0xFF, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestLufaWindows10_3) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x10, 0x4, 0x10}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestVusbWindows10) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0xE, 0xFF}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestVusbWindows10_2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0xE, 0x4}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosPs5) {
+ EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0x28, 0x2, 0x24}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestLufaPs5) {
+ EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0xE, 0x2, 0x10}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestVusbPs5) {
+ EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0xE, 0x2}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestChibiosNintendoSwitch) {
+ EXPECT_EQ(check_sequence({0x82, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestLufaNintendoSwitch) {
+ EXPECT_EQ(check_sequence({0x82, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestVusbNintendoSwitch) {
+ EXPECT_EQ(check_sequence({0x82, 0xFF, 0x40, 0x40}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestChibiosQuest2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestVusbQuest2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE}), OS_LINUX);
+}
diff --git a/quantum/os_detection/tests/rules.mk b/quantum/os_detection/tests/rules.mk
new file mode 100644
index 0000000000..9bfe373f46
--- /dev/null
+++ b/quantum/os_detection/tests/rules.mk
@@ -0,0 +1,5 @@
+os_detection_DEFS := -DOS_DETECTION_ENABLE
+
+os_detection_SRC := \
+ $(QUANTUM_PATH)/os_detection/tests/os_detection.cpp \
+ $(QUANTUM_PATH)/os_detection.c
diff --git a/quantum/os_detection/tests/testlist.mk b/quantum/os_detection/tests/testlist.mk
new file mode 100644
index 0000000000..405a7b82d5
--- /dev/null
+++ b/quantum/os_detection/tests/testlist.mk
@@ -0,0 +1 @@
+TEST_LIST += os_detection
diff --git a/quantum/painter/lvgl/qp_lvgl.c b/quantum/painter/lvgl/qp_lvgl.c
new file mode 100644
index 0000000000..41ca3f98c2
--- /dev/null
+++ b/quantum/painter/lvgl/qp_lvgl.c
@@ -0,0 +1,144 @@
+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "qp_lvgl.h"
+#include "timer.h"
+#include "deferred_exec.h"
+#include "lvgl.h"
+
+typedef struct lvgl_state_t {
+ uint8_t fnc_id; // Ideally this should be the pointer of the function to run
+ uint16_t delay_ms;
+ deferred_token defer_token;
+} lvgl_state_t;
+
+static deferred_executor_t lvgl_executors[2] = {0}; // For lv_tick_inc and lv_task_handler
+static lvgl_state_t lvgl_states[2] = {0}; // For lv_tick_inc and lv_task_handler
+
+painter_device_t selected_display = NULL;
+void * color_buffer = NULL;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter LVGL Integration Internal: qp_lvgl_flush
+
+void qp_lvgl_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
+ if (selected_display) {
+ uint32_t number_pixels = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1);
+ qp_viewport(selected_display, area->x1, area->y1, area->x2, area->y2);
+ qp_pixdata(selected_display, (void *)color_p, number_pixels);
+ qp_flush(selected_display);
+ lv_disp_flush_ready(disp);
+ }
+}
+
+static uint32_t tick_task_callback(uint32_t trigger_time, void *cb_arg) {
+ lvgl_state_t * state = (lvgl_state_t *)cb_arg;
+ static uint32_t last_tick = 0;
+ switch (state->fnc_id) {
+ case 0: {
+ uint32_t now = timer_read32();
+ lv_tick_inc(TIMER_DIFF_32(now, last_tick));
+ last_tick = now;
+ } break;
+ case 1:
+ lv_task_handler();
+ break;
+
+ default:
+ break;
+ }
+
+ // The tasks should run indefinitely
+ return state->delay_ms;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter LVGL Integration API: qp_lvgl_attach
+
+bool qp_lvgl_attach(painter_device_t device) {
+ qp_dprintf("qp_lvgl_start: entry\n");
+ qp_lvgl_detach();
+
+ struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ if (!driver->validate_ok) {
+ qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n");
+ qp_lvgl_detach();
+ return false;
+ }
+
+ // Setting up the tasks
+ lvgl_state_t *lv_tick_inc_state = &lvgl_states[0];
+ lv_tick_inc_state->fnc_id = 0;
+ lv_tick_inc_state->delay_ms = 1;
+ lv_tick_inc_state->defer_token = defer_exec_advanced(lvgl_executors, 2, 1, tick_task_callback, lv_tick_inc_state);
+
+ if (lv_tick_inc_state->defer_token == INVALID_DEFERRED_TOKEN) {
+ qp_dprintf("qp_lvgl_attach: fail (could not set up qp_lvgl executor)\n");
+ qp_lvgl_detach();
+ return false;
+ }
+
+ lvgl_state_t *lv_task_handler_state = &lvgl_states[1];
+ lv_task_handler_state->fnc_id = 1;
+ lv_task_handler_state->delay_ms = 5;
+ lv_task_handler_state->defer_token = defer_exec_advanced(lvgl_executors, 2, 5, tick_task_callback, lv_task_handler_state);
+
+ if (lv_task_handler_state->defer_token == INVALID_DEFERRED_TOKEN) {
+ qp_dprintf("qp_lvgl_attach: fail (could not set up qp_lvgl executor)\n");
+ qp_lvgl_detach();
+ return false;
+ }
+
+ // Init LVGL
+ lv_init();
+
+ // Set up lvgl display buffer
+ static lv_disp_draw_buf_t draw_buf;
+ // Allocate a buffer for 1/10 screen size
+ const size_t count_required = driver->panel_width * driver->panel_height / 10;
+ color_buffer = color_buffer ? realloc(color_buffer, sizeof(lv_color_t) * count_required) : malloc(sizeof(lv_color_t) * count_required);
+ if (!color_buffer) {
+ qp_dprintf("qp_lvgl_attach: fail (could not set up memory buffer)\n");
+ qp_lvgl_detach();
+ return false;
+ }
+ memset(color_buffer, 0, sizeof(lv_color_t) * count_required);
+ // Initialize the display buffer.
+ lv_disp_draw_buf_init(&draw_buf, color_buffer, NULL, count_required);
+
+ selected_display = device;
+
+ // Setting up display driver
+ static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
+ lv_disp_drv_init(&disp_drv); /*Basic initialization*/
+ disp_drv.flush_cb = qp_lvgl_flush; /*Set your driver function*/
+ disp_drv.draw_buf = &draw_buf; /*Assign the buffer to the display*/
+ disp_drv.hor_res = driver->panel_width; /*Set the horizontal resolution of the display*/
+ disp_drv.ver_res = driver->panel_height; /*Set the vertical resolution of the display*/
+ lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter LVGL Integration API: qp_lvgl_detach
+
+void qp_lvgl_detach(void) {
+ for (int i = 0; i < 2; ++i) {
+ cancel_deferred_exec_advanced(lvgl_executors, 2, lvgl_states[i].defer_token);
+ }
+ if (color_buffer) {
+ free(color_buffer);
+ color_buffer = NULL;
+ }
+ selected_display = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter LVGL Integration Internal: qp_lvgl_internal_tick
+
+void qp_lvgl_internal_tick(void) {
+ static uint32_t last_lvgl_exec = 0;
+ deferred_exec_advanced_task(lvgl_executors, 2, &last_lvgl_exec);
+}
diff --git a/quantum/painter/lvgl/qp_lvgl.h b/quantum/painter/lvgl/qp_lvgl.h
new file mode 100644
index 0000000000..d9ad5e8df1
--- /dev/null
+++ b/quantum/painter/lvgl/qp_lvgl.h
@@ -0,0 +1,25 @@
+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "qp.h"
+#include "lvgl.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter - LVGL External API
+
+/**
+ * Sets up LVGL with the supplied display.
+ *
+ * @param device[in] the handle of the device to control
+ * @return true if init. of LVGL succeeded
+ * @return false if init. of LVGL failed
+ */
+bool qp_lvgl_attach(painter_device_t device);
+
+/**
+ * Disconnects LVGL from any attached display
+ */
+void qp_lvgl_detach(void);
diff --git a/quantum/painter/lvgl/rules.mk b/quantum/painter/lvgl/rules.mk
new file mode 100644
index 0000000000..50226941b3
--- /dev/null
+++ b/quantum/painter/lvgl/rules.mk
@@ -0,0 +1,24 @@
+# LVGL Integration
+
+OPT_DEFS += -DQUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE -DLV_CONF_INCLUDE_SIMPLE
+DEFERRED_EXEC_ENABLE := yes
+
+LVGL_DIR_NAME = lvgl
+LVGL_DIR = $(LIB_DIR)
+LVGL_PATH = $(LVGL_DIR)/$(LVGL_DIR_NAME)
+
+COMMON_VPATH += $(PLATFORM_PATH) \
+ $(QUANTUM_DIR)/painter/$(LVGL_DIR_NAME) \
+ $(LVGL_PATH)
+
+include $(LVGL_PATH)/src/extra/extra.mk
+include $(LVGL_PATH)/src/core/lv_core.mk
+include $(LVGL_PATH)/src/draw/lv_draw.mk
+include $(LVGL_PATH)/src/draw/sw/lv_draw_sw.mk
+include $(LVGL_PATH)/src/font/lv_font.mk
+include $(LVGL_PATH)/src/hal/lv_hal.mk
+include $(LVGL_PATH)/src/misc/lv_misc.mk
+include $(LVGL_PATH)/src/widgets/lv_widgets.mk
+
+SRC += qp_lvgl.c \
+ $(CSRCS)
diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h
index 69bc435961..e5f595d71d 100644
--- a/quantum/painter/qp.h
+++ b/quantum/painter/qp.h
@@ -463,3 +463,10 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
#ifdef QUANTUM_PAINTER_SSD1351_ENABLE
# include "qp_ssd1351.h"
#endif // QUANTUM_PAINTER_SSD1351_ENABLE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter Extras
+
+#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
+# include "qp_lvgl.h"
+#endif // QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c
index e9b975f23a..943cbfef5b 100644
--- a/quantum/painter/qp_draw_image.c
+++ b/quantum/painter/qp_draw_image.c
@@ -399,3 +399,15 @@ void qp_internal_animation_tick(void) {
static uint32_t last_anim_exec = 0;
deferred_exec_advanced_task(animation_executors, QUANTUM_PAINTER_CONCURRENT_ANIMATIONS, &last_anim_exec);
}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter Core API: qp_internal_task
+
+void qp_internal_task(void) {
+ qp_internal_animation_tick();
+#ifdef QUANTUM_PAINTER_LVGL_INTEGRATION_ENABLE
+ // Run LVGL ticks
+ void qp_lvgl_internal_tick(void);
+ qp_lvgl_internal_tick();
+#endif
+}
diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk
index 5ac374a96e..199e406dd6 100644
--- a/quantum/painter/rules.mk
+++ b/quantum/painter/rules.mk
@@ -2,6 +2,8 @@
QUANTUM_PAINTER_DRIVERS ?=
QUANTUM_PAINTER_ANIMATIONS_ENABLE ?= yes
+QUANTUM_PAINTER_LVGL_INTEGRATION ?= no
+
# The list of permissible drivers that can be listed in QUANTUM_PAINTER_DRIVERS
VALID_QUANTUM_PAINTER_DRIVERS := \
rgb565_surface \
@@ -152,3 +154,7 @@ ifeq ($(strip $(QUANTUM_PAINTER_NEEDS_COMMS_SPI)), yes)
endif
endif
+# Check if LVGL needs to be enabled
+ifeq ($(strip $(QUANTUM_PAINTER_LVGL_INTEGRATION)), yes)
+ include $(QUANTUM_DIR)/painter/lvgl/rules.mk
+endif
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index 35d4851ee5..aaf0cf9142 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -397,8 +397,17 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
break;
# endif
}
- // If Retro Shift is disabled, possible custom actions shouldn't happen.
- // clang-format off
+ // If Retro Shift is disabled, possible custom actions shouldn't happen.
+ // clang-format off
+# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
+# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+ const bool is_hold_on_interrupt = get_hold_on_other_key_press(keycode, record);
+# elif defined(IGNORE_MOD_TAP_INTERRUPT)
+ const bool is_hold_on_interrupt = false;
+# else
+ const bool is_hold_on_interrupt = IS_QK_MOD_TAP(keycode);
+# endif
+# endif
if (IS_RETRO(keycode)
# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
// Not tapped or #defines mean that rolls should use hold action.
@@ -407,27 +416,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
# ifdef RETRO_TAPPING_PER_KEY
|| !get_retro_tapping(keycode, record)
# endif
- || (record->tap.interrupted && (IS_LT(keycode)
-# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- ? get_hold_on_other_key_press(keycode, record)
-# else
- ? true
-# endif
-# else
- ? false
-# endif
-# if defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- : !get_ignore_mod_tap_interrupt(keycode, record)
-# else
- : false
-# endif
-# else
- : true
-# endif
- ))
- )
+ || (record->tap.interrupted && is_hold_on_interrupt))
# endif
) {
// clang-format on
@@ -454,10 +443,10 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
# endif
) {
// Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set.
-# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
+# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
if (autoshift_flags.in_progress
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- && !get_ignore_mod_tap_interrupt(keycode, record)
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+ && get_hold_on_other_key_press(keycode, record)
# endif
) {
autoshift_end(KC_NO, now, false, &autoshift_lastrecord);
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index 86adb04985..66a4b3138a 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -22,9 +22,8 @@
# define AUTO_SHIFT_TIMEOUT 175
#endif
-#define IS_LT(kc) ((kc) >= QK_LAYER_TAP && (kc) <= QK_LAYER_TAP_MAX)
-#define IS_MT(kc) ((kc) >= QK_MOD_TAP && (kc) <= QK_MOD_TAP_MAX)
-#define IS_RETRO(kc) (IS_MT(kc) || IS_LT(kc))
+#define IS_RETRO(kc) (IS_QK_MOD_TAP(kc) || IS_QK_LAYER_TAP(kc))
+
#define DO_GET_AUTOSHIFT_TIMEOUT(keycode, record, ...) record
// clang-format off
#define AUTO_SHIFT_ALPHA KC_A ... KC_Z
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index b74b4927a8..80bc96e65f 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -14,18 +14,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef LEADER_ENABLE
+#include "process_leader.h"
+#include <string.h>
-# include "process_leader.h"
-# include <string.h>
-
-# ifndef LEADER_TIMEOUT
-# define LEADER_TIMEOUT 300
-# endif
+#ifndef LEADER_TIMEOUT
+# define LEADER_TIMEOUT 300
+#endif
-__attribute__((weak)) void leader_start(void) {}
+__attribute__((weak)) void leader_start_user(void) {}
-__attribute__((weak)) void leader_end(void) {}
+__attribute__((weak)) void leader_end_user(void) {}
// Leader key stuff
bool leading = false;
@@ -34,52 +32,54 @@ uint16_t leader_time = 0;
uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
uint8_t leader_sequence_size = 0;
-void qk_leader_start(void) {
+void leader_start(void) {
if (leading) {
return;
}
- leader_start();
+ leader_start_user();
leading = true;
leader_time = timer_read();
leader_sequence_size = 0;
memset(leader_sequence, 0, sizeof(leader_sequence));
}
+void leader_end(void) {
+ leader_end_user();
+}
+
bool process_leader(uint16_t keycode, keyrecord_t *record) {
// Leader key set-up
if (record->event.pressed) {
if (leading) {
-# ifndef LEADER_NO_TIMEOUT
+#ifndef LEADER_NO_TIMEOUT
if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
-# endif // LEADER_NO_TIMEOUT
+#endif // LEADER_NO_TIMEOUT
{
-# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
+#ifndef LEADER_KEY_STRICT_KEY_PROCESSING
if (IS_QK_MOD_TAP(keycode)) {
keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode);
} else if (IS_QK_LAYER_TAP(keycode)) {
keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode);
}
-# endif // LEADER_KEY_STRICT_KEY_PROCESSING
+#endif // LEADER_KEY_STRICT_KEY_PROCESSING
if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) {
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;
} else {
leading = false;
- leader_end();
+ leader_end_user();
return true;
}
-# ifdef LEADER_PER_KEY_TIMING
+#ifdef LEADER_PER_KEY_TIMING
leader_time = timer_read();
-# endif
+#endif
return false;
}
} else {
if (keycode == QK_LEADER) {
- qk_leader_start();
+ leader_start();
}
}
}
return true;
}
-
-#endif
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h
index f3fe14a432..82b4a3ed7b 100644
--- a/quantum/process_keycode/process_leader.h
+++ b/quantum/process_keycode/process_leader.h
@@ -20,9 +20,11 @@
bool process_leader(uint16_t keycode, keyrecord_t *record);
+void leader_start_user(void);
+void leader_end_user(void);
+
void leader_start(void);
void leader_end(void);
-void qk_leader_start(void);
#define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0)
#define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0)
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 6e8e596673..fbe4ce1d33 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -18,8 +18,8 @@
static uint16_t active_td;
static uint16_t last_tap_time;
-void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void tap_dance_pair_on_each_tap(tap_dance_state_t *state, void *user_data) {
+ tap_dance_pair_t *pair = (tap_dance_pair_t *)user_data;
if (state->count == 2) {
register_code16(pair->kc2);
@@ -27,14 +27,14 @@ void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data)
}
}
-void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void tap_dance_pair_finished(tap_dance_state_t *state, void *user_data) {
+ tap_dance_pair_t *pair = (tap_dance_pair_t *)user_data;
register_code16(pair->kc1);
}
-void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void tap_dance_pair_reset(tap_dance_state_t *state, void *user_data) {
+ tap_dance_pair_t *pair = (tap_dance_pair_t *)user_data;
if (state->count == 1) {
wait_ms(TAP_CODE_DELAY);
@@ -44,8 +44,8 @@ void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data) {
}
}
-void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void tap_dance_dual_role_on_each_tap(tap_dance_state_t *state, void *user_data) {
+ tap_dance_dual_role_t *pair = (tap_dance_dual_role_t *)user_data;
if (state->count == 2) {
layer_move(pair->layer);
@@ -53,8 +53,8 @@ void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_
}
}
-void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void tap_dance_dual_role_finished(tap_dance_state_t *state, void *user_data) {
+ tap_dance_dual_role_t *pair = (tap_dance_dual_role_t *)user_data;
if (state->count == 1) {
register_code16(pair->kc);
@@ -63,8 +63,8 @@ void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_dat
}
}
-void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void tap_dance_dual_role_reset(tap_dance_state_t *state, void *user_data) {
+ tap_dance_dual_role_t *pair = (tap_dance_dual_role_t *)user_data;
if (state->count == 1) {
wait_ms(TAP_CODE_DELAY);
@@ -72,13 +72,13 @@ void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data)
}
}
-static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, void *user_data, qk_tap_dance_user_fn_t fn) {
+static inline void _process_tap_dance_action_fn(tap_dance_state_t *state, void *user_data, tap_dance_user_fn_t fn) {
if (fn) {
fn(state, user_data);
}
}
-static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) {
+static inline void process_tap_dance_action_on_each_tap(tap_dance_action_t *action) {
action->state.count++;
action->state.weak_mods = get_mods();
action->state.weak_mods |= get_weak_mods();
@@ -88,17 +88,17 @@ static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *a
_process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap);
}
-static inline void process_tap_dance_action_on_reset(qk_tap_dance_action_t *action) {
+static inline void process_tap_dance_action_on_reset(tap_dance_action_t *action) {
_process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_reset);
del_weak_mods(action->state.weak_mods);
#ifndef NO_ACTION_ONESHOT
del_mods(action->state.oneshot_mods);
#endif
send_keyboard_report();
- action->state = (const qk_tap_dance_state_t){0};
+ action->state = (const tap_dance_state_t){0};
}
-static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) {
+static inline void process_tap_dance_action_on_dance_finished(tap_dance_action_t *action) {
if (!action->state.finished) {
action->state.finished = true;
add_weak_mods(action->state.weak_mods);
@@ -116,7 +116,7 @@ static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_actio
}
bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
- qk_tap_dance_action_t *action;
+ tap_dance_action_t *action;
if (!record->event.pressed) return false;
@@ -139,7 +139,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
}
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
- qk_tap_dance_action_t *action;
+ tap_dance_action_t *action;
switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
@@ -163,7 +163,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
}
void tap_dance_task() {
- qk_tap_dance_action_t *action;
+ tap_dance_action_t *action;
if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
@@ -173,7 +173,7 @@ void tap_dance_task() {
}
}
-void reset_tap_dance(qk_tap_dance_state_t *state) {
+void reset_tap_dance(tap_dance_state_t *state) {
active_td = 0;
- process_tap_dance_action_on_reset((qk_tap_dance_action_t *)state);
+ process_tap_dance_action_on_reset((tap_dance_action_t *)state);
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index d6d6c136dc..5cb6d9202c 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -31,39 +31,39 @@ typedef struct {
bool pressed : 1;
bool finished : 1;
bool interrupted : 1;
-} qk_tap_dance_state_t;
+} tap_dance_state_t;
-typedef void (*qk_tap_dance_user_fn_t)(qk_tap_dance_state_t *state, void *user_data);
+typedef void (*tap_dance_user_fn_t)(tap_dance_state_t *state, void *user_data);
typedef struct {
- qk_tap_dance_state_t state;
+ tap_dance_state_t state;
struct {
- qk_tap_dance_user_fn_t on_each_tap;
- qk_tap_dance_user_fn_t on_dance_finished;
- qk_tap_dance_user_fn_t on_reset;
+ tap_dance_user_fn_t on_each_tap;
+ tap_dance_user_fn_t on_dance_finished;
+ tap_dance_user_fn_t on_reset;
} fn;
void *user_data;
-} qk_tap_dance_action_t;
+} tap_dance_action_t;
typedef struct {
uint16_t kc1;
uint16_t kc2;
-} qk_tap_dance_pair_t;
+} tap_dance_pair_t;
typedef struct {
uint16_t kc;
uint8_t layer;
void (*layer_function)(uint8_t);
-} qk_tap_dance_dual_role_t;
+} tap_dance_dual_role_t;
# define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \
- { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), }
+ { .fn = {tap_dance_pair_on_each_tap, tap_dance_pair_finished, tap_dance_pair_reset}, .user_data = (void *)&((tap_dance_pair_t){kc1, kc2}), }
# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) \
- { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), }
+ { .fn = {tap_dance_dual_role_on_each_tap, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_move}), }
# define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \
- { .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), }
+ { .fn = {NULL, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_invert}), }
# define ACTION_TAP_DANCE_FN(user_fn) \
{ .fn = {NULL, user_fn, NULL}, .user_data = NULL, }
@@ -73,11 +73,11 @@ typedef struct {
# define TD(n) (QK_TAP_DANCE | TD_INDEX(n))
# define TD_INDEX(code) ((code)&0xFF)
-# define TAP_DANCE_KEYCODE(state) TD(((qk_tap_dance_action_t *)state) - tap_dance_actions)
+# define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions)
-extern qk_tap_dance_action_t tap_dance_actions[];
+extern tap_dance_action_t tap_dance_actions[];
-void reset_tap_dance(qk_tap_dance_state_t *state);
+void reset_tap_dance(tap_dance_state_t *state);
/* To be used internally */
@@ -85,13 +85,13 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record);
bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
void tap_dance_task(void);
-void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data);
+void tap_dance_pair_on_each_tap(tap_dance_state_t *state, void *user_data);
+void tap_dance_pair_finished(tap_dance_state_t *state, void *user_data);
+void tap_dance_pair_reset(tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data);
+void tap_dance_dual_role_on_each_tap(tap_dance_state_t *state, void *user_data);
+void tap_dance_dual_role_finished(tap_dance_state_t *state, void *user_data);
+void tap_dance_dual_role_reset(tap_dance_state_t *state, void *user_data);
#else
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c
index 646471bc4d..3aa09d5948 100644
--- a/quantum/process_keycode/process_ucis.c
+++ b/quantum/process_keycode/process_ucis.c
@@ -19,20 +19,20 @@
#include "keycode.h"
#include "wait.h"
-qk_ucis_state_t qk_ucis_state;
+ucis_state_t ucis_state;
-void qk_ucis_start(void) {
- qk_ucis_state.count = 0;
- qk_ucis_state.in_progress = true;
+void ucis_start(void) {
+ ucis_state.count = 0;
+ ucis_state.in_progress = true;
- qk_ucis_start_user();
+ ucis_start_user();
}
-__attribute__((weak)) void qk_ucis_start_user(void) {
+__attribute__((weak)) void ucis_start_user(void) {
register_unicode(0x2328); // ⌨
}
-__attribute__((weak)) void qk_ucis_success(uint8_t symbol_index) {}
+__attribute__((weak)) void ucis_success(uint8_t symbol_index) {}
static bool is_uni_seq(char *seq) {
uint8_t i;
@@ -43,20 +43,20 @@ static bool is_uni_seq(char *seq) {
} else {
keycode = seq[i] - 'a' + KC_A;
}
- if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != keycode) {
+ if (i > ucis_state.count || ucis_state.codes[i] != keycode) {
return false;
}
}
- return qk_ucis_state.codes[i] == KC_ENTER || qk_ucis_state.codes[i] == KC_SPACE;
+ return ucis_state.codes[i] == KC_ENTER || ucis_state.codes[i] == KC_SPACE;
}
-__attribute__((weak)) void qk_ucis_symbol_fallback(void) {
- for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
- tap_code(qk_ucis_state.codes[i]);
+__attribute__((weak)) void ucis_symbol_fallback(void) {
+ for (uint8_t i = 0; i < ucis_state.count - 1; i++) {
+ tap_code(ucis_state.codes[i]);
}
}
-__attribute__((weak)) void qk_ucis_cancel(void) {}
+__attribute__((weak)) void ucis_cancel(void) {}
void register_ucis(const uint32_t *code_points) {
for (int i = 0; i < UCIS_MAX_CODE_POINTS && code_points[i]; i++) {
@@ -65,38 +65,38 @@ void register_ucis(const uint32_t *code_points) {
}
bool process_ucis(uint16_t keycode, keyrecord_t *record) {
- if (!qk_ucis_state.in_progress || !record->event.pressed) {
+ if (!ucis_state.in_progress || !record->event.pressed) {
return true;
}
bool special = keycode == KC_SPACE || keycode == KC_ENTER || keycode == KC_ESCAPE || keycode == KC_BACKSPACE;
- if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) {
+ if (ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) {
return false;
}
- qk_ucis_state.codes[qk_ucis_state.count] = keycode;
- qk_ucis_state.count++;
+ ucis_state.codes[ucis_state.count] = keycode;
+ ucis_state.count++;
switch (keycode) {
case KC_BACKSPACE:
- if (qk_ucis_state.count >= 2) {
- qk_ucis_state.count -= 2;
+ if (ucis_state.count >= 2) {
+ ucis_state.count -= 2;
return true;
} else {
- qk_ucis_state.count--;
+ ucis_state.count--;
return false;
}
case KC_SPACE:
case KC_ENTER:
case KC_ESCAPE:
- for (uint8_t i = 0; i < qk_ucis_state.count; i++) {
+ for (uint8_t i = 0; i < ucis_state.count; i++) {
tap_code(KC_BACKSPACE);
}
if (keycode == KC_ESCAPE) {
- qk_ucis_state.in_progress = false;
- qk_ucis_cancel();
+ ucis_state.in_progress = false;
+ ucis_cancel();
return false;
}
@@ -110,12 +110,12 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) {
}
}
if (symbol_found) {
- qk_ucis_success(i);
+ ucis_success(i);
} else {
- qk_ucis_symbol_fallback();
+ ucis_symbol_fallback();
}
- qk_ucis_state.in_progress = false;
+ ucis_state.in_progress = false;
return false;
default:
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h
index 3de0707762..54eb9413d4 100644
--- a/quantum/process_keycode/process_ucis.h
+++ b/quantum/process_keycode/process_ucis.h
@@ -31,15 +31,15 @@
typedef struct {
char * symbol;
uint32_t code_points[UCIS_MAX_CODE_POINTS];
-} qk_ucis_symbol_t;
+} ucis_symbol_t;
typedef struct {
uint8_t count;
uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
bool in_progress : 1;
-} qk_ucis_state_t;
+} ucis_state_t;
-extern qk_ucis_state_t qk_ucis_state;
+extern ucis_state_t ucis_state;
// clang-format off
@@ -53,12 +53,12 @@ extern qk_ucis_state_t qk_ucis_state;
// clang-format on
-extern const qk_ucis_symbol_t ucis_symbol_table[];
+extern const ucis_symbol_t ucis_symbol_table[];
-void qk_ucis_start(void);
-void qk_ucis_start_user(void);
-void qk_ucis_symbol_fallback(void);
-void qk_ucis_success(uint8_t symbol_index);
+void ucis_start(void);
+void ucis_start_user(void);
+void ucis_symbol_fallback(void);
+void ucis_success(uint8_t symbol_index);
void register_ucis(const uint32_t *code_points);
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 46e8e07212..7693888462 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -68,23 +68,6 @@
|-----------------|-----------------------------------|
*****/
-#ifdef RGBLIGHT_ANIMATIONS
-// for backward compatibility
-# define RGBLIGHT_EFFECT_BREATHING
-# define RGBLIGHT_EFFECT_RAINBOW_MOOD
-# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
-# define RGBLIGHT_EFFECT_SNAKE
-# define RGBLIGHT_EFFECT_KNIGHT
-# define RGBLIGHT_EFFECT_CHRISTMAS
-# define RGBLIGHT_EFFECT_STATIC_GRADIENT
-# define RGBLIGHT_EFFECT_RGB_TEST
-# define RGBLIGHT_EFFECT_ALTERNATING
-#endif
-
-#ifdef RGBLIGHT_STATIC_PATTERNS
-# define RGBLIGHT_EFFECT_STATIC_GRADIENT
-#endif
-
// clang-format off
// check dynamic animation effects chose ?