summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action_tapping.c161
-rw-r--r--quantum/matrix.c10
-rw-r--r--quantum/os_detection.c129
-rw-r--r--quantum/os_detection.h38
-rw-r--r--quantum/os_detection/tests/os_detection.cpp164
-rw-r--r--quantum/os_detection/tests/rules.mk5
-rw-r--r--quantum/os_detection/tests/testlist.mk1
-rw-r--r--quantum/rgblight/rgblight.h17
8 files changed, 427 insertions, 98 deletions
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index df3317ac05..b5386a5e17 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -117,6 +117,66 @@ void action_tapping_process(keyrecord_t record) {
}
}
+/* Some conditionally defined helper macros to keep process_tapping more
+ * readable. The conditional definition of tapping_keycode and all the
+ * conditional uses of it are hidden inside macros named TAP_...
+ */
+# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(TAPPING_FORCE_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)
+# else
+# define TAP_DEFINE_KEYCODE
+# endif
+
+# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
+# ifdef RETRO_TAPPING_PER_KEY
+# define TAP_GET_RETRO_TAPPING get_retro_tapping(tapping_keycode, &tapping_key)
+# else
+# define TAP_GET_RETRO_TAPPING true
+# endif
+# define MAYBE_RETRO_SHIFTING(ev) (TAP_GET_RETRO_TAPPING && (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16((ev).time, tapping_key.event.time) < (RETRO_SHIFT + 0))
+# define TAP_IS_LT IS_LT(tapping_keycode)
+# define TAP_IS_MT IS_MT(tapping_keycode)
+# define TAP_IS_RETRO IS_RETRO(tapping_keycode)
+# else
+# define TAP_GET_RETRO_TAPPING false
+# define MAYBE_RETRO_SHIFTING(ev) false
+# define TAP_IS_LT false
+# define TAP_IS_MT false
+# define TAP_IS_RETRO false
+# endif
+
+# ifdef PERMISSIVE_HOLD_PER_KEY
+# define TAP_GET_PERMISSIVE_HOLD get_permissive_hold(tapping_keycode, &tapping_key)
+# elif defined(PERMISSIVE_HOLD)
+# define TAP_GET_PERMISSIVE_HOLD true
+# else
+# define TAP_GET_PERMISSIVE_HOLD false
+# endif
+
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS get_hold_on_other_key_press(tapping_keycode, &tapping_key)
+# elif defined(HOLD_ON_OTHER_KEY_PRESS)
+# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS true
+# else
+# define TAP_GET_HOLD_ON_OTHER_KEY_PRESS false
+# endif
+
+# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
+# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT get_ignore_mod_tap_interrupt(tapping_keycode, &tapping_key)
+# elif defined(IGNORE_MOD_TAP_INTERRUPT)
+# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT true
+# else
+# define TAP_GET_IGNORE_MOD_TAP_INTERRUPT false
+# endif
+
+# ifdef TAPPING_FORCE_HOLD_PER_KEY
+# define TAP_GET_TAPPING_FORCE_HOLD get_tapping_force_hold(tapping_keycode, &tapping_key)
+# elif defined(TAPPING_FORCE_HOLD)
+# define TAP_GET_TAPPING_FORCE_HOLD true
+# else
+# define TAP_GET_TAPPING_FORCE_HOLD false
+# endif
+
/** \brief Tapping
*
* Rule: Tap key is typed(pressed and released) within TAPPING_TERM.
@@ -125,24 +185,11 @@ void action_tapping_process(keyrecord_t record) {
/* return true when key event is processed or consumed. */
bool process_tapping(keyrecord_t *keyp) {
keyevent_t event = keyp->event;
-# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(TAPPING_FORCE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- uint16_t tapping_keycode = get_record_keycode(&tapping_key, false);
-# endif
+ TAP_DEFINE_KEYCODE;
// if tapping
if (IS_TAPPING_PRESSED()) {
- // clang-format off
- if (WITHIN_TAPPING_TERM(event)
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- || (
-# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(tapping_keycode, &tapping_key) &&
-# endif
- (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0)
- )
-# endif
- ) {
- // clang-format on
+ if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
if (tapping_key.tap.count == 0) {
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
@@ -164,57 +211,31 @@ bool process_tapping(keyrecord_t *keyp) {
* useful for long TAPPING_TERM but may prevent fast typing.
*/
// clang-format off
-# if defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
else if (
(
- IS_RELEASED(event) && waiting_buffer_typed(event)
-# ifdef PERMISSIVE_HOLD_PER_KEY
- && get_permissive_hold(tapping_keycode, &tapping_key)
-# elif defined(PERMISSIVE_HOLD)
- && true
-# endif
+ IS_RELEASED(event) && waiting_buffer_typed(event) &&
+ TAP_GET_PERMISSIVE_HOLD
)
// Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT
// unnecessarily and fixes them for Layer Taps.
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- || (
-# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(tapping_keycode, &tapping_key) &&
-# endif
+ || (TAP_GET_RETRO_TAPPING &&
(
// Rolled over the two keys.
- (
- (
- false
-# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- || (
- IS_LT(tapping_keycode)
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- && get_hold_on_other_key_press(tapping_keycode, &tapping_key)
-# endif
- )
-# endif
-# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
- || (
- IS_MT(tapping_keycode)
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- && !get_ignore_mod_tap_interrupt(tapping_keycode, &tapping_key)
-# endif
- )
-# endif
- ) && tapping_key.tap.interrupted == true
+ (tapping_key.tap.interrupted == true && (
+ (TAP_IS_LT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS) ||
+ (TAP_IS_MT && !TAP_GET_IGNORE_MOD_TAP_INTERRUPT)
+ )
)
// Makes Retro Shift ignore [IGNORE_MOD_TAP_INTERRUPT's
// effects on nested taps for MTs and the default
// behavior of LTs] below TAPPING_TERM or RETRO_SHIFT.
|| (
- IS_RETRO(tapping_keycode)
+ TAP_IS_RETRO
&& (event.key.col != tapping_key.event.key.col || event.key.row != tapping_key.event.key.row)
&& IS_RELEASED(event) && waiting_buffer_typed(event)
)
)
)
-# endif
) {
// clang-format on
debug("Tapping: End. No tap. Interfered by typing key\n");
@@ -224,13 +245,12 @@ bool process_tapping(keyrecord_t *keyp) {
// enqueue
return false;
}
-# endif
/* Process release event of a key pressed before tapping starts
* Without this unexpected repeating will occur with having fast repeating setting
* https://github.com/tmk/tmk_keyboard/issues/60
*/
else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) {
- // Modifier should be retained till end of this tapping.
+ // Modifier/Layer should be retained till end of this tapping.
action_t action = layer_switch_get_action(event.key);
switch (action.kind.id) {
case ACT_LMODS:
@@ -243,6 +263,16 @@ bool process_tapping(keyrecord_t *keyp) {
if (action.key.mods && keyp->tap.count == 0) return false;
if (IS_MOD(action.key.code)) return false;
break;
+ case ACT_LAYER_TAP:
+ case ACT_LAYER_TAP_EXT:
+ switch (action.layer_tap.code) {
+ case 0 ...(OP_TAP_TOGGLE - 1):
+ case OP_ON_OFF:
+ case OP_OFF_ON:
+ case OP_SET_CLEAR:
+ return false;
+ }
+ break;
}
// Release of key should be process immediately.
debug("Tapping: release event of a key pressed before tapping\n");
@@ -252,11 +282,7 @@ bool process_tapping(keyrecord_t *keyp) {
// set interrupted flag when other key preesed during tapping
if (event.pressed) {
tapping_key.tap.interrupted = true;
-# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
-# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
- if (get_hold_on_other_key_press(tapping_keycode, &tapping_key))
-# endif
- {
+ if (TAP_GET_HOLD_ON_OTHER_KEY_PRESS) {
debug("Tapping: End. No tap. Interfered by pressed key\n");
process_record(&tapping_key);
tapping_key = (keyrecord_t){};
@@ -264,7 +290,6 @@ bool process_tapping(keyrecord_t *keyp) {
// enqueue
return false;
}
-# endif
}
// enqueue
return false;
@@ -357,27 +382,10 @@ bool process_tapping(keyrecord_t *keyp) {
}
}
} else if (IS_TAPPING_RELEASED()) {
- // clang-format off
- if (WITHIN_TAPPING_TERM(event)
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- || (
-# ifdef RETRO_TAPPING_PER_KEY
- get_retro_tapping(tapping_keycode, &tapping_key) &&
-# endif
- (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16(event.time, tapping_key.event.time) < (RETRO_SHIFT + 0)
- )
-# endif
- ) {
- // clang-format on
+ if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
if (event.pressed) {
if (IS_TAPPING_RECORD(keyp)) {
-//# ifndef TAPPING_FORCE_HOLD
-# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY)
- if (
-# ifdef TAPPING_FORCE_HOLD_PER_KEY
- !get_tapping_force_hold(tapping_keycode, &tapping_key) &&
-# endif
- !tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
+ if (!TAP_GET_TAPPING_FORCE_HOLD && !tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
// sequential tap.
keyp->tap = tapping_key.tap;
if (keyp->tap.count < 15) keyp->tap.count += 1;
@@ -389,7 +397,6 @@ bool process_tapping(keyrecord_t *keyp) {
debug_tapping_key();
return true;
}
-# endif
// FIX: start new tap again
tapping_key = *keyp;
return true;
diff --git a/quantum/matrix.c b/quantum/matrix.c
index db683104ed..0de65c6cdd 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -46,6 +46,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define SPLIT_MUTABLE_COL const
#endif
+#ifndef MATRIX_INPUT_PRESSED_STATE
+# define MATRIX_INPUT_PRESSED_STATE 0
+#endif
+
#ifdef DIRECT_PINS
static SPLIT_MUTABLE pin_t direct_pins[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS;
#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
@@ -93,7 +97,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) {
static inline uint8_t readMatrixPin(pin_t pin) {
if (pin != NO_PIN) {
- return readPin(pin);
+ return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
} else {
return 1;
}
@@ -121,9 +125,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[]
matrix_row_t row_shifter = MATRIX_ROW_SHIFTER;
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) {
pin_t pin = direct_pins[current_row][col_index];
- if (pin != NO_PIN) {
- current_row_value |= readPin(pin) ? 0 : row_shifter;
- }
+ current_row_value |= readMatrixPin(pin) ? 0 : row_shifter;
}
// Update the matrix
diff --git a/quantum/os_detection.c b/quantum/os_detection.c
new file mode 100644
index 0000000000..b1511afb14
--- /dev/null
+++ b/quantum/os_detection.c
@@ -0,0 +1,129 @@
+/* Copyright 2022 Ruslan Sayfutdinov (@KapJI)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "os_detection.h"
+
+#include <string.h>
+
+#ifdef OS_DETECTION_DEBUG_ENABLE
+# include "eeconfig.h"
+# include "eeprom.h"
+# include "print.h"
+
+# define STORED_USB_SETUPS 50
+# define EEPROM_USER_OFFSET (uint8_t*)EECONFIG_SIZE
+
+uint16_t usb_setups[STORED_USB_SETUPS];
+#endif
+
+#ifdef OS_DETECTION_ENABLE
+struct setups_data_t {
+ uint8_t count;
+ uint8_t cnt_02;
+ uint8_t cnt_04;
+ uint8_t cnt_ff;
+ uint16_t last_wlength;
+ os_variant_t detected_os;
+};
+
+struct setups_data_t setups_data = {
+ .count = 0,
+ .cnt_02 = 0,
+ .cnt_04 = 0,
+ .cnt_ff = 0,
+ .detected_os = OS_UNSURE,
+};
+
+// Some collected sequences of wLength can be found in tests.
+void make_guess(void) {
+ if (setups_data.count < 3) {
+ return;
+ }
+ if (setups_data.cnt_ff >= 2 && setups_data.cnt_04 >= 1) {
+ setups_data.detected_os = OS_WINDOWS;
+ return;
+ }
+ if (setups_data.count == setups_data.cnt_ff) {
+ // Linux has 3 packets with 0xFF.
+ setups_data.detected_os = OS_LINUX;
+ return;
+ }
+ if (setups_data.count == 5 && setups_data.last_wlength == 0xFF && setups_data.cnt_ff == 1 && setups_data.cnt_02 == 2) {
+ setups_data.detected_os = OS_MACOS;
+ return;
+ }
+ if (setups_data.count == 4 && setups_data.cnt_ff == 0 && setups_data.cnt_02 == 2) {
+ // iOS and iPadOS don't have the last 0xFF packet.
+ setups_data.detected_os = OS_IOS;
+ return;
+ }
+ if (setups_data.cnt_ff == 0 && setups_data.cnt_02 == 3 && setups_data.cnt_04 == 1) {
+ // This is actually PS5.
+ setups_data.detected_os = OS_LINUX;
+ return;
+ }
+ if (setups_data.cnt_ff >= 1 && setups_data.cnt_02 == 0 && setups_data.cnt_04 == 0) {
+ // This is actually Quest 2 or Nintendo Switch.
+ setups_data.detected_os = OS_LINUX;
+ return;
+ }
+}
+
+void process_wlength(const uint16_t w_length) {
+# ifdef OS_DETECTION_DEBUG_ENABLE
+ usb_setups[setups_data.count] = w_length;
+# endif
+ setups_data.count++;
+ setups_data.last_wlength = w_length;
+ if (w_length == 0x2) {
+ setups_data.cnt_02++;
+ } else if (w_length == 0x4) {
+ setups_data.cnt_04++;
+ } else if (w_length == 0xFF) {
+ setups_data.cnt_ff++;
+ }
+ make_guess();
+}
+
+os_variant_t detected_host_os(void) {
+ return setups_data.detected_os;
+}
+
+void erase_wlength_data(void) {
+ memset(&setups_data, 0, sizeof(setups_data));
+}
+#endif // OS_DETECTION_ENABLE
+
+#ifdef OS_DETECTION_DEBUG_ENABLE
+void print_stored_setups(void) {
+# ifdef CONSOLE_ENABLE
+ uint8_t cnt = eeprom_read_byte(EEPROM_USER_OFFSET);
+ for (uint16_t i = 0; i < cnt; ++i) {
+ uint16_t* addr = (uint16_t*)EEPROM_USER_OFFSET + i * sizeof(uint16_t) + sizeof(uint8_t);
+ xprintf("i: %d, wLength: 0x%02X\n", i, eeprom_read_word(addr));
+ }
+# endif
+}
+
+void store_setups_in_eeprom(void) {
+ eeprom_update_byte(EEPROM_USER_OFFSET, setups_data.count);
+ for (uint16_t i = 0; i < setups_data.count; ++i) {
+ uint16_t* addr = (uint16_t*)EEPROM_USER_OFFSET + i * sizeof(uint16_t) + sizeof(uint8_t);
+ eeprom_update_word(addr, usb_setups[i]);
+ }
+}
+
+#endif // OS_DETECTION_DEBUG_ENABLE
diff --git a/quantum/os_detection.h b/quantum/os_detection.h
new file mode 100644
index 0000000000..e643dcd27f
--- /dev/null
+++ b/quantum/os_detection.h
@@ -0,0 +1,38 @@
+/* Copyright 2022 Ruslan Sayfutdinov (@KapJI)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#ifdef OS_DETECTION_ENABLE
+typedef enum {
+ OS_UNSURE,
+ OS_LINUX,
+ OS_WINDOWS,
+ OS_MACOS,
+ OS_IOS,
+} os_variant_t;
+
+void process_wlength(const uint16_t w_length);
+os_variant_t detected_host_os(void);
+void erase_wlength_data(void);
+#endif
+
+#ifdef OS_DETECTION_DEBUG_ENABLE
+void print_stored_setups(void);
+void store_setups_in_eeprom(void);
+#endif
diff --git a/quantum/os_detection/tests/os_detection.cpp b/quantum/os_detection/tests/os_detection.cpp
new file mode 100644
index 0000000000..102349852e
--- /dev/null
+++ b/quantum/os_detection/tests/os_detection.cpp
@@ -0,0 +1,164 @@
+/* Copyright 2022 Ruslan Sayfutdinov (@KapJI)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gtest/gtest.h"
+
+extern "C" {
+#include "os_detection.h"
+}
+
+class OsDetectionTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ erase_wlength_data();
+ }
+};
+
+os_variant_t check_sequence(const std::vector<uint16_t> &w_lengths) {
+ for (auto &w_length : w_lengths) {
+ process_wlength(w_length);
+ }
+ return detected_host_os();
+}
+
+/* Some collected data.
+
+ChibiOS:
+Windows 10: [FF, FF, 4, 24, 4, 24, 4, FF, 24, FF, 4, FF, 24, 4, 24, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A, 20A]
+Windows 10 (another host): [FF, FF, 4, 24, 4, 24, 4, 24, 4, 24, 4, 24]
+macOS 12.5: [2, 24, 2, 28, FF]
+iOS/iPadOS 15.6: [2, 24, 2, 28]
+Linux (including Android, Raspberry Pi and WebOS TV): [FF, FF, FF]
+PS5: [2, 4, 2, 28, 2, 24]
+Nintendo Switch: [82, FF, 40, 40, FF, 40, 40, FF, 40, 40, FF, 40, 40, FF, 40, 40]
+Quest 2: [FF, FF, FF, FE, FF, FE, FF, FE, FF, FE, FF]
+
+LUFA:
+Windows 10 (first connect): [12, FF, FF, 4, 10, FF, FF, FF, 4, 10, 20A, 20A, 20A, 20A, 20A, 20A]
+Windows 10 (subsequent connect): [FF, FF, 4, 10, FF, 4, FF, 10, FF, 20A, 20A, 20A, 20A, 20A, 20A]
+Windows 10 (another host): [FF, FF, 4, 10, 4, 10]
+macOS: [2, 10, 2, E, FF]
+iOS/iPadOS: [2, 10, 2, E]
+Linux: [FF, FF, FF]
+PS5: [2, 4, 2, E, 2, 10]
+Nintendo Switch: [82, FF, 40, 40, FF, 40, 40]
+
+V-USB:
+Windows 10: [FF, FF, 4, E, FF]
+Windows 10 (another host): [FF, FF, 4, E, 4]
+macOS: [2, E, 2, E, FF]
+iOS/iPadOS: [2, E, 2, E]
+Linux: [FF, FF, FF]
+PS5: [2, 4, 2, E, 2]
+Nintendo Switch: [82, FF, 40, 40]
+Quest 2: [FF, FF, FF, FE]
+
+Common parts:
+Windows: [..., FF, FF, 4, ...]
+macOS: [2, _, 2, _, FF]
+iOS/iPadOS: [2, _, 2, _]
+Linux: [FF, FF, FF]
+PS5: [2, 4, 2, _, 2, ...]
+Nintendo Switch: [82, FF, 40, 40, ...]
+Quest 2: [FF, FF, FF, FE, ...]
+*/
+TEST_F(OsDetectionTest, TestLinux) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestChibiosMacos) {
+ EXPECT_EQ(check_sequence({0x2, 0x24, 0x2, 0x28, 0xFF}), OS_MACOS);
+}
+
+TEST_F(OsDetectionTest, TestLufaMacos) {
+ EXPECT_EQ(check_sequence({0x2, 0x10, 0x2, 0xE, 0xFF}), OS_MACOS);
+}
+
+TEST_F(OsDetectionTest, TestVusbMacos) {
+ EXPECT_EQ(check_sequence({0x2, 0xE, 0x2, 0xE, 0xFF}), OS_MACOS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosIos) {
+ EXPECT_EQ(check_sequence({0x2, 0x24, 0x2, 0x28}), OS_IOS);
+}
+
+TEST_F(OsDetectionTest, TestLufaIos) {
+ EXPECT_EQ(check_sequence({0x2, 0x10, 0x2, 0xE}), OS_IOS);
+}
+
+TEST_F(OsDetectionTest, TestVusbIos) {
+ EXPECT_EQ(check_sequence({0x2, 0xE, 0x2, 0xE}), OS_IOS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosWindows10) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x24, 0x4, 0x24, 0x4, 0xFF, 0x24, 0xFF, 0x4, 0xFF, 0x24, 0x4, 0x24, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosWindows10_2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x24, 0x4, 0x24, 0x4, 0x24, 0x4, 0x24, 0x4, 0x24}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestLufaWindows10) {
+ EXPECT_EQ(check_sequence({0x12, 0xFF, 0xFF, 0x4, 0x10, 0xFF, 0xFF, 0xFF, 0x4, 0x10, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestLufaWindows10_2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x10, 0xFF, 0x4, 0xFF, 0x10, 0xFF, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestLufaWindows10_3) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0x10, 0x4, 0x10}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestVusbWindows10) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0xE, 0xFF}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestVusbWindows10_2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0x4, 0xE, 0x4}), OS_WINDOWS);
+}
+
+TEST_F(OsDetectionTest, TestChibiosPs5) {
+ EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0x28, 0x2, 0x24}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestLufaPs5) {
+ EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0xE, 0x2, 0x10}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestVusbPs5) {
+ EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0xE, 0x2}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestChibiosNintendoSwitch) {
+ EXPECT_EQ(check_sequence({0x82, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestLufaNintendoSwitch) {
+ EXPECT_EQ(check_sequence({0x82, 0xFF, 0x40, 0x40, 0xFF, 0x40, 0x40}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestVusbNintendoSwitch) {
+ EXPECT_EQ(check_sequence({0x82, 0xFF, 0x40, 0x40}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestChibiosQuest2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF}), OS_LINUX);
+}
+
+TEST_F(OsDetectionTest, TestVusbQuest2) {
+ EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE}), OS_LINUX);
+}
diff --git a/quantum/os_detection/tests/rules.mk b/quantum/os_detection/tests/rules.mk
new file mode 100644
index 0000000000..9bfe373f46
--- /dev/null
+++ b/quantum/os_detection/tests/rules.mk
@@ -0,0 +1,5 @@
+os_detection_DEFS := -DOS_DETECTION_ENABLE
+
+os_detection_SRC := \
+ $(QUANTUM_PATH)/os_detection/tests/os_detection.cpp \
+ $(QUANTUM_PATH)/os_detection.c
diff --git a/quantum/os_detection/tests/testlist.mk b/quantum/os_detection/tests/testlist.mk
new file mode 100644
index 0000000000..405a7b82d5
--- /dev/null
+++ b/quantum/os_detection/tests/testlist.mk
@@ -0,0 +1 @@
+TEST_LIST += os_detection
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 46e8e07212..7693888462 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -68,23 +68,6 @@
|-----------------|-----------------------------------|
*****/
-#ifdef RGBLIGHT_ANIMATIONS
-// for backward compatibility
-# define RGBLIGHT_EFFECT_BREATHING
-# define RGBLIGHT_EFFECT_RAINBOW_MOOD
-# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
-# define RGBLIGHT_EFFECT_SNAKE
-# define RGBLIGHT_EFFECT_KNIGHT
-# define RGBLIGHT_EFFECT_CHRISTMAS
-# define RGBLIGHT_EFFECT_STATIC_GRADIENT
-# define RGBLIGHT_EFFECT_RGB_TEST
-# define RGBLIGHT_EFFECT_ALTERNATING
-#endif
-
-#ifdef RGBLIGHT_STATIC_PATTERNS
-# define RGBLIGHT_EFFECT_STATIC_GRADIENT
-#endif
-
// clang-format off
// check dynamic animation effects chose ?