summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c39
-rw-r--r--quantum/action_code.h24
-rw-r--r--quantum/action_layer.c2
-rw-r--r--quantum/action_tapping.c133
-rw-r--r--quantum/action_tapping.h1
-rw-r--r--quantum/action_util.c12
-rw-r--r--quantum/action_util.h3
-rw-r--r--quantum/audio/audio.c5
-rw-r--r--quantum/audio/audio.h10
-rw-r--r--quantum/basic_profiling.h69
-rw-r--r--quantum/bootmagic/magic.c2
-rw-r--r--quantum/color.c4
-rw-r--r--quantum/command.c1
-rw-r--r--quantum/config_common.h19
-rw-r--r--quantum/digitizer.h8
-rw-r--r--quantum/dynamic_keymap.c2
-rw-r--r--quantum/encoder.c28
-rw-r--r--quantum/joystick.h4
-rw-r--r--quantum/keyboard.c64
-rw-r--r--quantum/keyboard.h68
-rw-r--r--quantum/keycode.h20
-rw-r--r--quantum/keymap.h23
-rw-r--r--quantum/keymap_common.c3
-rw-r--r--quantum/keymap_common.h10
-rw-r--r--quantum/keymap_extras/keymap_belgian.h2
-rw-r--r--quantum/keymap_extras/keymap_bepo.h2
-rw-r--r--quantum/keymap_extras/keymap_brazilian_abnt2.h2
-rw-r--r--quantum/keymap_extras/keymap_canadian_multilingual.h2
-rw-r--r--quantum/keymap_extras/keymap_colemak.h2
-rw-r--r--quantum/keymap_extras/keymap_croatian.h2
-rw-r--r--quantum/keymap_extras/keymap_czech.h2
-rw-r--r--quantum/keymap_extras/keymap_danish.h2
-rw-r--r--quantum/keymap_extras/keymap_dvorak.h2
-rw-r--r--quantum/keymap_extras/keymap_dvorak_fr.h2
-rw-r--r--quantum/keymap_extras/keymap_dvorak_programmer.h2
-rw-r--r--quantum/keymap_extras/keymap_estonian.h2
-rw-r--r--quantum/keymap_extras/keymap_finnish.h2
-rw-r--r--quantum/keymap_extras/keymap_french.h2
-rw-r--r--quantum/keymap_extras/keymap_french_afnor.h2
-rw-r--r--quantum/keymap_extras/keymap_french_mac_iso.h2
-rw-r--r--quantum/keymap_extras/keymap_german.h2
-rw-r--r--quantum/keymap_extras/keymap_german_mac_iso.h2
-rw-r--r--quantum/keymap_extras/keymap_greek.h2
-rw-r--r--quantum/keymap_extras/keymap_hebrew.h2
-rw-r--r--quantum/keymap_extras/keymap_hungarian.h2
-rw-r--r--quantum/keymap_extras/keymap_icelandic.h2
-rw-r--r--quantum/keymap_extras/keymap_irish.h2
-rw-r--r--quantum/keymap_extras/keymap_italian.h2
-rw-r--r--quantum/keymap_extras/keymap_italian_mac_ansi.h2
-rw-r--r--quantum/keymap_extras/keymap_italian_mac_iso.h2
-rw-r--r--quantum/keymap_extras/keymap_japanese.h2
-rw-r--r--quantum/keymap_extras/keymap_korean.h2
-rw-r--r--quantum/keymap_extras/keymap_latvian.h2
-rw-r--r--quantum/keymap_extras/keymap_lithuanian_azerty.h2
-rw-r--r--quantum/keymap_extras/keymap_lithuanian_qwerty.h2
-rw-r--r--quantum/keymap_extras/keymap_neo2.h2
-rw-r--r--quantum/keymap_extras/keymap_nordic.h2
-rw-r--r--quantum/keymap_extras/keymap_norman.h2
-rw-r--r--quantum/keymap_extras/keymap_norwegian.h2
-rw-r--r--quantum/keymap_extras/keymap_plover.h2
-rw-r--r--quantum/keymap_extras/keymap_plover_dvorak.h2
-rw-r--r--quantum/keymap_extras/keymap_polish.h2
-rw-r--r--quantum/keymap_extras/keymap_portuguese.h2
-rw-r--r--quantum/keymap_extras/keymap_portuguese_mac_iso.h2
-rw-r--r--quantum/keymap_extras/keymap_romanian.h2
-rw-r--r--quantum/keymap_extras/keymap_russian.h2
-rw-r--r--quantum/keymap_extras/keymap_serbian.h2
-rw-r--r--quantum/keymap_extras/keymap_serbian_latin.h2
-rw-r--r--quantum/keymap_extras/keymap_slovak.h2
-rw-r--r--quantum/keymap_extras/keymap_slovenian.h2
-rw-r--r--quantum/keymap_extras/keymap_spanish.h2
-rw-r--r--quantum/keymap_extras/keymap_spanish_dvorak.h2
-rw-r--r--quantum/keymap_extras/keymap_steno.h2
-rw-r--r--quantum/keymap_extras/keymap_swedish.h2
-rw-r--r--quantum/keymap_extras/keymap_swedish_mac_ansi.h2
-rw-r--r--quantum/keymap_extras/keymap_swedish_mac_iso.h2
-rw-r--r--quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h2
-rw-r--r--quantum/keymap_extras/keymap_swedish_pro_mac_iso.h2
-rw-r--r--quantum/keymap_extras/keymap_swiss_de.h2
-rw-r--r--quantum/keymap_extras/keymap_swiss_fr.h2
-rw-r--r--quantum/keymap_extras/keymap_turkish_f.h2
-rw-r--r--quantum/keymap_extras/keymap_turkish_q.h2
-rw-r--r--quantum/keymap_extras/keymap_uk.h2
-rw-r--r--quantum/keymap_extras/keymap_ukrainian.h2
-rw-r--r--quantum/keymap_extras/keymap_us.h2
-rw-r--r--quantum/keymap_extras/keymap_us_extended.h2
-rw-r--r--quantum/keymap_extras/keymap_us_international.h2
-rw-r--r--quantum/keymap_extras/keymap_us_international_linux.h2
-rw-r--r--quantum/keymap_extras/keymap_workman.h2
-rw-r--r--quantum/keymap_extras/keymap_workman_zxcvm.h2
-rw-r--r--quantum/keymap_introspection.h1
-rw-r--r--quantum/leader.h4
-rw-r--r--quantum/midi/midi.c5
-rw-r--r--quantum/modifiers.h54
-rw-r--r--quantum/os_detection.c45
-rw-r--r--quantum/os_detection.h4
-rw-r--r--quantum/painter/lvgl/qp_lvgl.c2
-rw-r--r--quantum/painter/qff.h10
-rw-r--r--quantum/painter/qp.c22
-rw-r--r--quantum/painter/qp.h36
-rw-r--r--quantum/painter/qp_comms.c16
-rw-r--r--quantum/painter/qp_draw.h14
-rw-r--r--quantum/painter/qp_draw_circle.c2
-rw-r--r--quantum/painter/qp_draw_codec.c22
-rw-r--r--quantum/painter/qp_draw_core.c20
-rw-r--r--quantum/painter/qp_draw_ellipse.c2
-rw-r--r--quantum/painter/qp_draw_image.c26
-rw-r--r--quantum/painter/qp_draw_text.c56
-rw-r--r--quantum/painter/qp_internal.c96
-rw-r--r--quantum/painter/qp_internal_driver.h29
-rw-r--r--quantum/painter/qp_stream.h4
-rw-r--r--quantum/painter/rules.mk1
-rw-r--r--quantum/pointing_device/pointing_device.c28
-rw-r--r--quantum/pointing_device/pointing_device.h7
-rw-r--r--quantum/pointing_device/pointing_device_drivers.c22
-rw-r--r--quantum/process_keycode/process_auto_shift.c14
-rw-r--r--quantum/process_keycode/process_caps_word.c66
-rw-r--r--quantum/process_keycode/process_combo.c11
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c10
-rw-r--r--quantum/process_keycode/process_dynamic_macro.h2
-rw-r--r--quantum/process_keycode/process_steno.c6
-rw-r--r--quantum/programmable_button.h4
-rw-r--r--quantum/quantum.h7
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c9
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h18
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c1
-rw-r--r--quantum/rgblight/rgblight.c12
-rw-r--r--quantum/rgblight/rgblight.h5
-rw-r--r--quantum/secure.h13
-rw-r--r--quantum/send_string/send_string.h6
-rw-r--r--quantum/split_common/transaction_id_define.h8
-rw-r--r--quantum/split_common/transactions.c63
-rw-r--r--quantum/split_common/transport.h21
-rw-r--r--quantum/velocikey.c8
134 files changed, 968 insertions, 530 deletions
diff --git a/quantum/action.c b/quantum/action.c
index 7d3f40a950..dadb88e9df 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host.h"
#include "keycode.h"
#include "keyboard.h"
-#include "keymap.h"
#include "mousekey.h"
#include "programmable_button.h"
#include "command.h"
@@ -30,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action.h"
#include "wait.h"
#include "keycode_config.h"
+#include "debug.h"
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
@@ -39,6 +39,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "pointing_device.h"
#endif
+#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) && defined(SWAP_HANDS_ENABLE)
+# include "encoder.h"
+#endif
+
int tp_buttons;
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
@@ -435,39 +439,32 @@ void process_action(keyrecord_t *record, action_t action) {
} else {
if (event.pressed) {
if (tap_count == 0) {
+ // Not a tap, but a hold: register the held mod
ac_dprintf("MODS_TAP: Oneshot: 0\n");
- register_mods(mods | get_oneshot_mods());
+ register_mods(mods);
} else if (tap_count == 1) {
ac_dprintf("MODS_TAP: Oneshot: start\n");
- set_oneshot_mods(mods | get_oneshot_mods());
+ add_oneshot_mods(mods);
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
ac_dprintf("MODS_TAP: Toggling oneshot");
register_mods(mods);
- clear_oneshot_mods();
- set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
+ del_oneshot_mods(mods);
+ add_oneshot_locked_mods(mods);
# endif
- } else {
- register_mods(mods | get_oneshot_mods());
}
} else {
if (tap_count == 0) {
- clear_oneshot_mods();
+ // Release hold: unregister the held mod and its variants
unregister_mods(mods);
- } else if (tap_count == 1) {
- // Retain Oneshot mods
+ del_oneshot_mods(mods);
+ del_oneshot_locked_mods(mods);
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
- if (mods & get_mods()) {
- unregister_mods(mods);
- clear_oneshot_mods();
- set_oneshot_locked_mods(~mods & get_oneshot_locked_mods());
- }
- } else if (tap_count == ONESHOT_TAP_TOGGLE) {
- // Toggle Oneshot Layer
-# endif
- } else {
+ } else if (tap_count == 1 && (mods & get_mods())) {
unregister_mods(mods);
- clear_oneshot_mods();
+ del_oneshot_mods(mods);
+ del_oneshot_locked_mods(mods);
+# endif
}
}
}
@@ -487,7 +484,7 @@ void process_action(keyrecord_t *record, action_t action) {
default:
if (event.pressed) {
if (tap_count > 0) {
-# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
if (
# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
diff --git a/quantum/action_code.h b/quantum/action_code.h
index 58d929016d..d9a575b518 100644
--- a/quantum/action_code.h
+++ b/quantum/action_code.h
@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
+#include "modifiers.h"
+
/** \brief Action codes
*
* 16bit code: action_kind(4bit) + action_parameter(12bit)
@@ -160,28 +162,6 @@ typedef union {
#define ACTION_TRANSPARENT 1
#define ACTION(kind, param) ((kind) << 12 | (param))
-/** \brief Key Actions
- *
- * Mod bits: 43210
- * bit 0 ||||+- Control
- * bit 1 |||+-- Shift
- * bit 2 ||+--- Alt
- * bit 3 |+---- Gui
- * bit 4 +----- LR flag(Left:0, Right:1)
- */
-enum mods_bit {
- MOD_LCTL = 0x01,
- MOD_LSFT = 0x02,
- MOD_LALT = 0x04,
- MOD_LGUI = 0x08,
- MOD_RCTL = 0x11,
- MOD_RSFT = 0x12,
- MOD_RALT = 0x14,
- MOD_RGUI = 0x18,
-};
-#define MOD_HYPR (MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI)
-#define MOD_MEH (MOD_LCTL | MOD_LSFT | MOD_LALT)
-
enum mods_codes {
MODS_ONESHOT = 0x00,
MODS_TAP_TOGGLE = 0x01,
diff --git a/quantum/action_layer.c b/quantum/action_layer.c
index 789a7fddeb..7c09a5bd1e 100644
--- a/quantum/action_layer.c
+++ b/quantum/action_layer.c
@@ -2,8 +2,8 @@
#include <stdint.h>
#include "keyboard.h"
-#include "keymap.h"
#include "action.h"
+#include "encoder.h"
#include "util.h"
#include "action_layer.h"
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index 5a38bf96e3..362b15105c 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -11,20 +11,14 @@
# 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
+# elif defined(IGNORE_MOD_TAP_INTERRUPT)
+# error "IGNORE_MOD_TAP_INTERRUPT is no longer necessary as it is now the default behavior of mod-tap keys. Please remove it from your config."
# 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)))
# ifndef COMBO_ENABLE
-# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)))
+# define IS_TAPPING_RECORD(r) (KEYEQ(tapping_key.event.key, (r->event.key)))
# else
-# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode)
+# define IS_TAPPING_RECORD(r) (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))
@@ -96,7 +90,7 @@ void action_tapping_process(keyrecord_t record) {
ac_dprintf("OVERFLOW: CLEAR ALL STATES\n");
clear_keyboard();
waiting_buffer_clear();
- tapping_key = (keyrecord_t){};
+ tapping_key = (keyrecord_t){0};
}
}
@@ -123,7 +117,7 @@ void action_tapping_process(keyrecord_t record) {
* conditional uses of it are hidden inside macros named TAP_...
*/
# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
-# define TAP_DEFINE_KEYCODE uint16_t tapping_keycode = get_record_keycode(&tapping_key, false)
+# define TAP_DEFINE_KEYCODE const uint16_t tapping_keycode = get_record_keycode(&tapping_key, false)
# else
# define TAP_DEFINE_KEYCODE
# endif
@@ -162,12 +156,6 @@ void action_tapping_process(keyrecord_t record) {
# 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.
@@ -175,12 +163,37 @@ 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;
+ const keyevent_t event = keyp->event;
+
+ // state machine is in the "reset" state, no tapping key is to be
+ // processed
+ if (IS_NOEVENT(tapping_key.event) && IS_EVENT(event)) {
+ if (event.pressed && is_tap_record(keyp)) {
+ // the currently pressed key is a tapping key, therefore transition
+ // into the "pressed" tapping key state
+ ac_dprintf("Tapping: Start(Press tap key).\n");
+ tapping_key = *keyp;
+ process_record_tap_hint(&tapping_key);
+ waiting_buffer_scan_tap();
+ debug_tapping_key();
+ return true;
+ } else {
+ // the current key is just a regular key, pass it on for regular
+ // processing
+ process_record(keyp);
+ return true;
+ }
+ }
+
TAP_DEFINE_KEYCODE;
- // if tapping
- if (IS_TAPPING_PRESSED()) {
+ // process "pressed" tapping key state
+ if (tapping_key.event.pressed) {
if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
+ if (IS_NOEVENT(event)) {
+ // early return for tick events
+ return true;
+ }
if (tapping_key.tap.count == 0) {
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
@@ -204,7 +217,7 @@ bool process_tapping(keyrecord_t *keyp) {
// clang-format off
else if (
(
- IS_RELEASED(event) && waiting_buffer_typed(event) &&
+ !event.pressed && waiting_buffer_typed(event) &&
TAP_GET_PERMISSIVE_HOLD
)
// Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT
@@ -217,13 +230,12 @@ bool process_tapping(keyrecord_t *keyp) {
(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.
+ // Makes Retro Shift ignore the default behavior of
+ // MTs and LTs on nested taps below TAPPING_TERM or RETRO_SHIFT
|| (
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)
+ && !event.pressed && waiting_buffer_typed(event)
)
)
)
@@ -231,7 +243,7 @@ bool process_tapping(keyrecord_t *keyp) {
// clang-format on
ac_dprintf("Tapping: End. No tap. Interfered by typing key\n");
process_record(&tapping_key);
- tapping_key = (keyrecord_t){};
+ tapping_key = (keyrecord_t){0};
debug_tapping_key();
// enqueue
return false;
@@ -240,7 +252,7 @@ bool process_tapping(keyrecord_t *keyp) {
* 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)) {
+ else if (!event.pressed && !waiting_buffer_typed(event)) {
// Modifier/Layer should be retained till end of this tapping.
action_t action = layer_switch_get_action(event.key);
switch (action.kind.id) {
@@ -276,7 +288,7 @@ bool process_tapping(keyrecord_t *keyp) {
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){};
+ tapping_key = (keyrecord_t){0};
debug_tapping_key();
// enqueue
return false;
@@ -304,6 +316,7 @@ bool process_tapping(keyrecord_t *keyp) {
.event.key = tapping_key.event.key,
.event.time = event.time,
.event.pressed = false,
+ .event.type = tapping_key.event.type,
# ifdef COMBO_ENABLE
.keycode = tapping_key.keycode,
# endif
@@ -316,9 +329,7 @@ bool process_tapping(keyrecord_t *keyp) {
debug_tapping_key();
return true;
} else {
- if (IS_EVENT(event)) {
- ac_dprintf("Tapping: key event while last tap(>0).\n");
- }
+ ac_dprintf("Tapping: key event while last tap(>0).\n");
process_record(keyp);
return true;
}
@@ -331,15 +342,18 @@ bool process_tapping(keyrecord_t *keyp) {
debug_event(event);
ac_dprintf("\n");
process_record(&tapping_key);
- tapping_key = (keyrecord_t){};
+ tapping_key = (keyrecord_t){0};
debug_tapping_key();
return false;
} else {
+ if (IS_NOEVENT(event)) {
+ return true;
+ }
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
ac_dprintf("Tapping: End. last timeout tap release(>0).");
keyp->tap = tapping_key.tap;
process_record(keyp);
- tapping_key = (keyrecord_t){};
+ tapping_key = (keyrecord_t){0};
return true;
} else if (is_tap_record(keyp) && event.pressed) {
if (tapping_key.tap.count > 1) {
@@ -350,6 +364,7 @@ bool process_tapping(keyrecord_t *keyp) {
.event.key = tapping_key.event.key,
.event.time = event.time,
.event.pressed = false,
+ .event.type = tapping_key.event.type,
# ifdef COMBO_ENABLE
.keycode = tapping_key.keycode,
# endif
@@ -362,16 +377,20 @@ bool process_tapping(keyrecord_t *keyp) {
debug_tapping_key();
return true;
} else {
- if (IS_EVENT(event)) {
- ac_dprintf("Tapping: key event while last timeout tap(>0).\n");
- }
+ ac_dprintf("Tapping: key event while last timeout tap(>0).\n");
process_record(keyp);
return true;
}
}
}
- } else if (IS_TAPPING_RELEASED()) {
+ }
+ // process "released" tapping key state
+ else {
if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
+ if (IS_NOEVENT(event)) {
+ // early return for tick events
+ return true;
+ }
if (event.pressed) {
if (IS_TAPPING_RECORD(keyp)) {
if (WITHIN_QUICK_TAP_TERM(event) && !tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
@@ -402,35 +421,20 @@ bool process_tapping(keyrecord_t *keyp) {
return true;
}
} else {
- if (IS_EVENT(event)) ac_dprintf("Tapping: other key just after tap.\n");
+ ac_dprintf("Tapping: other key just after tap.\n");
process_record(keyp);
return true;
}
} else {
- // FIX: process_action here?
- // timeout. no sequential tap.
+ // Timeout - reset state machine.
ac_dprintf("Tapping: End(Timeout after releasing last tap): ");
debug_event(event);
ac_dprintf("\n");
- tapping_key = (keyrecord_t){};
+ tapping_key = (keyrecord_t){0};
debug_tapping_key();
return false;
}
}
- // not tapping state
- else {
- if (event.pressed && is_tap_record(keyp)) {
- ac_dprintf("Tapping: Start(Press tap key).\n");
- tapping_key = *keyp;
- process_record_tap_hint(&tapping_key);
- waiting_buffer_scan_tap();
- debug_tapping_key();
- return true;
- } else {
- process_record(keyp);
- return true;
- }
- }
}
/** \brief Waiting buffer enq
@@ -493,15 +497,18 @@ __attribute__((unused)) bool waiting_buffer_has_anykey_pressed(void) {
* FIXME: Needs docs
*/
void waiting_buffer_scan_tap(void) {
- // tapping already is settled
- if (tapping_key.tap.count > 0) return;
- // invalid state: tapping_key released && tap.count == 0
- if (!tapping_key.event.pressed) return;
+ // early return if:
+ // - tapping already is settled
+ // - invalid state: tapping_key released && tap.count == 0
+ if ((tapping_key.tap.count > 0) || !tapping_key.event.pressed) {
+ return;
+ }
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
- if (IS_TAPPING_KEY(waiting_buffer[i].event.key) && !waiting_buffer[i].event.pressed && WITHIN_TAPPING_TERM(waiting_buffer[i].event)) {
- tapping_key.tap.count = 1;
- waiting_buffer[i].tap.count = 1;
+ keyrecord_t *candidate = &waiting_buffer[i];
+ if (IS_EVENT(candidate->event) && KEYEQ(candidate->event.key, tapping_key.event.key) && !candidate->event.pressed && WITHIN_TAPPING_TERM(candidate->event)) {
+ tapping_key.tap.count = 1;
+ candidate->tap.count = 1;
process_record(&tapping_key);
ac_dprintf("waiting_buffer_scan_tap: found at [%u]\n", i);
diff --git a/quantum/action_tapping.h b/quantum/action_tapping.h
index 6099d80d6d..6b518b8298 100644
--- a/quantum/action_tapping.h
+++ b/quantum/action_tapping.h
@@ -43,7 +43,6 @@ void action_tapping_process(keyrecord_t record);
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_retro_tapping(uint16_t keycode, keyrecord_t *record);
bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/action_util.c b/quantum/action_util.c
index 7f7d32887b..034c2ecaae 100644
--- a/quantum/action_util.c
+++ b/quantum/action_util.c
@@ -46,6 +46,12 @@ static uint8_t oneshot_locked_mods = 0;
uint8_t get_oneshot_locked_mods(void) {
return oneshot_locked_mods;
}
+void add_oneshot_locked_mods(uint8_t mods) {
+ if ((oneshot_locked_mods & mods) != mods) {
+ oneshot_locked_mods |= mods;
+ oneshot_locked_mods_changed_kb(oneshot_locked_mods);
+ }
+}
void set_oneshot_locked_mods(uint8_t mods) {
if (mods != oneshot_locked_mods) {
oneshot_locked_mods = mods;
@@ -58,6 +64,12 @@ void clear_oneshot_locked_mods(void) {
oneshot_locked_mods_changed_kb(oneshot_locked_mods);
}
}
+void del_oneshot_locked_mods(uint8_t mods) {
+ if (oneshot_locked_mods & mods) {
+ oneshot_locked_mods &= ~mods;
+ oneshot_locked_mods_changed_kb(oneshot_locked_mods);
+ }
+}
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
static uint16_t oneshot_time = 0;
bool has_oneshot_mods_timed_out(void) {
diff --git a/quantum/action_util.h b/quantum/action_util.h
index 6f1f09c4bd..02f6e9e6df 100644
--- a/quantum/action_util.h
+++ b/quantum/action_util.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include "report.h"
+#include "modifiers.h"
#ifdef __cplusplus
extern "C" {
@@ -64,8 +65,10 @@ void clear_oneshot_mods(void);
bool has_oneshot_mods_timed_out(void);
uint8_t get_oneshot_locked_mods(void);
+void add_oneshot_locked_mods(uint8_t mods);
void set_oneshot_locked_mods(uint8_t mods);
void clear_oneshot_locked_mods(void);
+void del_oneshot_locked_mods(uint8_t mods);
typedef enum { ONESHOT_PRESSED = 0b01, ONESHOT_OTHER_KEY_PRESSED = 0b10, ONESHOT_START = 0b11, ONESHOT_TOGGLED = 0b100 } oneshot_fullfillment_t;
void set_oneshot_layer(uint8_t layer, uint8_t state);
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index ca78a483ad..2570ad9cd1 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -18,6 +18,7 @@
#include "eeconfig.h"
#include "timer.h"
#include "wait.h"
+#include "util.h"
/* audio system:
*
@@ -112,6 +113,10 @@ static bool audio_initialized = false;
static bool audio_driver_stopped = true;
audio_config_t audio_config;
+void eeconfig_update_audio_current(void) {
+ eeconfig_update_audio(audio_config.raw);
+}
+
void audio_init(void) {
if (audio_initialized) {
return;
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index fe23cf3ed1..497f3dafd0 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -43,11 +43,6 @@ typedef union {
};
} audio_config_t;
-// AVR/LUFA has a MIN, arm/chibios does not
-#ifndef MIN
-# define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
/*
* a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre
* https://en.wikipedia.org/wiki/Musical_tone
@@ -64,6 +59,11 @@ typedef struct {
// public interface
/**
+ * @brief Save the current choices to the eeprom
+ */
+void eeconfig_update_audio_current(void);
+
+/**
* @brief one-time initialization called by quantum/quantum.c
* @details usually done lazy, when some tones are to be played
*
diff --git a/quantum/basic_profiling.h b/quantum/basic_profiling.h
new file mode 100644
index 0000000000..d371acd6f0
--- /dev/null
+++ b/quantum/basic_profiling.h
@@ -0,0 +1,69 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+/*
+ This API allows for basic profiling information to be printed out over console.
+
+ Usage example:
+
+ #include "basic_profiling.h"
+
+ // Original code:
+ matrix_task();
+
+ // Delete the original, replace with the following (variant 1, automatic naming):
+ PROFILE_CALL(1000, matrix_task());
+
+ // Delete the original, replace with the following (variant 2, explicit naming):
+ PROFILE_CALL_NAMED(1000, "matrix_task", {
+ matrix_task();
+ });
+*/
+
+#if defined(PROTOCOL_LUFA) || defined(PROTOCOL_VUSB)
+# define TIMESTAMP_GETTER TCNT0
+#elif defined(PROTOCOL_CHIBIOS)
+# define TIMESTAMP_GETTER chSysGetRealtimeCounterX()
+#elif defined(PROTOCOL_ARM_ATSAM)
+# error arm_atsam not currently supported
+#else
+# error Unknown protocol in use
+#endif
+
+#ifndef CONSOLE_ENABLE
+// Can't do anything if we don't have console output enabled.
+# define PROFILE_CALL_NAMED(count, name, call) \
+ do { \
+ } while (0)
+#else
+# define PROFILE_CALL_NAMED(count, name, call) \
+ do { \
+ static uint64_t inner_sum = 0; \
+ static uint64_t outer_sum = 0; \
+ uint32_t start_ts; \
+ static uint32_t end_ts; \
+ static uint32_t write_location = 0; \
+ start_ts = TIMESTAMP_GETTER; \
+ if (write_location > 0) { \
+ outer_sum += start_ts - end_ts; \
+ } \
+ do { \
+ call; \
+ } while (0); \
+ end_ts = TIMESTAMP_GETTER; \
+ inner_sum += end_ts - start_ts; \
+ ++write_location; \
+ if (write_location >= ((uint32_t)count)) { \
+ uint32_t inner_avg = inner_sum / (((uint32_t)count) - 1); \
+ uint32_t outer_avg = outer_sum / (((uint32_t)count) - 1); \
+ dprintf("%s -- Percentage time spent: %d%%\n", (name), (int)(inner_avg * 100 / (inner_avg + outer_avg))); \
+ inner_sum = 0; \
+ outer_sum = 0; \
+ write_location = 0; \
+ } \
+ } while (0)
+
+#endif // CONSOLE_ENABLE
+
+#define PROFILE_CALL(count, call) PROFILE_CALL_NAMED(count, #call, call)
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c
index f1cb11c395..d68df3fa58 100644
--- a/quantum/bootmagic/magic.c
+++ b/quantum/bootmagic/magic.c
@@ -19,7 +19,7 @@
#include "matrix.h"
#include "bootloader.h"
#include "debug.h"
-#include "keymap.h"
+#include "keycode_config.h"
#include "host.h"
#include "action_layer.h"
#include "eeconfig.h"
diff --git a/quantum/color.c b/quantum/color.c
index c80078dbf2..767155c9db 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -17,6 +17,7 @@
#include "color.h"
#include "led_tables.h"
#include "progmem.h"
+#include "util.h"
RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
RGB rgb;
@@ -109,9 +110,6 @@ RGB hsv_to_rgb_nocie(HSV hsv) {
}
#ifdef RGBW
-# ifndef MIN
-# define MIN(a, b) ((a) < (b) ? (a) : (b))
-# endif
void convert_rgb_to_rgbw(LED_TYPE *led) {
// Determine lowest value in all three colors, put that into
// the white channel and then shift all colors by that amount
diff --git a/quantum/command.c b/quantum/command.c
index 84757b9b01..aa64b75064 100644
--- a/quantum/command.c
+++ b/quantum/command.c
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wait.h"
#include "keycode.h"
#include "host.h"
-#include "keymap.h"
#include "print.h"
#include "debug.h"
#include "util.h"
diff --git a/quantum/config_common.h b/quantum/config_common.h
deleted file mode 100644
index 6c70b00b53..0000000000
--- a/quantum/config_common.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2015-2018 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/>.
- */
-
-#pragma once
-
-#pragma message("'config_common.h' should no longer be included!")
diff --git a/quantum/digitizer.h b/quantum/digitizer.h
index b826ba8ac8..6a9c24ed34 100644
--- a/quantum/digitizer.h
+++ b/quantum/digitizer.h
@@ -13,17 +13,15 @@
* 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 "quantum.h"
+#pragma once
#include <stdbool.h>
-#include <stdint.h>
/**
- * \defgroup digitizer
+ * \file
*
- * HID Digitizer
+ * defgroup digitizer HID Digitizer
* \{
*/
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index c406be4585..90a0f20838 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "keymap.h" // to get keymaps[][][]
+#include "keymap_introspection.h" // to get keymaps[][][]
#include "eeprom.h"
#include "progmem.h" // to read default from flash
#include "quantum.h" // for send_string()
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 3aee340249..1046fe6cc3 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -77,7 +77,29 @@ __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) {
}
__attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) {
- return encoder_update_user(index, clockwise);
+ bool res = encoder_update_user(index, clockwise);
+#if !defined(ENCODER_TESTS)
+ if (res) {
+ if (clockwise) {
+# if defined(EXTRAKEY_ENABLE)
+ tap_code_delay(KC_VOLU, 10);
+# elif defined(MOUSEKEY_ENABLE)
+ tap_code_delay(KC_MS_WH_UP, 10);
+# else
+ tap_code_delay(KC_PGDN, 10);
+# endif
+ } else {
+# if defined(EXTRAKEY_ENABLE)
+ tap_code_delay(KC_VOLD, 10);
+# elif defined(MOUSEKEY_ENABLE)
+ tap_code_delay(KC_MS_WH_DOWN, 10);
+# else
+ tap_code_delay(KC_PGUP, 10);
+# endif
+ }
+ }
+#endif // ENCODER_TESTS
+ return res;
}
__attribute__((weak)) bool should_process_encoder(void) {
@@ -147,12 +169,12 @@ void encoder_init(void) {
#ifdef ENCODER_MAP_ENABLE
static void encoder_exec_mapping(uint8_t index, bool clockwise) {
// The delays below cater for Windows and its wonderful requirements.
- action_exec(clockwise ? ENCODER_CW_EVENT(index, true) : ENCODER_CCW_EVENT(index, true));
+ action_exec(clockwise ? MAKE_ENCODER_CW_EVENT(index, true) : MAKE_ENCODER_CCW_EVENT(index, true));
# if ENCODER_MAP_KEY_DELAY > 0
wait_ms(ENCODER_MAP_KEY_DELAY);
# endif // ENCODER_MAP_KEY_DELAY > 0
- action_exec(clockwise ? ENCODER_CW_EVENT(index, false) : ENCODER_CCW_EVENT(index, false));
+ action_exec(clockwise ? MAKE_ENCODER_CW_EVENT(index, false) : MAKE_ENCODER_CCW_EVENT(index, false));
# if ENCODER_MAP_KEY_DELAY > 0
wait_ms(ENCODER_MAP_KEY_DELAY);
# endif // ENCODER_MAP_KEY_DELAY > 0
diff --git a/quantum/joystick.h b/quantum/joystick.h
index 0ac99aa590..5de4ba66c6 100644
--- a/quantum/joystick.h
+++ b/quantum/joystick.h
@@ -22,9 +22,9 @@
#include "gpio.h"
/**
- * \defgroup joystick
+ * \file
*
- * HID Joystick
+ * \defgroup joystick HID Joystick
* \{
*/
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index ec2f2e4496..90f6d6f8da 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quantum.h"
#include "keyboard.h"
#include "matrix.h"
-#include "keymap.h"
+#include "keymap_introspection.h"
#include "magic.h"
#include "host.h"
#include "led.h"
@@ -114,7 +114,7 @@ uint32_t last_input_activity_time(void) {
return last_input_modification_time;
}
uint32_t last_input_activity_elapsed(void) {
- return timer_elapsed32(last_input_modification_time);
+ return sync_timer_elapsed32(last_input_modification_time);
}
static uint32_t last_matrix_modification_time = 0;
@@ -122,10 +122,10 @@ uint32_t last_matrix_activity_time(void) {
return last_matrix_modification_time;
}
uint32_t last_matrix_activity_elapsed(void) {
- return timer_elapsed32(last_matrix_modification_time);
+ return sync_timer_elapsed32(last_matrix_modification_time);
}
void last_matrix_activity_trigger(void) {
- last_matrix_modification_time = last_input_modification_time = timer_read32();
+ last_matrix_modification_time = last_input_modification_time = sync_timer_read32();
}
static uint32_t last_encoder_modification_time = 0;
@@ -133,10 +133,28 @@ uint32_t last_encoder_activity_time(void) {
return last_encoder_modification_time;
}
uint32_t last_encoder_activity_elapsed(void) {
- return timer_elapsed32(last_encoder_modification_time);
+ return sync_timer_elapsed32(last_encoder_modification_time);
}
void last_encoder_activity_trigger(void) {
- last_encoder_modification_time = last_input_modification_time = timer_read32();
+ last_encoder_modification_time = last_input_modification_time = sync_timer_read32();
+}
+
+static uint32_t last_pointing_device_modification_time = 0;
+uint32_t last_pointing_device_activity_time(void) {
+ return last_pointing_device_modification_time;
+}
+uint32_t last_pointing_device_activity_elapsed(void) {
+ return sync_timer_elapsed32(last_pointing_device_modification_time);
+}
+void last_pointing_device_activity_trigger(void) {
+ last_pointing_device_modification_time = last_input_modification_time = sync_timer_read32();
+}
+
+void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp, uint32_t pointing_device_timestamp) {
+ last_matrix_modification_time = matrix_timestamp;
+ last_encoder_modification_time = encoder_timestamp;
+ last_pointing_device_modification_time = pointing_device_timestamp;
+ last_input_modification_time = MAX(matrix_timestamp, MAX(encoder_timestamp, pointing_device_timestamp));
}
// Only enable this if console is enabled to print to
@@ -444,7 +462,7 @@ static inline void generate_tick_event(void) {
static uint16_t last_tick = 0;
const uint16_t now = timer_read();
if (TIMER_DIFF_16(now, last_tick) != 0) {
- action_exec(TICK_EVENT);
+ action_exec(MAKE_TICK_EVENT);
last_tick = now;
}
}
@@ -592,9 +610,10 @@ void quantum_task(void) {
/** \brief Main task that is repeatedly called as fast as possible. */
void keyboard_task(void) {
- const bool matrix_changed = matrix_task();
- if (matrix_changed) {
+ __attribute__((unused)) bool activity_has_occurred = false;
+ if (matrix_task()) {
last_matrix_activity_trigger();
+ activity_has_occurred = true;
}
quantum_task();
@@ -621,9 +640,16 @@ void keyboard_task(void) {
#endif
#ifdef ENCODER_ENABLE
- const bool encoders_changed = encoder_read();
- if (encoders_changed) {
+ if (encoder_read()) {
last_encoder_activity_trigger();
+ activity_has_occurred = true;
+ }
+#endif
+
+#ifdef POINTING_DEVICE_ENABLE
+ if (pointing_device_task()) {
+ last_pointing_device_activity_trigger();
+ activity_has_occurred = true;
}
#endif
@@ -631,11 +657,7 @@ void keyboard_task(void) {
oled_task();
# if OLED_TIMEOUT > 0
// Wake up oled if user is using those fabulous keys or spinning those encoders!
-# ifdef ENCODER_ENABLE
- if (matrix_changed || encoders_changed) oled_on();
-# else
- if (matrix_changed) oled_on();
-# endif
+ if (activity_has_occurred) oled_on();
# endif
#endif
@@ -643,11 +665,7 @@ void keyboard_task(void) {
st7565_task();
# if ST7565_TIMEOUT > 0
// Wake up display if user is using those fabulous keys or spinning those encoders!
-# ifdef ENCODER_ENABLE
- if (matrix_changed || encoders_changed) st7565_on();
-# else
- if (matrix_changed) st7565_on();
-# endif
+ if (activity_has_occurred) st7565_on();
# endif
#endif
@@ -660,10 +678,6 @@ void keyboard_task(void) {
ps2_mouse_task();
#endif
-#ifdef POINTING_DEVICE_ENABLE
- pointing_device_task();
-#endif
-
#ifdef MIDI_ENABLE
midi_task();
#endif
diff --git a/quantum/keyboard.h b/quantum/keyboard.h
index d0b52dd13a..bf1890d10b 100644
--- a/quantum/keyboard.h
+++ b/quantum/keyboard.h
@@ -30,65 +30,64 @@ typedef struct {
uint8_t row;
} keypos_t;
+typedef enum keyevent_type_t { TICK_EVENT = 0, KEY_EVENT = 1, ENCODER_CW_EVENT = 2, ENCODER_CCW_EVENT = 3, COMBO_EVENT = 4 } keyevent_type_t;
+
/* key event */
typedef struct {
- keypos_t key;
- bool pressed;
- uint16_t time;
+ keypos_t key;
+ uint16_t time;
+ keyevent_type_t type;
+ bool pressed;
} keyevent_t;
/* equivalent test of keypos_t */
#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col)
/* special keypos_t entries */
-#define KEYLOC_TICK 255
-#define KEYLOC_COMBO 254
#define KEYLOC_ENCODER_CW 253
#define KEYLOC_ENCODER_CCW 252
-/* Rules for No Event:
- * 1) (time == 0) to handle (keyevent_t){} as empty event
- * 2) Matrix(255, 255) to make TICK event available
- */
-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_NOEVENT(const keyevent_t event) {
+ return event.type == TICK_EVENT;
}
-static inline bool IS_KEYEVENT(keyevent_t event) {
- return event.key.row < MATRIX_ROWS && event.key.col < MATRIX_COLS;
+static inline bool IS_EVENT(const keyevent_t event) {
+ return event.type != TICK_EVENT;
}
-static inline bool IS_COMBOEVENT(keyevent_t event) {
- return event.key.row == KEYLOC_COMBO;
+static inline bool IS_KEYEVENT(const keyevent_t event) {
+ return event.type == KEY_EVENT;
}
-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_COMBOEVENT(const keyevent_t event) {
+ return event.type == COMBO_EVENT;
}
-static inline bool IS_PRESSED(keyevent_t event) {
- return IS_EVENT(event) && event.pressed;
-}
-static inline bool IS_RELEASED(keyevent_t event) {
- return IS_EVENT(event) && !event.pressed;
+static inline bool IS_ENCODEREVENT(const keyevent_t event) {
+ return event.type == ENCODER_CW_EVENT || event.type == ENCODER_CCW_EVENT;
}
-/* Common keyevent object factory */
+/* Common keypos_t object factory */
#define MAKE_KEYPOS(row_num, col_num) ((keypos_t){.row = (row_num), .col = (col_num)})
+/* Common keyevent_t object factory */
+#define MAKE_EVENT(row_num, col_num, press, event_type) ((keyevent_t){.key = MAKE_KEYPOS((row_num), (col_num)), .pressed = (press), .time = timer_read(), .type = (event_type)})
+
/**
* @brief Constructs a key event for a pressed or released key.
*/
-#define MAKE_KEYEVENT(row_num, col_num, press) ((keyevent_t){.key = MAKE_KEYPOS((row_num), (col_num)), .pressed = (press), .time = (timer_read() | 1)})
+#define MAKE_KEYEVENT(row_num, col_num, press) MAKE_EVENT((row_num), (col_num), (press), KEY_EVENT)
+
+/**
+ * @brief Constructs a combo event.
+ */
+#define MAKE_COMBOEVENT(press) MAKE_EVENT(0, 0, (press), COMBO_EVENT)
/**
* @brief Constructs a internal tick event that is used to drive the internal QMK state machine.
*/
-#define TICK_EVENT MAKE_KEYEVENT(KEYLOC_TICK, KEYLOC_TICK, false)
+#define MAKE_TICK_EVENT MAKE_EVENT(0, 0, false, TICK_EVENT)
#ifdef ENCODER_MAP_ENABLE
/* Encoder events */
-# define ENCODER_CW_EVENT(enc_id, press) MAKE_KEYEVENT(KEYLOC_ENCODER_CW, (enc_id), (press))
-# define ENCODER_CCW_EVENT(enc_id, press) MAKE_KEYEVENT(KEYLOC_ENCODER_CCW, (enc_id), (press))
+# define MAKE_ENCODER_CW_EVENT(enc_id, press) MAKE_EVENT(KEYLOC_ENCODER_CW, (enc_id), (press), ENCODER_CW_EVENT)
+# define MAKE_ENCODER_CCW_EVENT(enc_id, press) MAKE_EVENT(KEYLOC_ENCODER_CCW, (enc_id), (press), ENCODER_CCW_EVENT)
#endif // ENCODER_MAP_ENABLE
/* it runs once at early stage of startup before keyboard_init. */
@@ -111,8 +110,8 @@ void housekeeping_task(void); // To be executed by the main loop in each ba
void housekeeping_task_kb(void); // To be overridden by keyboard-level code
void housekeeping_task_user(void); // To be overridden by user/keymap-level code
-uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity
-uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity
+uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder or pointing device activity
+uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder or pointing device activity
uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity
uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity
@@ -120,6 +119,11 @@ uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the
uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity
uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity
+uint32_t last_pointing_device_activity_time(void); // Timestamp of the last pointing device activity
+uint32_t last_pointing_device_activity_elapsed(void); // Number of milliseconds since the last pointing device activity
+
+void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp, uint32_t pointing_device_timestamp); // Set the timestamps of the last matrix and encoder activity
+
uint32_t get_matrix_scan_rate(void);
#ifdef __cplusplus
diff --git a/quantum/keycode.h b/quantum/keycode.h
index 701c078ad0..df1452d296 100644
--- a/quantum/keycode.h
+++ b/quantum/keycode.h
@@ -34,26 +34,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
-#define MOD_BIT(code) (1 << MOD_INDEX(code))
-#define MOD_INDEX(code) ((code)&0x07)
-
-#define MOD_MASK_CTRL (MOD_BIT(KC_LEFT_CTRL) | MOD_BIT(KC_RIGHT_CTRL))
-#define MOD_MASK_SHIFT (MOD_BIT(KC_LEFT_SHIFT) | MOD_BIT(KC_RIGHT_SHIFT))
-#define MOD_MASK_ALT (MOD_BIT(KC_LEFT_ALT) | MOD_BIT(KC_RIGHT_ALT))
-#define MOD_MASK_GUI (MOD_BIT(KC_LEFT_GUI) | MOD_BIT(KC_RIGHT_GUI))
-#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT)
-#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT)
-#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI)
-#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT)
-#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI)
-#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI)
-#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT)
-#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI)
-#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI)
-#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
-#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
+#define MOD_BIT(code) (1 << ((code)&0x07))
// clang-format off
// TODO: dd keycodes
#include "keycodes.h"
+#include "modifiers.h"
diff --git a/quantum/keymap.h b/quantum/keymap.h
index 0225f53362..a067e1aa36 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -17,25 +17,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-#include <stdint.h>
-#include <stdbool.h>
-#include "platform_deps.h"
-#include "action.h"
-#include "keycode.h"
-#include "report.h"
-#include "host.h"
-#include "debug.h"
-#include "keycode_config.h"
-#include "gpio.h" // for pin_t
-
-#include "quantum_keycodes.h"
-
-// translates key to keycode
-uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
-
-#ifdef ENCODER_MAP_ENABLE
-// Ensure we have a forward declaration for the encoder map
-# include "encoder.h"
-#endif
-
-#include "keymap_introspection.h"
+#pragma message("'keymap.h' should no longer be included!")
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 6fcebc3242..0492e6fd1c 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -15,7 +15,8 @@ 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 "keymap.h"
+#include "keymap_common.h"
+#include "keymap_introspection.h"
#include "report.h"
#include "keycode.h"
#include "action_layer.h"
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h
new file mode 100644
index 0000000000..fca4fc9ba3
--- /dev/null
+++ b/quantum/keymap_common.h
@@ -0,0 +1,10 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+#include "keyboard.h"
+
+// translates key to keycode
+uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
diff --git a/quantum/keymap_extras/keymap_belgian.h b/quantum/keymap_extras/keymap_belgian.h
index 1bf9549c5a..6851c6b4e8 100644
--- a/quantum/keymap_extras/keymap_belgian.h
+++ b/quantum/keymap_extras/keymap_belgian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h
index 12026ce649..448727dece 100644
--- a/quantum/keymap_extras/keymap_bepo.h
+++ b/quantum/keymap_extras/keymap_bepo.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_brazilian_abnt2.h b/quantum/keymap_extras/keymap_brazilian_abnt2.h
index 70a09a52be..8fac7666c2 100644
--- a/quantum/keymap_extras/keymap_brazilian_abnt2.h
+++ b/quantum/keymap_extras/keymap_brazilian_abnt2.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h
index 44009f3aa2..5b9b03babb 100644
--- a/quantum/keymap_extras/keymap_canadian_multilingual.h
+++ b/quantum/keymap_extras/keymap_canadian_multilingual.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h
index 5cb86bf441..d63309f010 100644
--- a/quantum/keymap_extras/keymap_colemak.h
+++ b/quantum/keymap_extras/keymap_colemak.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_croatian.h b/quantum/keymap_extras/keymap_croatian.h
index 1115592e17..3e7c681ced 100644
--- a/quantum/keymap_extras/keymap_croatian.h
+++ b/quantum/keymap_extras/keymap_croatian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_czech.h b/quantum/keymap_extras/keymap_czech.h
index 02692002e3..351c51ad41 100644
--- a/quantum/keymap_extras/keymap_czech.h
+++ b/quantum/keymap_extras/keymap_czech.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_danish.h b/quantum/keymap_extras/keymap_danish.h
index 18107ccd53..cea9444896 100644
--- a/quantum/keymap_extras/keymap_danish.h
+++ b/quantum/keymap_extras/keymap_danish.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h
index 5767530b3b..9205a72057 100644
--- a/quantum/keymap_extras/keymap_dvorak.h
+++ b/quantum/keymap_extras/keymap_dvorak.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_dvorak_fr.h b/quantum/keymap_extras/keymap_dvorak_fr.h
index 60675fbf13..b206767614 100644
--- a/quantum/keymap_extras/keymap_dvorak_fr.h
+++ b/quantum/keymap_extras/keymap_dvorak_fr.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_dvorak_programmer.h b/quantum/keymap_extras/keymap_dvorak_programmer.h
index 6e1ae17807..19187ed13b 100644
--- a/quantum/keymap_extras/keymap_dvorak_programmer.h
+++ b/quantum/keymap_extras/keymap_dvorak_programmer.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_estonian.h b/quantum/keymap_extras/keymap_estonian.h
index 462bcde429..ea9c56c12a 100644
--- a/quantum/keymap_extras/keymap_estonian.h
+++ b/quantum/keymap_extras/keymap_estonian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_finnish.h b/quantum/keymap_extras/keymap_finnish.h
index 7e94896e2e..c0dc1af81e 100644
--- a/quantum/keymap_extras/keymap_finnish.h
+++ b/quantum/keymap_extras/keymap_finnish.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h
index da9467a475..03dbb7bc40 100644
--- a/quantum/keymap_extras/keymap_french.h
+++ b/quantum/keymap_extras/keymap_french.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_french_afnor.h b/quantum/keymap_extras/keymap_french_afnor.h
index 259e0a30f4..869984c4d2 100644
--- a/quantum/keymap_extras/keymap_french_afnor.h
+++ b/quantum/keymap_extras/keymap_french_afnor.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_french_mac_iso.h b/quantum/keymap_extras/keymap_french_mac_iso.h
index 9a8ed72604..e5f7514a80 100644
--- a/quantum/keymap_extras/keymap_french_mac_iso.h
+++ b/quantum/keymap_extras/keymap_french_mac_iso.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h
index 251491fb81..38b0c685ba 100644
--- a/quantum/keymap_extras/keymap_german.h
+++ b/quantum/keymap_extras/keymap_german.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_german_mac_iso.h b/quantum/keymap_extras/keymap_german_mac_iso.h
index de7b60546b..efa9099f20 100644
--- a/quantum/keymap_extras/keymap_german_mac_iso.h
+++ b/quantum/keymap_extras/keymap_german_mac_iso.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_greek.h b/quantum/keymap_extras/keymap_greek.h
index b4f5b5c5b3..01779cf2e8 100644
--- a/quantum/keymap_extras/keymap_greek.h
+++ b/quantum/keymap_extras/keymap_greek.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_hebrew.h b/quantum/keymap_extras/keymap_hebrew.h
index 372d7f2e93..284562072d 100644
--- a/quantum/keymap_extras/keymap_hebrew.h
+++ b/quantum/keymap_extras/keymap_hebrew.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_hungarian.h b/quantum/keymap_extras/keymap_hungarian.h
index 591d71c09c..fbc31ed155 100644
--- a/quantum/keymap_extras/keymap_hungarian.h
+++ b/quantum/keymap_extras/keymap_hungarian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_icelandic.h b/quantum/keymap_extras/keymap_icelandic.h
index 800899b515..3bd71c19f2 100644
--- a/quantum/keymap_extras/keymap_icelandic.h
+++ b/quantum/keymap_extras/keymap_icelandic.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_irish.h b/quantum/keymap_extras/keymap_irish.h
index 2cd63a48e3..6e161628c8 100644
--- a/quantum/keymap_extras/keymap_irish.h
+++ b/quantum/keymap_extras/keymap_irish.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_italian.h b/quantum/keymap_extras/keymap_italian.h
index 95f3348f63..8092dc1301 100644
--- a/quantum/keymap_extras/keymap_italian.h
+++ b/quantum/keymap_extras/keymap_italian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_italian_mac_ansi.h b/quantum/keymap_extras/keymap_italian_mac_ansi.h
index 5e7e2a37e8..ae1281be26 100644
--- a/quantum/keymap_extras/keymap_italian_mac_ansi.h
+++ b/quantum/keymap_extras/keymap_italian_mac_ansi.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_italian_mac_iso.h b/quantum/keymap_extras/keymap_italian_mac_iso.h
index 1d30451376..f3f01839c3 100644
--- a/quantum/keymap_extras/keymap_italian_mac_iso.h
+++ b/quantum/keymap_extras/keymap_italian_mac_iso.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_japanese.h b/quantum/keymap_extras/keymap_japanese.h
index 286863deea..947317833e 100644
--- a/quantum/keymap_extras/keymap_japanese.h
+++ b/quantum/keymap_extras/keymap_japanese.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_korean.h b/quantum/keymap_extras/keymap_korean.h
index 073647de7f..440a6b3b4d 100644
--- a/quantum/keymap_extras/keymap_korean.h
+++ b/quantum/keymap_extras/keymap_korean.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_latvian.h b/quantum/keymap_extras/keymap_latvian.h
index e3ac1cd433..2f26b1d8af 100644
--- a/quantum/keymap_extras/keymap_latvian.h
+++ b/quantum/keymap_extras/keymap_latvian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_lithuanian_azerty.h b/quantum/keymap_extras/keymap_lithuanian_azerty.h
index 11de3ad030..f6dd94f0ca 100644
--- a/quantum/keymap_extras/keymap_lithuanian_azerty.h
+++ b/quantum/keymap_extras/keymap_lithuanian_azerty.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_lithuanian_qwerty.h b/quantum/keymap_extras/keymap_lithuanian_qwerty.h
index c27389971e..03c6b7a2af 100644
--- a/quantum/keymap_extras/keymap_lithuanian_qwerty.h
+++ b/quantum/keymap_extras/keymap_lithuanian_qwerty.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h
index e8352ffa08..bc9445892f 100644
--- a/quantum/keymap_extras/keymap_neo2.h
+++ b/quantum/keymap_extras/keymap_neo2.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
index e336916713..6464966c71 100644
--- a/quantum/keymap_extras/keymap_nordic.h
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_norman.h b/quantum/keymap_extras/keymap_norman.h
index 1f773bb410..1a3a0bc53a 100644
--- a/quantum/keymap_extras/keymap_norman.h
+++ b/quantum/keymap_extras/keymap_norman.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_norwegian.h b/quantum/keymap_extras/keymap_norwegian.h
index 33193d6a4d..af16fec8d6 100644
--- a/quantum/keymap_extras/keymap_norwegian.h
+++ b/quantum/keymap_extras/keymap_norwegian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_plover.h b/quantum/keymap_extras/keymap_plover.h
index b51e44b8bb..c0e3311e90 100644
--- a/quantum/keymap_extras/keymap_plover.h
+++ b/quantum/keymap_extras/keymap_plover.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_plover_dvorak.h b/quantum/keymap_extras/keymap_plover_dvorak.h
index f8341f8cbc..7feb52a25c 100644
--- a/quantum/keymap_extras/keymap_plover_dvorak.h
+++ b/quantum/keymap_extras/keymap_plover_dvorak.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_polish.h b/quantum/keymap_extras/keymap_polish.h
index 6b37d77a0a..40870ec237 100644
--- a/quantum/keymap_extras/keymap_polish.h
+++ b/quantum/keymap_extras/keymap_polish.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_portuguese.h b/quantum/keymap_extras/keymap_portuguese.h
index 17da9a6c11..b4570ad922 100644
--- a/quantum/keymap_extras/keymap_portuguese.h
+++ b/quantum/keymap_extras/keymap_portuguese.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_portuguese_mac_iso.h b/quantum/keymap_extras/keymap_portuguese_mac_iso.h
index 3d34a39ae5..57a27d04e9 100644
--- a/quantum/keymap_extras/keymap_portuguese_mac_iso.h
+++ b/quantum/keymap_extras/keymap_portuguese_mac_iso.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_romanian.h b/quantum/keymap_extras/keymap_romanian.h
index fb48a0fda7..cf4c17125f 100644
--- a/quantum/keymap_extras/keymap_romanian.h
+++ b/quantum/keymap_extras/keymap_romanian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_russian.h b/quantum/keymap_extras/keymap_russian.h
index 3643718444..fd3a1604c8 100644
--- a/quantum/keymap_extras/keymap_russian.h
+++ b/quantum/keymap_extras/keymap_russian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_serbian.h b/quantum/keymap_extras/keymap_serbian.h
index dd1bda7533..732e2e939d 100644
--- a/quantum/keymap_extras/keymap_serbian.h
+++ b/quantum/keymap_extras/keymap_serbian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_serbian_latin.h b/quantum/keymap_extras/keymap_serbian_latin.h
index 83495b63be..5151696a10 100644
--- a/quantum/keymap_extras/keymap_serbian_latin.h
+++ b/quantum/keymap_extras/keymap_serbian_latin.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_slovak.h b/quantum/keymap_extras/keymap_slovak.h
index 10714f1be9..81a88fa25c 100644
--- a/quantum/keymap_extras/keymap_slovak.h
+++ b/quantum/keymap_extras/keymap_slovak.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_slovenian.h b/quantum/keymap_extras/keymap_slovenian.h
index 30910530e0..1e17342c27 100644
--- a/quantum/keymap_extras/keymap_slovenian.h
+++ b/quantum/keymap_extras/keymap_slovenian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h
index cac16c08a5..bcdd5af0c2 100644
--- a/quantum/keymap_extras/keymap_spanish.h
+++ b/quantum/keymap_extras/keymap_spanish.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_spanish_dvorak.h b/quantum/keymap_extras/keymap_spanish_dvorak.h
index 1feab96b8c..fb033df770 100644
--- a/quantum/keymap_extras/keymap_spanish_dvorak.h
+++ b/quantum/keymap_extras/keymap_spanish_dvorak.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h
index 07d96b7465..852b2f7121 100644
--- a/quantum/keymap_extras/keymap_steno.h
+++ b/quantum/keymap_extras/keymap_steno.h
@@ -16,7 +16,7 @@
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// List of keycodes for the steno keyboard. To prevent
// errors, this must be <= 42 total entries in order to
diff --git a/quantum/keymap_extras/keymap_swedish.h b/quantum/keymap_extras/keymap_swedish.h
index 4cdf4879c3..acb49f7773 100644
--- a/quantum/keymap_extras/keymap_swedish.h
+++ b/quantum/keymap_extras/keymap_swedish.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_swedish_mac_ansi.h b/quantum/keymap_extras/keymap_swedish_mac_ansi.h
index 9649f59dd0..ef48a9e493 100644
--- a/quantum/keymap_extras/keymap_swedish_mac_ansi.h
+++ b/quantum/keymap_extras/keymap_swedish_mac_ansi.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_swedish_mac_iso.h b/quantum/keymap_extras/keymap_swedish_mac_iso.h
index 068c81b020..2eaef5e60c 100644
--- a/quantum/keymap_extras/keymap_swedish_mac_iso.h
+++ b/quantum/keymap_extras/keymap_swedish_mac_iso.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h b/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h
index c0692ababd..d33a259023 100644
--- a/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h
+++ b/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h b/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h
index e01f0a7dc3..680bd1db9e 100644
--- a/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h
+++ b/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_swiss_de.h b/quantum/keymap_extras/keymap_swiss_de.h
index 0a6e6e4918..69bba7293e 100644
--- a/quantum/keymap_extras/keymap_swiss_de.h
+++ b/quantum/keymap_extras/keymap_swiss_de.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_swiss_fr.h b/quantum/keymap_extras/keymap_swiss_fr.h
index 05a4a4c279..1e2f833db1 100644
--- a/quantum/keymap_extras/keymap_swiss_fr.h
+++ b/quantum/keymap_extras/keymap_swiss_fr.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_turkish_f.h b/quantum/keymap_extras/keymap_turkish_f.h
index 0dfc0236e8..4fdcf3f746 100644
--- a/quantum/keymap_extras/keymap_turkish_f.h
+++ b/quantum/keymap_extras/keymap_turkish_f.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_turkish_q.h b/quantum/keymap_extras/keymap_turkish_q.h
index cc64300b18..5a9362acb4 100644
--- a/quantum/keymap_extras/keymap_turkish_q.h
+++ b/quantum/keymap_extras/keymap_turkish_q.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h
index ff6f8c9c2e..71e5f38f55 100644
--- a/quantum/keymap_extras/keymap_uk.h
+++ b/quantum/keymap_extras/keymap_uk.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_ukrainian.h b/quantum/keymap_extras/keymap_ukrainian.h
index b954bb2398..3f3ec4cec2 100644
--- a/quantum/keymap_extras/keymap_ukrainian.h
+++ b/quantum/keymap_extras/keymap_ukrainian.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_us.h b/quantum/keymap_extras/keymap_us.h
index 38df8c6336..6101c8d8ba 100644
--- a/quantum/keymap_extras/keymap_us.h
+++ b/quantum/keymap_extras/keymap_us.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_us_extended.h b/quantum/keymap_extras/keymap_us_extended.h
index c4f627c30d..90da98c756 100644
--- a/quantum/keymap_extras/keymap_us_extended.h
+++ b/quantum/keymap_extras/keymap_us_extended.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_us_international.h b/quantum/keymap_extras/keymap_us_international.h
index 1f2bc33476..bd5f21ec8c 100644
--- a/quantum/keymap_extras/keymap_us_international.h
+++ b/quantum/keymap_extras/keymap_us_international.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_us_international_linux.h b/quantum/keymap_extras/keymap_us_international_linux.h
index 16d072cc5b..4551cbe29f 100644
--- a/quantum/keymap_extras/keymap_us_international_linux.h
+++ b/quantum/keymap_extras/keymap_us_international_linux.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_workman.h b/quantum/keymap_extras/keymap_workman.h
index 5fe9d36b16..808caec054 100644
--- a/quantum/keymap_extras/keymap_workman.h
+++ b/quantum/keymap_extras/keymap_workman.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_extras/keymap_workman_zxcvm.h b/quantum/keymap_extras/keymap_workman_zxcvm.h
index 757f98e912..f8645ac4cf 100644
--- a/quantum/keymap_extras/keymap_workman_zxcvm.h
+++ b/quantum/keymap_extras/keymap_workman_zxcvm.h
@@ -24,7 +24,7 @@
*******************************************************************************/
#pragma once
-#include "keymap.h"
+#include "keycodes.h"
// clang-format off
// Aliases
diff --git a/quantum/keymap_introspection.h b/quantum/keymap_introspection.h
index a8df3928a6..201de937cb 100644
--- a/quantum/keymap_introspection.h
+++ b/quantum/keymap_introspection.h
@@ -3,6 +3,7 @@
#pragma once
#include <stdint.h>
+#include <stdbool.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Key mapping
diff --git a/quantum/leader.h b/quantum/leader.h
index 1999006c56..3177fcd196 100644
--- a/quantum/leader.h
+++ b/quantum/leader.h
@@ -5,9 +5,9 @@
#include <stdint.h>
/**
- * \defgroup leader
+ * \file
*
- * Leader Key
+ * \defgroup leader Leader Key
* \{
*/
diff --git a/quantum/midi/midi.c b/quantum/midi/midi.c
index 1ba3e73a40..1c481f2f0b 100644
--- a/quantum/midi/midi.c
+++ b/quantum/midi/midi.c
@@ -18,10 +18,7 @@
#include "midi.h"
#include <string.h> //for memcpy
-
-#ifndef MIN
-# define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#endif
+#include "util.h"
#ifndef NULL
# define NULL 0
diff --git a/quantum/modifiers.h b/quantum/modifiers.h
new file mode 100644
index 0000000000..45bcd6508d
--- /dev/null
+++ b/quantum/modifiers.h
@@ -0,0 +1,54 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+/** \brief 5-bit packed modifiers
+ *
+ * Mod bits: 43210
+ * bit 0 ||||+- Control
+ * bit 1 |||+-- Shift
+ * bit 2 ||+--- Alt
+ * bit 3 |+---- Gui
+ * bit 4 +----- LR flag(Left:0, Right:1)
+ */
+enum mods_5bit {
+ MOD_LCTL = 0x01,
+ MOD_LSFT = 0x02,
+ MOD_LALT = 0x04,
+ MOD_LGUI = 0x08,
+ MOD_RCTL = 0x11,
+ MOD_RSFT = 0x12,
+ MOD_RALT = 0x14,
+ MOD_RGUI = 0x18,
+};
+#define MOD_HYPR (MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI)
+#define MOD_MEH (MOD_LCTL | MOD_LSFT | MOD_LALT)
+
+/** \brief 8-bit packed modifiers
+ */
+enum mods_8bit {
+ MOD_BIT_LCTRL = 0b00000001,
+ MOD_BIT_LSHIFT = 0b00000010,
+ MOD_BIT_LALT = 0b00000100,
+ MOD_BIT_LGUI = 0b00001000,
+ MOD_BIT_RCTRL = 0b00010000,
+ MOD_BIT_RSHIFT = 0b00100000,
+ MOD_BIT_RALT = 0b01000000,
+ MOD_BIT_RGUI = 0b10000000,
+};
+#define MOD_MASK_CTRL (MOD_BIT_LCTRL | MOD_BIT_RCTRL)
+#define MOD_MASK_SHIFT (MOD_BIT_LSHIFT | MOD_BIT_RSHIFT)
+#define MOD_MASK_ALT (MOD_BIT_LALT | MOD_BIT_RALT)
+#define MOD_MASK_GUI (MOD_BIT_LGUI | MOD_BIT_RGUI)
+#define MOD_MASK_CS (MOD_MASK_CTRL | MOD_MASK_SHIFT)
+#define MOD_MASK_CA (MOD_MASK_CTRL | MOD_MASK_ALT)
+#define MOD_MASK_CG (MOD_MASK_CTRL | MOD_MASK_GUI)
+#define MOD_MASK_SA (MOD_MASK_SHIFT | MOD_MASK_ALT)
+#define MOD_MASK_SG (MOD_MASK_SHIFT | MOD_MASK_GUI)
+#define MOD_MASK_AG (MOD_MASK_ALT | MOD_MASK_GUI)
+#define MOD_MASK_CSA (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT)
+#define MOD_MASK_CSG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_GUI)
+#define MOD_MASK_CAG (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI)
+#define MOD_MASK_SAG (MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
+#define MOD_MASK_CSAG (MOD_MASK_CTRL | MOD_MASK_SHIFT | MOD_MASK_ALT | MOD_MASK_GUI)
diff --git a/quantum/os_detection.c b/quantum/os_detection.c
index b1511afb14..e606227136 100644
--- a/quantum/os_detection.c
+++ b/quantum/os_detection.c
@@ -31,53 +31,53 @@ uint16_t usb_setups[STORED_USB_SETUPS];
#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;
+ uint8_t count;
+ uint8_t cnt_02;
+ uint8_t cnt_04;
+ uint8_t cnt_ff;
+ uint16_t last_wlength;
};
struct setups_data_t setups_data = {
- .count = 0,
- .cnt_02 = 0,
- .cnt_04 = 0,
- .cnt_ff = 0,
- .detected_os = OS_UNSURE,
+ .count = 0,
+ .cnt_02 = 0,
+ .cnt_04 = 0,
+ .cnt_ff = 0,
};
+os_variant_t 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ detected_os = OS_LINUX;
return;
}
}
@@ -99,13 +99,20 @@ void process_wlength(const uint16_t w_length) {
}
os_variant_t detected_host_os(void) {
- return setups_data.detected_os;
+ return detected_os;
}
void erase_wlength_data(void) {
memset(&setups_data, 0, sizeof(setups_data));
+ detected_os = OS_UNSURE;
+}
+
+# if defined(SPLIT_KEYBOARD) && defined(SPLIT_DETECTED_OS_ENABLE)
+void slave_update_detected_host_os(os_variant_t os) {
+ detected_os = os;
}
-#endif // OS_DETECTION_ENABLE
+# endif // defined(SPLIT_KEYBOARD) && defined(SPLIT_DETECTED_OS_ENABLE)
+#endif // OS_DETECTION_ENABLE
#ifdef OS_DETECTION_DEBUG_ENABLE
void print_stored_setups(void) {
diff --git a/quantum/os_detection.h b/quantum/os_detection.h
index e643dcd27f..3496ea0ed2 100644
--- a/quantum/os_detection.h
+++ b/quantum/os_detection.h
@@ -30,6 +30,10 @@ typedef enum {
void process_wlength(const uint16_t w_length);
os_variant_t detected_host_os(void);
void erase_wlength_data(void);
+
+# if defined(SPLIT_KEYBOARD) && defined(SPLIT_DETECTED_OS_ENABLE)
+void slave_update_detected_host_os(os_variant_t os);
+# endif // defined(SPLIT_KEYBOARD) && defined(SPLIT_DETECTED_OS_ENABLE)
#endif
#ifdef OS_DETECTION_DEBUG_ENABLE
diff --git a/quantum/painter/lvgl/qp_lvgl.c b/quantum/painter/lvgl/qp_lvgl.c
index c6dd08ef97..660ffb6100 100644
--- a/quantum/painter/lvgl/qp_lvgl.c
+++ b/quantum/painter/lvgl/qp_lvgl.c
@@ -60,7 +60,7 @@ 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;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n");
qp_lvgl_detach();
diff --git a/quantum/painter/qff.h b/quantum/painter/qff.h
index 6f1a1fd815..d1d629582f 100644
--- a/quantum/painter/qff.h
+++ b/quantum/painter/qff.h
@@ -21,7 +21,7 @@
#define QFF_FONT_DESCRIPTOR_TYPEID 0x00
-typedef struct __attribute__((packed)) qff_font_descriptor_v1_t {
+typedef struct QP_PACKED qff_font_descriptor_v1_t {
qgf_block_header_v1_t header; // = { .type_id = 0x00, .neg_type_id = (~0x00), .length = 20 }
uint32_t magic : 24; // constant, equal to 0x464651 ("QFF")
uint8_t qff_version; // constant, equal to 0x01
@@ -50,13 +50,13 @@ _Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t
#define QFF_GLYPH_OFFSET_BITS 18
#define QFF_GLYPH_OFFSET_MASK (((1 << QFF_GLYPH_OFFSET_BITS) - 1) << QFF_GLYPH_WIDTH_BITS)
-typedef struct __attribute__((packed)) qff_ascii_glyph_v1_t {
+typedef struct QP_PACKED qff_ascii_glyph_v1_t {
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
} qff_ascii_glyph_v1_t;
_Static_assert(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF");
-typedef struct __attribute__((packed)) qff_ascii_glyph_table_v1_t {
+typedef struct QP_PACKED qff_ascii_glyph_table_v1_t {
qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 }
qff_ascii_glyph_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E
} qff_ascii_glyph_table_v1_t;
@@ -68,14 +68,14 @@ _Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1
#define QFF_UNICODE_GLYPH_DESCRIPTOR_TYPEID 0x02
-typedef struct __attribute__((packed)) qff_unicode_glyph_v1_t {
+typedef struct QP_PACKED qff_unicode_glyph_v1_t {
uint32_t code_point : 24;
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
} qff_unicode_glyph_v1_t;
_Static_assert(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF");
-typedef struct __attribute__((packed)) qff_unicode_glyph_table_v1_t {
+typedef struct QP_PACKED qff_unicode_glyph_table_v1_t {
qgf_block_header_v1_t header; // = { .type_id = 0x02, .neg_type_id = (~0x02), .length = (N * 6) }
qff_unicode_glyph_v1_t glyph[0]; // Extent of '0' signifies that this struct is immediately followed by the glyph data
} qff_unicode_glyph_table_v1_t;
diff --git a/quantum/painter/qp.c b/quantum/painter/qp.c
index de36dee2c1..aea9381b60 100644
--- a/quantum/painter/qp.c
+++ b/quantum/painter/qp.c
@@ -11,15 +11,15 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal driver validation
-static bool validate_driver_vtable(struct painter_driver_t *driver) {
+static bool validate_driver_vtable(painter_driver_t *driver) {
return (driver->driver_vtable && driver->driver_vtable->init && driver->driver_vtable->power && driver->driver_vtable->clear && driver->driver_vtable->viewport && driver->driver_vtable->pixdata && driver->driver_vtable->palette_convert && driver->driver_vtable->append_pixels && driver->driver_vtable->append_pixdata) ? true : false;
}
-static bool validate_comms_vtable(struct painter_driver_t *driver) {
+static bool validate_comms_vtable(painter_driver_t *driver) {
return (driver->comms_vtable && driver->comms_vtable->comms_init && driver->comms_vtable->comms_start && driver->comms_vtable->comms_stop && driver->comms_vtable->comms_send) ? true : false;
}
-static bool validate_driver_integrity(struct painter_driver_t *driver) {
+static bool validate_driver_integrity(painter_driver_t *driver) {
return validate_driver_vtable(driver) && validate_comms_vtable(driver);
}
@@ -28,7 +28,7 @@ static bool validate_driver_integrity(struct painter_driver_t *driver) {
bool qp_init(painter_device_t device, painter_rotation_t rotation) {
qp_dprintf("qp_init: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
driver->validate_ok = false;
if (!validate_driver_integrity(driver)) {
@@ -64,7 +64,7 @@ bool qp_init(painter_device_t device, painter_rotation_t rotation) {
bool qp_power(painter_device_t device, bool power_on) {
qp_dprintf("qp_power: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_power: fail (validation_ok == false)\n");
return false;
@@ -86,7 +86,7 @@ bool qp_power(painter_device_t device, bool power_on) {
bool qp_clear(painter_device_t device) {
qp_dprintf("qp_clear: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_clear: fail (validation_ok == false)\n");
return false;
@@ -108,7 +108,7 @@ bool qp_clear(painter_device_t device) {
bool qp_flush(painter_device_t device) {
qp_dprintf("qp_flush: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_flush: fail (validation_ok == false)\n");
return false;
@@ -130,7 +130,7 @@ bool qp_flush(painter_device_t device) {
void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) {
qp_dprintf("qp_geometry: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
switch (driver->rotation) {
default:
@@ -174,7 +174,7 @@ void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height,
void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_t offset_y) {
qp_dprintf("qp_set_viewport_offsets: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
driver->offset_x = offset_x;
driver->offset_y = offset_y;
@@ -187,7 +187,7 @@ void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_
bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
qp_dprintf("qp_viewport: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_viewport: fail (validation_ok == false)\n");
return false;
@@ -210,7 +210,7 @@ bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t
bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
qp_dprintf("qp_pixdata: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_pixdata: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h
index 00f5d7931a..7222d3b413 100644
--- a/quantum/painter/qp.h
+++ b/quantum/painter/qp.h
@@ -1,4 +1,4 @@
-// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2021-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -11,6 +11,22 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter global configurables (add to your keyboard's config.h)
+#ifndef QUANTUM_PAINTER_DISPLAY_TIMEOUT
+/**
+ * @def This controls the amount of time (in milliseconds) that all displays will remain on after the last user input.
+ * If set to 0, the display will remain on indefinitely.
+ */
+# define QUANTUM_PAINTER_DISPLAY_TIMEOUT 30000
+#endif // QUANTUM_PAINTER_DISPLAY_TIMEOUT
+
+#ifndef QUANTUM_PAINTER_TASK_THROTTLE
+/**
+ * @def This controls the amount of time (in milliseconds) that the Quantum Painter internal task will wait between
+ * each execution.
+ */
+# define QUANTUM_PAINTER_TASK_THROTTLE 1
+#endif // QUANTUM_PAINTER_TASK_THROTTLE
+
#ifndef QUANTUM_PAINTER_NUM_IMAGES
/**
* @def This controls the maximum number of images that Quantum Painter can load at any one time. Images can be loaded
@@ -53,7 +69,7 @@
* @def This controls the maximum size of the pixel data buffer used for single blocks of transmission. Larger buffers
* means more data is processed at one time, with less frequent transmissions, at the cost of RAM.
*/
-# define QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE 32
+# define QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE 1024
#endif
#ifndef QUANTUM_PAINTER_SUPPORTS_256_PALETTE
@@ -442,34 +458,50 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
#ifdef QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
# include "qp_rgb565_surface.h"
+#else // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
+# define RGB565_SURFACE_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_RGB565_SURFACE_ENABLE
#ifdef QUANTUM_PAINTER_ILI9163_ENABLE
# include "qp_ili9163.h"
+#else // QUANTUM_PAINTER_ILI9163_ENABLE
+# define ILI9163_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ILI9163_ENABLE
#ifdef QUANTUM_PAINTER_ILI9341_ENABLE
# include "qp_ili9341.h"
+#else // QUANTUM_PAINTER_ILI9341_ENABLE
+# define ILI9341_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ILI9341_ENABLE
#ifdef QUANTUM_PAINTER_ILI9488_ENABLE
# include "qp_ili9488.h"
+#else // QUANTUM_PAINTER_ILI9488_ENABLE
+# define ILI9488_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ILI9488_ENABLE
#ifdef QUANTUM_PAINTER_ST7789_ENABLE
# include "qp_st7789.h"
+#else // QUANTUM_PAINTER_ST7789_ENABLE
+# define ST7789_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ST7789_ENABLE
#ifdef QUANTUM_PAINTER_ST7735_ENABLE
# include "qp_st7735.h"
+#else // QUANTUM_PAINTER_ST7735_ENABLE
+# define ST7735_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_ST7735_ENABLE
#ifdef QUANTUM_PAINTER_GC9A01_ENABLE
# include "qp_gc9a01.h"
+#else // QUANTUM_PAINTER_GC9A01_ENABLE
+# define GC9A01_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_GC9A01_ENABLE
#ifdef QUANTUM_PAINTER_SSD1351_ENABLE
# include "qp_ssd1351.h"
+#else // QUANTUM_PAINTER_SSD1351_ENABLE
+# define SSD1351_NUM_DEVICES 0
#endif // QUANTUM_PAINTER_SSD1351_ENABLE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/quantum/painter/qp_comms.c b/quantum/painter/qp_comms.c
index dc17b49460..bcc6de8f2e 100644
--- a/quantum/painter/qp_comms.c
+++ b/quantum/painter/qp_comms.c
@@ -7,7 +7,7 @@
// Base comms APIs
bool qp_comms_init(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_init: fail (validation_ok == false)\n");
return false;
@@ -17,7 +17,7 @@ bool qp_comms_init(painter_device_t device) {
}
bool qp_comms_start(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_start: fail (validation_ok == false)\n");
return false;
@@ -27,7 +27,7 @@ bool qp_comms_start(painter_device_t device) {
}
void qp_comms_stop(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_stop: fail (validation_ok == false)\n");
return;
@@ -37,7 +37,7 @@ void qp_comms_stop(painter_device_t device) {
}
uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_count) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_comms_send: fail (validation_ok == false)\n");
return false;
@@ -50,8 +50,8 @@ uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_
// Comms APIs that use a D/C pin
void qp_comms_command(painter_device_t device, uint8_t cmd) {
- struct painter_driver_t * driver = (struct painter_driver_t *)device;
- struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable;
+ painter_driver_t * driver = (painter_driver_t *)device;
+ painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable;
comms_vtable->send_command(device, cmd);
}
@@ -66,7 +66,7 @@ uint32_t qp_comms_command_databuf(painter_device_t device, uint8_t cmd, const vo
}
void qp_comms_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) {
- struct painter_driver_t * driver = (struct painter_driver_t *)device;
- struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable;
+ painter_driver_t * driver = (painter_driver_t *)device;
+ painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable;
comms_vtable->bulk_command_sequence(device, sequence, sequence_len);
}
diff --git a/quantum/painter/qp_draw.h b/quantum/painter/qp_draw.h
index 84b1946ca7..3d073efe8c 100644
--- a/quantum/painter/qp_draw.h
+++ b/quantum/painter/qp_draw.h
@@ -63,7 +63,7 @@ enum qp_internal_rle_mode_t {
NON_REPEATING_RUN,
};
-struct qp_internal_byte_input_state {
+typedef struct qp_internal_byte_input_state_t {
painter_device_t device;
qp_stream_t* src_stream;
int16_t curr;
@@ -74,22 +74,22 @@ struct qp_internal_byte_input_state {
uint8_t remain; // number of bytes remaining in the current mode
} rle;
};
-};
+} qp_internal_byte_input_state_t;
-struct qp_internal_pixel_output_state {
+typedef struct qp_internal_pixel_output_state_t {
painter_device_t device;
uint32_t pixel_write_pos;
uint32_t max_pixels;
-};
+} qp_internal_pixel_output_state_t;
bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg);
-struct qp_internal_byte_output_state {
+typedef struct qp_internal_byte_output_state_t {
painter_device_t device;
uint32_t byte_write_pos;
uint32_t max_bytes;
-};
+} qp_internal_byte_output_state_t;
bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg);
-qp_internal_byte_input_callback qp_internal_prepare_input_state(struct qp_internal_byte_input_state* input_state, painter_compression_t compression);
+qp_internal_byte_input_callback qp_internal_prepare_input_state(qp_internal_byte_input_state_t* input_state, painter_compression_t compression);
diff --git a/quantum/painter/qp_draw_circle.c b/quantum/painter/qp_draw_circle.c
index edaae35835..25517d91c5 100644
--- a/quantum/painter/qp_draw_circle.c
+++ b/quantum/painter/qp_draw_circle.c
@@ -127,7 +127,7 @@ static bool qp_circle_helper_impl(painter_device_t device, uint16_t centerx, uin
bool qp_circle(painter_device_t device, uint16_t x, uint16_t y, uint16_t radius, uint8_t hue, uint8_t sat, uint8_t val, bool filled) {
qp_dprintf("qp_circle: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_circle: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp_draw_codec.c b/quantum/painter/qp_draw_codec.c
index 5d1cf7c52e..cee2e32e28 100644
--- a/quantum/painter/qp_draw_codec.c
+++ b/quantum/painter/qp_draw_codec.c
@@ -54,8 +54,8 @@ bool qp_internal_decode_grayscale(painter_device_t device, uint32_t pixel_count,
}
bool qp_internal_decode_recolor(painter_device_t device, uint32_t pixel_count, uint8_t bits_per_pixel, qp_internal_byte_input_callback input_callback, void* input_arg, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qp_internal_pixel_output_callback output_callback, void* output_arg) {
- struct painter_driver_t* driver = (struct painter_driver_t*)device;
- int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate
+ painter_driver_t* driver = (painter_driver_t*)device;
+ int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate
if (qp_internal_interpolate_palette(fg_hsv888, bg_hsv888, steps)) {
if (!driver->driver_vtable->palette_convert(device, steps, qp_internal_global_pixel_lookup_table)) {
return false;
@@ -84,13 +84,13 @@ bool qp_internal_send_bytes(painter_device_t device, uint32_t byte_count, qp_int
// Progressive pull of bytes, push of pixels
static inline int16_t qp_drawimage_byte_uncompressed_decoder(void* cb_arg) {
- struct qp_internal_byte_input_state* state = (struct qp_internal_byte_input_state*)cb_arg;
- state->curr = qp_stream_get(state->src_stream);
+ qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg;
+ state->curr = qp_stream_get(state->src_stream);
return state->curr;
}
static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) {
- struct qp_internal_byte_input_state* state = (struct qp_internal_byte_input_state*)cb_arg;
+ qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg;
// Work out if we're parsing the initial marker byte
if (state->rle.mode == MARKER_BYTE) {
@@ -126,8 +126,8 @@ static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) {
}
bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg) {
- struct qp_internal_pixel_output_state* state = (struct qp_internal_pixel_output_state*)cb_arg;
- struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
+ qp_internal_pixel_output_state_t* state = (qp_internal_pixel_output_state_t*)cb_arg;
+ painter_driver_t* driver = (painter_driver_t*)state->device;
if (!driver->driver_vtable->append_pixels(state->device, qp_internal_global_pixdata_buffer, palette, state->pixel_write_pos++, 1, &index)) {
return false;
@@ -145,8 +145,8 @@ bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg
}
bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
- struct qp_internal_byte_output_state* state = (struct qp_internal_byte_output_state*)cb_arg;
- struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
+ qp_internal_byte_output_state_t* state = (qp_internal_byte_output_state_t*)cb_arg;
+ painter_driver_t* driver = (painter_driver_t*)state->device;
if (!driver->driver_vtable->append_pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos++, byteval)) {
return false;
@@ -154,7 +154,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
// If we've hit the transmit limit, send out the entire buffer and reset the write position
if (state->byte_write_pos == state->max_bytes) {
- struct painter_driver_t* driver = (struct painter_driver_t*)state->device;
+ painter_driver_t* driver = (painter_driver_t*)state->device;
if (!driver->driver_vtable->pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos * 8 / driver->native_bits_per_pixel)) {
return false;
}
@@ -164,7 +164,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) {
return true;
}
-qp_internal_byte_input_callback qp_internal_prepare_input_state(struct qp_internal_byte_input_state* input_state, painter_compression_t compression) {
+qp_internal_byte_input_callback qp_internal_prepare_input_state(qp_internal_byte_input_state_t* input_state, painter_compression_t compression) {
switch (compression) {
case IMAGE_UNCOMPRESSED:
return qp_drawimage_byte_uncompressed_decoder;
diff --git a/quantum/painter/qp_draw_core.c b/quantum/painter/qp_draw_core.c
index 309ef93dd0..3988aaedf8 100644
--- a/quantum/painter/qp_draw_core.c
+++ b/quantum/painter/qp_draw_core.c
@@ -37,21 +37,21 @@ __attribute__((__aligned__(4))) qp_pixel_t qp_internal_global_pixel_lookup_table
// Helpers
uint32_t qp_internal_num_pixels_in_buffer(painter_device_t device) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
return ((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE * 8) / driver->native_bits_per_pixel);
}
// qp_setpixel internal implementation, but accepts a buffer with pre-converted native pixel. Only the first pixel is used.
bool qp_internal_setpixel_impl(painter_device_t device, uint16_t x, uint16_t y) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
return driver->driver_vtable->viewport(device, x, y, x, y) && driver->driver_vtable->pixdata(device, qp_internal_global_pixdata_buffer, 1);
}
// Fills the global native pixel buffer with equivalent pixels matching the supplied HSV
void qp_internal_fill_pixdata(painter_device_t device, uint32_t num_pixels, uint8_t hue, uint8_t sat, uint8_t val) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
- uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
- num_pixels = QP_MIN(pixels_in_pixdata, num_pixels);
+ painter_driver_t *driver = (painter_driver_t *)device;
+ uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
+ num_pixels = QP_MIN(pixels_in_pixdata, num_pixels);
// Convert the color to native pixel format
qp_pixel_t color = {.hsv888 = {.h = hue, .s = sat, .v = val}};
@@ -144,7 +144,7 @@ bool qp_internal_load_qgf_palette(qp_stream_t *stream, uint8_t bpp) {
// Quantum Painter External API: qp_setpixel
bool qp_setpixel(painter_device_t device, uint16_t x, uint16_t y, uint8_t hue, uint8_t sat, uint8_t val) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_setpixel: fail (validation_ok == false)\n");
return false;
@@ -174,7 +174,7 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin
}
qp_dprintf("qp_line(%d, %d, %d, %d): entry\n", (int)x0, (int)y0, (int)x1, (int)y1);
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_line: fail (validation_ok == false)\n");
return false;
@@ -228,8 +228,8 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin
// Quantum Painter External API: qp_rect
bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
- uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device);
+ painter_driver_t *driver = (painter_driver_t *)device;
uint16_t l = QP_MIN(left, right);
uint16_t r = QP_MAX(left, right);
@@ -252,7 +252,7 @@ bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, ui
bool qp_rect(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint8_t hue, uint8_t sat, uint8_t val, bool filled) {
qp_dprintf("qp_rect(%d, %d, %d, %d): entry\n", (int)left, (int)top, (int)right, (int)bottom);
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_rect: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp_draw_ellipse.c b/quantum/painter/qp_draw_ellipse.c
index 7f2f4abcfd..5c7abd7a7d 100644
--- a/quantum/painter/qp_draw_ellipse.c
+++ b/quantum/painter/qp_draw_ellipse.c
@@ -61,7 +61,7 @@ static bool qp_ellipse_helper_impl(painter_device_t device, uint16_t centerx, ui
bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex, uint16_t sizey, uint8_t hue, uint8_t sat, uint8_t val, bool filled) {
qp_dprintf("qp_ellipse: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_ellipse: fail (validation_ok == false)\n");
return false;
diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c
index 073f1da8eb..9f86b29f8b 100644
--- a/quantum/painter/qp_draw_image.c
+++ b/quantum/painter/qp_draw_image.c
@@ -1,4 +1,4 @@
-// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2021-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "qp_internal.h"
@@ -124,7 +124,7 @@ typedef struct qgf_frame_info_t {
} qgf_frame_info_t;
static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, qgf_image_handle_t *qgf_image, uint16_t frame_number, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qgf_frame_info_t *info) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
// Drop out if we can't actually place the data we read out anywhere
if (!info) {
@@ -209,7 +209,7 @@ static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device,
static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint16_t y, painter_image_handle_t image, int frame_number, qgf_frame_info_t *frame_info, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888) {
qp_dprintf("qp_drawimage_recolor: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_drawimage_recolor: fail (validation_ok == false)\n");
return false;
@@ -254,8 +254,8 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
}
// Set up the input state
- struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qgf_image->stream};
- qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme);
+ qp_internal_byte_input_state_t input_state = {.device = device, .src_stream = &qgf_image->stream};
+ qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme);
if (input_callback == NULL) {
qp_dprintf("qp_drawimage_recolor: fail (invalid image compression scheme)\n");
qp_comms_stop(device);
@@ -265,7 +265,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
bool ret = false;
if (frame_info->bpp <= 8) {
// Set up the output state
- struct qp_internal_pixel_output_state output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
+ qp_internal_pixel_output_state_t output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
// Decode the pixel data and stream to the display
ret = qp_internal_decode_palette(device, pixel_count, frame_info->bpp, input_callback, &input_state, qp_internal_global_pixel_lookup_table, qp_internal_pixel_appender, &output_state);
@@ -279,7 +279,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1
return false;
} else {
// Set up the output state
- struct qp_internal_byte_output_state output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8};
+ qp_internal_byte_output_state_t output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8};
// Stream the raw pixel data to the display
uint32_t byte_count = pixel_count * frame_info->bpp / 8;
@@ -418,15 +418,3 @@ 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/qp_draw_text.c b/quantum/painter/qp_draw_text.c
index f9fb2bf08f..ed3d373867 100644
--- a/quantum/painter/qp_draw_text.c
+++ b/quantum/painter/qp_draw_text.c
@@ -164,7 +164,7 @@ typedef bool (*code_point_handler)(qff_font_handle_t *qff_font, uint32_t code_po
// Helper that sets up the palette (if required) and returns the offset in the stream that the data starts
static inline bool qp_drawtext_prepare_font_for_render(painter_device_t device, qff_font_handle_t *qff_font, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, uint32_t *data_offset) {
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
// Drop out if we can't actually place the data we read out anywhere
if (!data_offset) {
@@ -319,13 +319,13 @@ static inline bool qp_iterate_code_points(qff_font_handle_t *qff_font, const cha
// String width calculation
// Callback state
-struct code_point_iter_calcwidth_state {
+typedef struct code_point_iter_calcwidth_state_t {
int16_t width;
-};
+} code_point_iter_calcwidth_state_t;
// Codepoint handler callback: width calc
static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) {
- struct code_point_iter_calcwidth_state *state = (struct code_point_iter_calcwidth_state *)cb_arg;
+ code_point_iter_calcwidth_state_t *state = (code_point_iter_calcwidth_state_t *)cb_arg;
// Increment the overall width by this glyph's width
state->width += width;
@@ -337,19 +337,19 @@ static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_f
// String drawing implementation
// Callback state
-struct code_point_iter_drawglyph_state {
- painter_device_t device;
- int16_t xpos;
- int16_t ypos;
- qp_internal_byte_input_callback input_callback;
- struct qp_internal_byte_input_state * input_state;
- struct qp_internal_pixel_output_state *output_state;
-};
+typedef struct code_point_iter_drawglyph_state_t {
+ painter_device_t device;
+ int16_t xpos;
+ int16_t ypos;
+ qp_internal_byte_input_callback input_callback;
+ qp_internal_byte_input_state_t * input_state;
+ qp_internal_pixel_output_state_t *output_state;
+} code_point_iter_drawglyph_state_t;
// Codepoint handler callback: drawing
static inline bool qp_font_code_point_handler_drawglyph(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) {
- struct code_point_iter_drawglyph_state *state = (struct code_point_iter_drawglyph_state *)cb_arg;
- struct painter_driver_t * driver = (struct painter_driver_t *)state->device;
+ code_point_iter_drawglyph_state_t *state = (code_point_iter_drawglyph_state_t *)cb_arg;
+ painter_driver_t * driver = (painter_driver_t *)state->device;
// Reset the input state's RLE mode -- the stream should already be correctly positioned by qp_iterate_code_points()
state->input_state->rle.mode = MARKER_BYTE; // ignored if not using RLE
@@ -386,7 +386,7 @@ int16_t qp_textwidth(painter_font_handle_t font, const char *str) {
}
// Create the codepoint iterator state
- struct code_point_iter_calcwidth_state state = {.width = 0};
+ code_point_iter_calcwidth_state_t state = {.width = 0};
// Iterate each codepoint, return the calculated width if successful.
return qp_iterate_code_points(qff_font, str, qp_font_code_point_handler_calcwidth, &state) ? state.width : 0;
}
@@ -405,7 +405,7 @@ int16_t qp_drawtext(painter_device_t device, uint16_t x, uint16_t y, painter_fon
int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, painter_font_handle_t font, const char *str, uint8_t hue_fg, uint8_t sat_fg, uint8_t val_fg, uint8_t hue_bg, uint8_t sat_bg, uint8_t val_bg) {
qp_dprintf("qp_drawtext_recolor: entry\n");
- struct painter_driver_t *driver = (struct painter_driver_t *)device;
+ painter_driver_t *driver = (painter_driver_t *)device;
if (!driver->validate_ok) {
qp_dprintf("qp_drawtext_recolor: fail (validation_ok == false)\n");
return 0;
@@ -423,8 +423,8 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
}
// Set up the byte input state and input callback
- struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qff_font->stream};
- qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme);
+ qp_internal_byte_input_state_t input_state = {.device = device, .src_stream = &qff_font->stream};
+ qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme);
if (input_callback == NULL) {
qp_dprintf("qp_drawtext_recolor: fail (invalid font compression scheme)\n");
qp_comms_stop(device);
@@ -432,18 +432,18 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai
}
// Set up the pixel output state
- struct qp_internal_pixel_output_state output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
+ qp_internal_pixel_output_state_t output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)};
// Set up the codepoint iteration state
- struct code_point_iter_drawglyph_state state = {// Common
- .device = device,
- .xpos = x,
- .ypos = y,
- // Input
- .input_callback = input_callback,
- .input_state = &input_state,
- // Output
- .output_state = &output_state};
+ code_point_iter_drawglyph_state_t state = {// Common
+ .device = device,
+ .xpos = x,
+ .ypos = y,
+ // Input
+ .input_callback = input_callback,
+ .input_state = &input_state,
+ // Output
+ .output_state = &output_state};
qp_pixel_t fg_hsv888 = {.hsv888 = {.h = hue_fg, .s = sat_fg, .v = val_fg}};
qp_pixel_t bg_hsv888 = {.hsv888 = {.h = hue_bg, .s = sat_bg, .v = val_bg}};
diff --git a/quantum/painter/qp_internal.c b/quantum/painter/qp_internal.c
new file mode 100644
index 0000000000..ea23aef7c3
--- /dev/null
+++ b/quantum/painter/qp_internal.c
@@ -0,0 +1,96 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "qp_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter Core API: device registration
+
+enum {
+ // Work out how many devices we're actually going to be instantiating
+ // NOTE: We intentionally do not include surfaces here, despite them conforming to the same API.
+ QP_NUM_DEVICES = (ILI9163_NUM_DEVICES) // ILI9163
+ + (ILI9341_NUM_DEVICES) // ILI9341
+ + (ILI9488_NUM_DEVICES) // ILI9488
+ + (ST7789_NUM_DEVICES) // ST7789
+ + (ST7735_NUM_DEVICES) // ST7735
+ + (GC9A01_NUM_DEVICES) // GC9A01
+ + (SSD1351_NUM_DEVICES) // SSD1351
+};
+
+static painter_device_t qp_devices[QP_NUM_DEVICES] = {NULL};
+
+bool qp_internal_register_device(painter_device_t driver) {
+ for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) {
+ if (qp_devices[i] == NULL) {
+ qp_devices[i] = driver;
+ return true;
+ }
+ }
+
+ // We should never get here -- someone has screwed up their device counts during config
+ qp_dprintf("qp_internal_register_device: no more space for devices!\n");
+ return false;
+}
+
+#if (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+static void qp_internal_display_timeout_task(void) {
+ // Handle power on/off state
+ static bool display_on = true;
+ bool should_change_display_state = false;
+ bool target_display_state = false;
+ if (last_input_activity_elapsed() < (QUANTUM_PAINTER_DISPLAY_TIMEOUT)) {
+ should_change_display_state = display_on == false;
+ target_display_state = true;
+ } else {
+ should_change_display_state = display_on == true;
+ target_display_state = false;
+ }
+
+ if (should_change_display_state) {
+ for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) {
+ if (qp_devices[i] != NULL) {
+ qp_power(qp_devices[i], target_display_state);
+ }
+ }
+
+ display_on = target_display_state;
+ }
+}
+#endif // (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Quantum Painter Core API: qp_internal_task
+
+_Static_assert((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999");
+
+void qp_internal_task(void) {
+ // Perform throttling of the internal processing of Quantum Painter
+ static uint32_t last_tick = 0;
+ uint32_t now = timer_read32();
+ if (TIMER_DIFF_32(now, last_tick) < (QUANTUM_PAINTER_TASK_THROTTLE)) {
+ return;
+ }
+ last_tick = now;
+
+#if (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+ qp_internal_display_timeout_task();
+#endif // (QUANTUM_PAINTER_DISPLAY_TIMEOUT) > 0
+
+ // Handle animations
+ void qp_internal_animation_tick(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
+
+ // Flush (render) dirty regions to corresponding displays
+ for (uint8_t i = 0; i < QP_NUM_DEVICES; i++) {
+ if (qp_devices[i] != NULL) {
+ qp_flush(qp_devices[i]);
+ }
+ }
+}
diff --git a/quantum/painter/qp_internal_driver.h b/quantum/painter/qp_internal_driver.h
index 82a0178a73..69da966f8c 100644
--- a/quantum/painter/qp_internal_driver.h
+++ b/quantum/painter/qp_internal_driver.h
@@ -1,4 +1,4 @@
-// Copyright 2021 Nick Brassel (@tzarc)
+// Copyright 2021-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -19,7 +19,7 @@ typedef bool (*painter_driver_append_pixels)(painter_device_t device, uint8_t *t
typedef bool (*painter_driver_append_pixdata)(painter_device_t device, uint8_t *target_buffer, uint32_t pixdata_offset, uint8_t pixdata_byte);
// Driver vtable definition
-struct painter_driver_vtable_t {
+typedef struct painter_driver_vtable_t {
painter_driver_init_func init;
painter_driver_power_func power;
painter_driver_clear_func clear;
@@ -29,7 +29,7 @@ struct painter_driver_vtable_t {
painter_driver_convert_palette_func palette_convert;
painter_driver_append_pixels append_pixels;
painter_driver_append_pixdata append_pixdata;
-};
+} painter_driver_vtable_t;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Comms callbacks
@@ -39,28 +39,28 @@ typedef bool (*painter_driver_comms_start_func)(painter_device_t device);
typedef void (*painter_driver_comms_stop_func)(painter_device_t device);
typedef uint32_t (*painter_driver_comms_send_func)(painter_device_t device, const void *data, uint32_t byte_count);
-struct painter_comms_vtable_t {
+typedef struct painter_comms_vtable_t {
painter_driver_comms_init_func comms_init;
painter_driver_comms_start_func comms_start;
painter_driver_comms_stop_func comms_stop;
painter_driver_comms_send_func comms_send;
-};
+} painter_comms_vtable_t;
typedef void (*painter_driver_comms_send_command_func)(painter_device_t device, uint8_t cmd);
typedef void (*painter_driver_comms_bulk_command_sequence)(painter_device_t device, const uint8_t *sequence, size_t sequence_len);
-struct painter_comms_with_command_vtable_t {
- struct painter_comms_vtable_t base; // must be first, so this object can be cast from the painter_comms_vtable_t* type
+typedef struct painter_comms_with_command_vtable_t {
+ painter_comms_vtable_t base; // must be first, so this object can be cast from the painter_comms_vtable_t* type
painter_driver_comms_send_command_func send_command;
painter_driver_comms_bulk_command_sequence bulk_command_sequence;
-};
+} painter_comms_with_command_vtable_t;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Driver base definition
-struct painter_driver_t {
- const struct painter_driver_vtable_t *driver_vtable;
- const struct painter_comms_vtable_t * comms_vtable;
+typedef struct painter_driver_t {
+ const painter_driver_vtable_t *driver_vtable;
+ const painter_comms_vtable_t * comms_vtable;
// Flag signifying if validation was successful
bool validate_ok;
@@ -81,4 +81,9 @@ struct painter_driver_t {
// Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it.
void *comms_config;
-};
+} painter_driver_t;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Device internals
+
+bool qp_internal_register_device(painter_device_t driver);
diff --git a/quantum/painter/qp_stream.h b/quantum/painter/qp_stream.h
index c0e745adc1..4f2b612e43 100644
--- a/quantum/painter/qp_stream.h
+++ b/quantum/painter/qp_stream.h
@@ -48,14 +48,14 @@ uint32_t qp_stream_write_impl(const void *input_buf, uint32_t member_size, uint3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Stream definition
-struct qp_stream_t {
+typedef struct qp_stream_t {
int16_t (*get)(qp_stream_t *stream);
bool (*put)(qp_stream_t *stream, uint8_t c);
int (*seek)(qp_stream_t *stream, int32_t offset, int origin);
int32_t (*tell)(qp_stream_t *stream);
bool (*is_eof)(qp_stream_t *stream);
void (*close)(qp_stream_t *stream);
-};
+} qp_stream_t;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Memory streams
diff --git a/quantum/painter/rules.mk b/quantum/painter/rules.mk
index 199e406dd6..7752936cbd 100644
--- a/quantum/painter/rules.mk
+++ b/quantum/painter/rules.mk
@@ -24,6 +24,7 @@ SRC += \
$(QUANTUM_DIR)/unicode/utf8.c \
$(QUANTUM_DIR)/color.c \
$(QUANTUM_DIR)/painter/qp.c \
+ $(QUANTUM_DIR)/painter/qp_internal.c \
$(QUANTUM_DIR)/painter/qp_stream.c \
$(QUANTUM_DIR)/painter/qgf.c \
$(QUANTUM_DIR)/painter/qff.c \
diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c
index 75bb5f81fc..abb3817b5f 100644
--- a/quantum/pointing_device/pointing_device.c
+++ b/quantum/pointing_device/pointing_device.c
@@ -74,7 +74,8 @@ uint16_t pointing_device_get_shared_cpi(void) {
#endif // defined(SPLIT_POINTING_ENABLE)
-static report_mouse_t local_mouse_report = {};
+static report_mouse_t local_mouse_report = {};
+static bool pointing_device_force_send = false;
extern const pointing_device_driver_t pointing_device_driver;
@@ -163,11 +164,11 @@ __attribute__((weak)) void pointing_device_init(void) {
* This sends the mouse report generated by pointing_device_task if changed since the last report. Once send zeros mouse report except buttons.
*
*/
-__attribute__((weak)) void pointing_device_send(void) {
- static report_mouse_t old_report = {};
+__attribute__((weak)) bool pointing_device_send(void) {
+ static report_mouse_t old_report = {};
+ bool should_send_report = has_mouse_report_changed(&local_mouse_report, &old_report);
- // If you need to do other things, like debugging, this is the place to do it.
- if (has_mouse_report_changed(&local_mouse_report, &old_report)) {
+ if (should_send_report) {
host_mouse_send(&local_mouse_report);
}
// send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
@@ -175,6 +176,8 @@ __attribute__((weak)) void pointing_device_send(void) {
memset(&local_mouse_report, 0, sizeof(local_mouse_report));
local_mouse_report.buttons = buttons;
memcpy(&old_report, &local_mouse_report, sizeof(local_mouse_report));
+
+ return should_send_report || buttons;
}
/**
@@ -220,18 +223,18 @@ report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report) {
* It applies any optional configuration e.g. rotation or axis inversion and then initiates a send.
*
*/
-__attribute__((weak)) void pointing_device_task(void) {
+__attribute__((weak)) bool pointing_device_task(void) {
#if defined(SPLIT_POINTING_ENABLE)
// Don't poll the target side pointing device.
if (!is_keyboard_master()) {
- return;
+ return false;
};
#endif
#if (POINTING_DEVICE_TASK_THROTTLE_MS > 0)
static uint32_t last_exec = 0;
if (timer_elapsed32(last_exec) < POINTING_DEVICE_TASK_THROTTLE_MS) {
- return;
+ return false;
}
last_exec = timer_read32();
#endif
@@ -286,7 +289,11 @@ __attribute__((weak)) void pointing_device_task(void) {
report_mouse_t mousekey_report = mousekey_get_report();
local_mouse_report.buttons = local_mouse_report.buttons | mousekey_report.buttons;
#endif
- pointing_device_send();
+
+ const bool send_report = pointing_device_send() || pointing_device_force_send;
+ pointing_device_force_send = false;
+
+ return send_report;
}
/**
@@ -304,7 +311,8 @@ report_mouse_t pointing_device_get_report(void) {
* @param[in] mouse_report
*/
void pointing_device_set_report(report_mouse_t mouse_report) {
- local_mouse_report = mouse_report;
+ pointing_device_force_send = has_mouse_report_changed(&local_mouse_report, &mouse_report);
+ memcpy(&local_mouse_report, &mouse_report, sizeof(local_mouse_report));
}
/**
diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h
index d430e6cfa4..afd653eaee 100644
--- a/quantum/pointing_device/pointing_device.h
+++ b/quantum/pointing_device/pointing_device.h
@@ -28,6 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(POINTING_DEVICE_DRIVER_adns5050)
# include "drivers/sensors/adns5050.h"
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
+#elif defined(POINTING_DEVICE_DRIVER_pmw3320)
+# include "drivers/sensors/pmw3320.h"
+# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
#elif defined(POINTING_DEVICE_DRIVER_adns9800)
# include "spi_master.h"
# include "drivers/sensors/adns9800.h"
@@ -97,8 +100,8 @@ typedef int16_t clamp_range_t;
#endif
void pointing_device_init(void);
-void pointing_device_task(void);
-void pointing_device_send(void);
+bool pointing_device_task(void);
+bool pointing_device_send(void);
report_mouse_t pointing_device_get_report(void);
void pointing_device_set_report(report_mouse_t mouse_report);
uint16_t pointing_device_get_cpi(void);
diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c
index d6f29c062e..9a4315f76f 100644
--- a/quantum/pointing_device/pointing_device_drivers.c
+++ b/quantum/pointing_device/pointing_device_drivers.c
@@ -50,6 +50,28 @@ const pointing_device_driver_t pointing_device_driver = {
};
// clang-format on
+#elif defined(POINTING_DEVICE_DRIVER_pmw3320)
+report_mouse_t pmw3320_get_report(report_mouse_t mouse_report) {
+ report_pmw3320_t data = pmw3320_read_burst();
+
+ if (data.dx != 0 || data.dy != 0) {
+ pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
+ mouse_report.x = (mouse_xy_report_t)data.dx;
+ mouse_report.y = (mouse_xy_report_t)data.dy;
+ }
+
+ return mouse_report;
+}
+
+// clang-format off
+const pointing_device_driver_t pointing_device_driver = {
+ .init = pmw3320_init,
+ .get_report = pmw3320_get_report,
+ .set_cpi = pmw3320_set_cpi,
+ .get_cpi = pmw3320_get_cpi,
+};
+// clang-format on
+
#elif defined(POINTING_DEVICE_DRIVER_adns9800)
report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report) {
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index aad1a164ae..62c347ae0c 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -400,12 +400,10 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
// 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)
+# ifdef 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);
+ const bool is_hold_on_interrupt = false;
# endif
# endif
if (IS_RETRO(keycode)
@@ -443,12 +441,8 @@ 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(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- if (autoshift_flags.in_progress
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- && get_hold_on_other_key_press(keycode, record)
-# endif
- ) {
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+ if (autoshift_flags.in_progress && get_hold_on_other_key_press(keycode, record)) {
autoshift_end(KC_NO, now, false, &autoshift_lastrecord);
}
# endif
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c
index 94302b29ae..8f2ee1db8b 100644
--- a/quantum/process_keycode/process_caps_word.c
+++ b/quantum/process_keycode/process_caps_word.c
@@ -14,6 +14,54 @@
#include "process_caps_word.h"
+#ifdef CAPS_WORD_INVERT_ON_SHIFT
+static uint8_t held_mods = 0;
+
+static bool handle_shift(uint16_t keycode, keyrecord_t* record) {
+ switch (keycode) {
+ case OSM(MOD_LSFT):
+ keycode = KC_LSFT;
+ break;
+ case OSM(MOD_RSFT):
+ keycode = KC_RSFT;
+ break;
+
+# ifndef NO_ACTION_TAPPING
+ case QK_MOD_TAP ... QK_MOD_TAP_MAX:
+ if (record->tap.count == 0) { // Mod-tap key is held.
+ switch (QK_MOD_TAP_GET_MODS(keycode)) {
+ case MOD_LSFT:
+ keycode = KC_LSFT;
+ break;
+ case MOD_RSFT:
+ keycode = KC_RSFT;
+ break;
+ }
+ }
+# endif // NO_ACTION_TAPPING
+ }
+
+ if (keycode == KC_LSFT || keycode == KC_RSFT) {
+ const uint8_t mod = MOD_BIT(keycode);
+
+ if (is_caps_word_on()) {
+ if (record->event.pressed) {
+ held_mods |= mod;
+ } else {
+ held_mods &= ~mod;
+ }
+ return false;
+ } else if ((held_mods & mod) != 0) {
+ held_mods &= ~mod;
+ del_mods(mod);
+ return record->event.pressed;
+ }
+ }
+
+ return true;
+}
+#endif // CAPS_WORD_INVERT_ON_SHIFT
+
bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
if (keycode == QK_CAPS_WORD_TOGGLE) {
if (record->event.pressed) {
@@ -21,6 +69,11 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
}
return false;
}
+#ifdef CAPS_WORD_INVERT_ON_SHIFT
+ if (!handle_shift(keycode, record)) {
+ return false;
+ }
+#endif // CAPS_WORD_INVERT_ON_SHIFT
#ifndef NO_ACTION_ONESHOT
const uint8_t mods = get_mods() | get_oneshot_mods();
@@ -111,12 +164,14 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
if (record->tap.count == 0) { // Mod-tap key is held.
const uint8_t mods = QK_MOD_TAP_GET_MODS(keycode);
switch (mods) {
+# ifndef CAPS_WORD_INVERT_ON_SHIFT
case MOD_LSFT:
keycode = KC_LSFT;
break;
case MOD_RSFT:
keycode = KC_RSFT;
break;
+# endif // CAPS_WORD_INVERT_ON_SHIFT
case MOD_RSFT | MOD_RALT:
keycode = RSFT(KC_RALT);
break;
@@ -124,6 +179,9 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
return true;
default:
caps_word_off();
+# ifdef CAPS_WORD_INVERT_ON_SHIFT
+ add_mods(held_mods);
+# endif // CAPS_WORD_INVERT_ON_SHIFT
return true;
}
} else {
@@ -163,12 +221,20 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
clear_weak_mods();
#endif // AUTO_SHIFT_ENABLE
if (caps_word_press_user(keycode)) {
+#ifdef CAPS_WORD_INVERT_ON_SHIFT
+ if (held_mods) {
+ set_weak_mods(get_weak_mods() ^ MOD_BIT(KC_LSFT));
+ }
+#endif // CAPS_WORD_INVERT_ON_SHIFT
send_keyboard_report();
return true;
}
}
caps_word_off();
+#ifdef CAPS_WORD_INVERT_ON_SHIFT
+ add_mods(held_mods);
+#endif // CAPS_WORD_INVERT_ON_SHIFT
return true;
}
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 8597649c92..b1b49d3019 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "keymap_common.h"
#include "print.h"
#include "process_combo.h"
#include "action_tapping.h"
@@ -144,7 +145,7 @@ static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH];
static inline void release_combo(uint16_t combo_index, combo_t *combo) {
if (combo->keycode) {
keyrecord_t record = {
- .event = MAKE_KEYEVENT(KEYLOC_COMBO, KEYLOC_COMBO, false),
+ .event = MAKE_COMBOEVENT(false),
.keycode = combo->keycode,
};
#ifndef NO_ACTION_TAPPING
@@ -232,7 +233,7 @@ static inline void dump_key_buffer(void) {
process_record(record);
#endif
}
- record->event.time = 0;
+ record->event.type = TICK_EVENT;
#if defined(CAPS_WORD_ENABLE) && defined(AUTO_SHIFT_ENABLE)
// Edge case: preserve the weak Left Shift mod if both Caps Word and
@@ -332,8 +333,8 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
KEY_STATE_DOWN(state, key_index);
if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) {
// this in the end executes the combo when the key_buffer is dumped.
- record->keycode = combo->keycode;
- record->event.key = MAKE_KEYPOS(KEYLOC_COMBO, KEYLOC_COMBO);
+ record->keycode = combo->keycode;
+ record->event.type = COMBO_EVENT;
qrecord->combo_index = combo_index;
ACTIVATE_COMBO(combo);
@@ -342,7 +343,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
} else {
// key was part of the combo but not the last one, "disable" it
// by making it a TICK event.
- record->event.time = 0;
+ record->event.type = TICK_EVENT;
}
}
drop_combo_from_buffer(combo_index);
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
index c2e7e7716f..bf6af566e2 100644
--- a/quantum/process_keycode/process_dynamic_macro.c
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -29,7 +29,7 @@ void dynamic_macro_led_blink(void) {
/* User hooks for Dynamic Macros */
-__attribute__((weak)) void dynamic_macro_record_start_user(void) {
+__attribute__((weak)) void dynamic_macro_record_start_user(int8_t direction) {
dynamic_macro_led_blink();
}
@@ -62,10 +62,10 @@ __attribute__((weak)) bool dynamic_macro_valid_key_user(uint16_t keycode, keyrec
* @param[out] macro_pointer The new macro buffer iterator.
* @param[in] macro_buffer The macro buffer used to initialize macro_pointer.
*/
-void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer) {
+void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer, int8_t direction) {
dprintln("dynamic macro recording: started");
- dynamic_macro_record_start_user();
+ dynamic_macro_record_start_user(direction);
clear_keyboard();
layer_clear();
@@ -213,11 +213,11 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
if (!record->event.pressed) {
switch (keycode) {
case QK_DYNAMIC_MACRO_RECORD_START_1:
- dynamic_macro_record_start(&macro_pointer, macro_buffer);
+ dynamic_macro_record_start(&macro_pointer, macro_buffer, +1);
macro_id = 1;
return false;
case QK_DYNAMIC_MACRO_RECORD_START_2:
- dynamic_macro_record_start(&macro_pointer, r_macro_buffer);
+ dynamic_macro_record_start(&macro_pointer, r_macro_buffer, -1);
macro_id = 2;
return false;
case QK_DYNAMIC_MACRO_PLAY_1:
diff --git a/quantum/process_keycode/process_dynamic_macro.h b/quantum/process_keycode/process_dynamic_macro.h
index 39036541b8..ab70726897 100644
--- a/quantum/process_keycode/process_dynamic_macro.h
+++ b/quantum/process_keycode/process_dynamic_macro.h
@@ -35,7 +35,7 @@
void dynamic_macro_led_blink(void);
bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record);
-void dynamic_macro_record_start_user(void);
+void dynamic_macro_record_start_user(int8_t direction);
void dynamic_macro_play_user(int8_t direction);
void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record);
void dynamic_macro_record_end_user(int8_t direction);
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index 8ba98bd4bb..d5ad61ba85 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -173,13 +173,13 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
#ifdef STENO_ENABLE_ALL
case QK_STENO_BOLT:
- if (IS_PRESSED(record->event)) {
+ if (record->event.pressed) {
steno_set_mode(STENO_MODE_BOLT);
}
return false;
case QK_STENO_GEMINI:
- if (IS_PRESSED(record->event)) {
+ if (record->event.pressed) {
steno_set_mode(STENO_MODE_GEMINI);
}
return false;
@@ -193,7 +193,7 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) {
}
#endif // STENO_COMBINEDMAP
case STN__MIN ... STN__MAX:
- if (IS_PRESSED(record->event)) {
+ if (record->event.pressed) {
n_pressed_keys++;
switch (mode) {
#ifdef STENO_ENABLE_BOLT
diff --git a/quantum/programmable_button.h b/quantum/programmable_button.h
index e8c916d75c..4c2cd534fe 100644
--- a/quantum/programmable_button.h
+++ b/quantum/programmable_button.h
@@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
/**
- * \defgroup programmable_button
+ * \file
*
- * HID Programmable Buttons
+ * \defgroup programmable_button HID Programmable Buttons
* \{
*/
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 315fa25568..38186a48a3 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -18,7 +18,7 @@
#include "platform_deps.h"
#include "wait.h"
#include "matrix.h"
-#include "keymap.h"
+#include "keyboard.h"
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
@@ -36,6 +36,9 @@
# include "rgb_matrix.h"
#endif
+#include "keymap_common.h"
+#include "quantum_keycodes.h"
+#include "keycode_config.h"
#include "action_layer.h"
#include "eeconfig.h"
#include "bootloader.h"
@@ -44,10 +47,12 @@
#include "sync_timer.h"
#include "gpio.h"
#include "atomic_util.h"
+#include "host.h"
#include "led.h"
#include "action_util.h"
#include "action_tapping.h"
#include "print.h"
+#include "debug.h"
#include "suspend.h"
#include <stddef.h>
#include <stdlib.h>
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index bbb706da69..1f3912cf7e 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -459,14 +459,7 @@ void rgb_matrix_indicators_advanced(effect_params_t *params) {
* and not sure which would be better. Otherwise, this should be called from
* rgb_task_render, right before the iter++ line.
*/
-#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
- uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1);
- uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT;
- if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
-#else
- uint8_t min = 0;
- uint8_t max = RGB_MATRIX_LED_COUNT;
-#endif
+ RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1);
rgb_matrix_indicators_advanced_kb(min, max);
}
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index 62078f6e60..6b373d0bcd 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -52,34 +52,36 @@
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
# if defined(RGB_MATRIX_SPLIT)
-# define RGB_MATRIX_USE_LIMITS(min, max) \
- uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
+# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
+ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \
uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
# else
-# define RGB_MATRIX_USE_LIMITS(min, max) \
- uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
- uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
+# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
+ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
+ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
# endif
#else
# if defined(RGB_MATRIX_SPLIT)
-# define RGB_MATRIX_USE_LIMITS(min, max) \
+# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
uint8_t min = 0; \
uint8_t max = RGB_MATRIX_LED_COUNT; \
const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
# else
-# define RGB_MATRIX_USE_LIMITS(min, max) \
- uint8_t min = 0; \
+# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
+ uint8_t min = 0; \
uint8_t max = RGB_MATRIX_LED_COUNT;
# endif
#endif
+#define RGB_MATRIX_USE_LIMITS(min, max) RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter)
+
#define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \
if (i >= led_min && i < led_max) { \
rgb_matrix_set_color(i, r, g, b); \
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index 5b81915845..415c66f115 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -359,7 +359,6 @@ LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
static void init(void) {}
static void flush(void) {
- // Assumes use of RGB_DI_PIN
ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
}
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 19d80e0097..02188df95b 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -21,6 +21,7 @@
#include "rgblight.h"
#include "color.h"
#include "debug.h"
+#include "util.h"
#include "led_tables.h"
#include <lib/lib8tion/lib8tion.h>
#ifdef EEPROM_ENABLE
@@ -30,13 +31,6 @@
# include "velocikey.h"
#endif
-#ifndef MIN
-# define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-#ifndef MAX
-# define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
#ifdef RGBLIGHT_SPLIT
/* for split keyboard */
# define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE
@@ -422,6 +416,10 @@ void rgblight_disable_noeeprom(void) {
rgblight_set();
}
+void rgblight_enabled_noeeprom(bool state) {
+ state ? rgblight_enable_noeeprom() : rgblight_disable_noeeprom();
+}
+
bool rgblight_is_enabled(void) {
return rgblight_config.enable;
}
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 7693888462..2e85541313 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -174,6 +174,10 @@ typedef struct {
uint8_t val;
} rgblight_segment_t;
+// rgblight_set_layer_state doesn't take effect until the next time
+// rgblight_task runs, so timers must be enabled for layers to work.
+# define RGBLIGHT_USE_TIMER
+
# define RGBLIGHT_END_SEGMENT_INDEX (255)
# define RGBLIGHT_END_SEGMENTS \
{ RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0 }
@@ -321,6 +325,7 @@ void rgblight_enable(void);
void rgblight_enable_noeeprom(void);
void rgblight_disable(void);
void rgblight_disable_noeeprom(void);
+void rgblight_enabled_noeeprom(bool state);
/* hue, sat, val change */
void rgblight_increase_hue(void);
diff --git a/quantum/secure.h b/quantum/secure.h
index bb2ba50f31..ae9b5b9045 100644
--- a/quantum/secure.h
+++ b/quantum/secure.h
@@ -3,10 +3,15 @@
#pragma once
-/** \file
+/**
+ * \file
*
- * Exposes a set of functionality to act as a virtual padlock for your device
- * ... As long as that padlock is made of paper and its currently raining.
+ * \defgroup secure Secure API
+ *
+ * \brief Exposes a set of functionality to act as a virtual padlock for your device
+ * ...as long as that padlock is made of paper and it's currently raining.
+ *
+ * \{
*/
#include <stdint.h>
@@ -77,3 +82,5 @@ bool secure_hook_user(secure_status_t secure_status);
/** \brief keyboard hook called when changing secure status device
*/
bool secure_hook_kb(secure_status_t secure_status);
+
+/** \} */
diff --git a/quantum/send_string/send_string.h b/quantum/send_string/send_string.h
index 4eb55b88dc..dbaed43ebc 100644
--- a/quantum/send_string/send_string.h
+++ b/quantum/send_string/send_string.h
@@ -15,9 +15,11 @@
*/
/**
- * \defgroup send_string
+ * \file
*
- * Send String API. These functions allow you to create macros by typing out sequences of keystrokes.
+ * \defgroup send_string Send String API
+ *
+ * \brief These functions allow you to create macros by typing out sequences of keystrokes.
* \{
*/
diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h
index 18d3826b83..4d4d2b9570 100644
--- a/quantum/split_common/transaction_id_define.h
+++ b/quantum/split_common/transaction_id_define.h
@@ -92,6 +92,10 @@ enum serial_transaction_id {
PUT_HAPTIC,
#endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
+#if defined(SPLIT_ACTIVITY_ENABLE)
+ PUT_ACTIVITY,
+#endif // SPLIT_ACTIVITY_ENABLE
+
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
PUT_RPC_INFO,
PUT_RPC_REQ_DATA,
@@ -109,6 +113,10 @@ enum serial_transaction_id {
SPLIT_TRANSACTION_IDS_USER,
#endif // SPLIT_TRANSACTION_IDS_USER
+#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+ PUT_DETECTED_OS,
+#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+
NUM_TOTAL_TRANSACTIONS
};
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index 8e1961b586..b3c80f1194 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -790,6 +790,63 @@ static void haptic_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla
#endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
+#if defined(SPLIT_ACTIVITY_ENABLE)
+
+static bool activity_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ static uint32_t last_update = 0;
+ split_slave_activity_sync_t activity_sync;
+ activity_sync.matrix_timestamp = last_matrix_activity_time();
+ activity_sync.encoder_timestamp = last_encoder_activity_time();
+ activity_sync.pointing_device_timestamp = last_pointing_device_activity_time();
+ return send_if_data_mismatch(PUT_ACTIVITY, &last_update, &activity_sync, &split_shmem->activity_sync, sizeof(activity_sync));
+}
+
+static void activity_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ set_activity_timestamps(split_shmem->activity_sync.matrix_timestamp, split_shmem->activity_sync.encoder_timestamp, split_shmem->activity_sync.pointing_device_timestamp);
+}
+
+// clang-format off
+# define TRANSACTIONS_ACTIVITY_MASTER() TRANSACTION_HANDLER_MASTER(activity)
+# define TRANSACTIONS_ACTIVITY_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(activity)
+# define TRANSACTIONS_ACTIVITY_REGISTRATIONS [PUT_ACTIVITY] = trans_initiator2target_initializer(activity_sync),
+// clang-format on
+
+#else // defined(SPLIT_ACTIVITY_ENABLE)
+
+# define TRANSACTIONS_ACTIVITY_MASTER()
+# define TRANSACTIONS_ACTIVITY_SLAVE()
+# define TRANSACTIONS_ACTIVITY_REGISTRATIONS
+
+#endif // defined(SPLIT_ACTIVITY_ENABLE)
+
+////////////////////////////////////////////////////
+// Detected OS
+
+#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+
+static bool detected_os_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ static uint32_t last_detected_os_update = 0;
+ os_variant_t detected_os = detected_host_os();
+ bool okay = send_if_condition(PUT_DETECTED_OS, &last_detected_os_update, (detected_os != split_shmem->detected_os), &detected_os, sizeof(os_variant_t));
+ return okay;
+}
+
+static void detected_os_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ slave_update_detected_host_os(split_shmem->detected_os);
+}
+
+# define TRANSACTIONS_DETECTED_OS_MASTER() TRANSACTION_HANDLER_MASTER(detected_os)
+# define TRANSACTIONS_DETECTED_OS_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(detected_os)
+# define TRANSACTIONS_DETECTED_OS_REGISTRATIONS [PUT_DETECTED_OS] = trans_initiator2target_initializer(detected_os),
+
+#else // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+
+# define TRANSACTIONS_DETECTED_OS_MASTER()
+# define TRANSACTIONS_DETECTED_OS_SLAVE()
+# define TRANSACTIONS_DETECTED_OS_REGISTRATIONS
+
+#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+
////////////////////////////////////////////////////
split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
@@ -818,6 +875,8 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
TRANSACTIONS_POINTING_REGISTRATIONS
TRANSACTIONS_WATCHDOG_REGISTRATIONS
TRANSACTIONS_HAPTIC_REGISTRATIONS
+ TRANSACTIONS_ACTIVITY_REGISTRATIONS
+ TRANSACTIONS_DETECTED_OS_REGISTRATIONS
// clang-format on
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
@@ -846,6 +905,8 @@ bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix
TRANSACTIONS_POINTING_MASTER();
TRANSACTIONS_WATCHDOG_MASTER();
TRANSACTIONS_HAPTIC_MASTER();
+ TRANSACTIONS_ACTIVITY_MASTER();
+ TRANSACTIONS_DETECTED_OS_MASTER();
return true;
}
@@ -867,6 +928,8 @@ void transactions_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[
TRANSACTIONS_POINTING_SLAVE();
TRANSACTIONS_WATCHDOG_SLAVE();
TRANSACTIONS_HAPTIC_SLAVE();
+ TRANSACTIONS_ACTIVITY_SLAVE();
+ TRANSACTIONS_DETECTED_OS_SLAVE();
}
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index adee4470d2..6f8985cb07 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -122,6 +122,15 @@ typedef struct _split_slave_haptic_sync_t {
} split_slave_haptic_sync_t;
#endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
+#if defined(SPLIT_ACTIVITY_ENABLE)
+# include "keyboard.h"
+typedef struct _split_slave_activity_sync_t {
+ uint32_t matrix_timestamp;
+ uint32_t encoder_timestamp;
+ uint32_t pointing_device_timestamp;
+} split_slave_activity_sync_t;
+#endif // defined(SPLIT_ACTIVITY_ENABLE)
+
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
typedef struct _rpc_sync_info_t {
uint8_t checksum;
@@ -133,6 +142,10 @@ typedef struct _rpc_sync_info_t {
} rpc_sync_info_t;
#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
+#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+# include "os_detection.h"
+#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+
typedef struct _split_shared_memory_t {
#ifdef USE_I2C
int8_t transaction_id;
@@ -204,11 +217,19 @@ typedef struct _split_shared_memory_t {
split_slave_haptic_sync_t haptic_sync;
#endif // defined(HAPTIC_ENABLE)
+#if defined(SPLIT_ACTIVITY_ENABLE)
+ split_slave_activity_sync_t activity_sync;
+#endif // defined(SPLIT_ACTIVITY_ENABLE)
+
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
rpc_sync_info_t rpc_info;
uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
+
+#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
+ os_variant_t detected_os;
+#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
} split_shared_memory_t;
extern split_shared_memory_t *const split_shmem;
diff --git a/quantum/velocikey.c b/quantum/velocikey.c
index 58e14215bb..03e91911f6 100644
--- a/quantum/velocikey.c
+++ b/quantum/velocikey.c
@@ -2,13 +2,7 @@
#include "timer.h"
#include "eeconfig.h"
#include "eeprom.h"
-
-#ifndef MIN
-# define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-#ifndef MAX
-# define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
+#include "util.h"
#define TYPING_SPEED_MAX_VALUE 200
uint8_t typing_speed = 0;