diff options
Diffstat (limited to 'quantum')
26 files changed, 409 insertions, 219 deletions
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 4e223f0c9a..461ec89544 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -183,6 +183,25 @@ void audio_init(void) { #endif } +void audio_task(void) { +#ifdef AUDIO_INIT_DELAY + // startup song potentially needs to be run a little bit + // after keyboard startup, or else they will not work correctly + // because of interaction with the USB device state, which + // may still be in flux... + static bool delayed_tasks_run = false; + static uint16_t delayed_task_timer = 0; + if (!delayed_tasks_run) { + if (!delayed_task_timer) { + delayed_task_timer = timer_read(); + } else if (timer_elapsed(delayed_task_timer) > 300) { + audio_startup(); + delayed_tasks_run = true; + } + } +#endif +} + void audio_startup(void) { if (audio_config.enable) { PLAY_SONG(startup_song); @@ -371,8 +390,9 @@ void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) { melody_current_note_duration = audio_duration_to_ms((*notes_pointer)[current_note][1]); } -float click[2][2]; -void audio_play_click(uint16_t delay, float pitch, uint16_t duration) { +void audio_play_click(uint16_t delay, float pitch, uint16_t duration) { + static float click[2][2]; + uint16_t duration_tone = audio_ms_to_duration(duration); uint16_t duration_delay = audio_ms_to_duration(delay); diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 647744a686..a41814d0f8 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -69,7 +69,11 @@ void eeconfig_update_audio_current(void); * @post audio system (and hardware) initialized and ready to play tones */ void audio_init(void); -void audio_startup(void); + +/** + * \brief Handle various subsystem background tasks. + */ +void audio_task(void); /** * @brief en-/disable audio output, save this choice to the eeprom diff --git a/quantum/command.c b/quantum/command.c index 998d9b9aa1..ea2fd68e2b 100644 --- a/quantum/command.c +++ b/quantum/command.c @@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "action_layer.h" #include "action_util.h" #include "eeconfig.h" -#include "sleep_led.h" #include "led.h" #include "command.h" #include "quantum.h" @@ -39,6 +38,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. # include "backlight.h" #endif +#ifdef SLEEP_LED_ENABLE +# include "sleep_led.h" +#endif + #if defined(MOUSEKEY_ENABLE) # include "mousekey.h" #endif diff --git a/quantum/keyboard.c b/quantum/keyboard.c index c1a6d444a5..bf4890a51d 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -648,24 +648,8 @@ void quantum_task(void) { if (!is_keyboard_master()) return; #endif -#if defined(AUDIO_ENABLE) && defined(AUDIO_INIT_DELAY) - // There are some tasks that need to be run a little bit - // after keyboard startup, or else they will not work correctly - // because of interaction with the USB device state, which - // may still be in flux... - // - // At the moment the only feature that needs this is the - // startup song. - static bool delayed_tasks_run = false; - static uint16_t delayed_task_timer = 0; - if (!delayed_tasks_run) { - if (!delayed_task_timer) { - delayed_task_timer = timer_read(); - } else if (timer_elapsed(delayed_task_timer) > 300) { - audio_startup(); - delayed_tasks_run = true; - } - } +#ifdef AUDIO_ENABLE + audio_task(); #endif #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index 7a0e8a5ebb..9c8004cc17 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -107,7 +107,11 @@ void eeconfig_update_led_matrix_default(void) { void eeconfig_debug_led_matrix(void) { dprintf("led_matrix_eeconfig EEPROM\n"); dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable); +#ifdef LED_MATRIX_MODE_NAME_ENABLE + dprintf("led_matrix_eeconfig.mode = %d (%s)\n", led_matrix_eeconfig.mode, led_matrix_get_mode_name(led_matrix_eeconfig.mode)); +#else dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode); +#endif // LED_MATRIX_MODE_NAME_ENABLE dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val); dprintf("led_matrix_eeconfig.speed = %d\n", led_matrix_eeconfig.speed); dprintf("led_matrix_eeconfig.flags = %d\n", led_matrix_eeconfig.flags); @@ -525,7 +529,11 @@ void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { } led_task_state = STARTING; eeconfig_flag_led_matrix(write_to_eeprom); - dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); +#ifdef LED_MATRIX_MODE_NAME_ENABLE + dprintf("led matrix mode [%s]: %u (%s)\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", (unsigned)led_matrix_eeconfig.mode, led_matrix_get_mode_name(led_matrix_eeconfig.mode)); +#else + dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", (unsigned)led_matrix_eeconfig.mode); +#endif // LED_MATRIX_MODE_NAME_ENABLE } void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); @@ -652,3 +660,48 @@ void led_matrix_set_flags(led_flags_t flags) { void led_matrix_set_flags_noeeprom(led_flags_t flags) { led_matrix_set_flags_eeprom_helper(flags, false); } + +// LED Matrix naming +#undef LED_MATRIX_EFFECT +#ifdef LED_MATRIX_MODE_NAME_ENABLE +const char *led_matrix_get_mode_name(uint8_t mode) { + switch (mode) { + case LED_MATRIX_NONE: + return "NONE"; + +# define LED_MATRIX_EFFECT(name, ...) \ + case LED_MATRIX_##name: \ + return #name; +# include "led_matrix_effects.inc" +# undef LED_MATRIX_EFFECT + +# ifdef COMMUNITY_MODULES_ENABLE +# define LED_MATRIX_EFFECT(name, ...) \ + case LED_MATRIX_COMMUNITY_MODULE_##name: \ + return #name; +# include "led_matrix_community_modules.inc" +# undef LED_MATRIX_EFFECT +# endif // COMMUNITY_MODULES_ENABLE + +# if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER) +# define LED_MATRIX_EFFECT(name, ...) \ + case LED_MATRIX_CUSTOM_##name: \ + return #name; + +# ifdef LED_MATRIX_CUSTOM_KB +# include "led_matrix_kb.inc" +# endif // LED_MATRIX_CUSTOM_KB + +# ifdef LED_MATRIX_CUSTOM_USER +# include "led_matrix_user.inc" +# endif // LED_MATRIX_CUSTOM_USER + +# undef LED_MATRIX_EFFECT +# endif // LED_MATRIX_CUSTOM_KB || LED_MATRIX_CUSTOM_USER + + default: + return "UNKNOWN"; + } +} +# undef LED_MATRIX_EFFECT +#endif // LED_MATRIX_MODE_NAME_ENABLE diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h index 0dfe33ffab..9a49515ab2 100644 --- a/quantum/led_matrix/led_matrix.h +++ b/quantum/led_matrix/led_matrix.h @@ -184,6 +184,10 @@ led_flags_t led_matrix_get_flags(void); void led_matrix_set_flags(led_flags_t flags); void led_matrix_set_flags_noeeprom(led_flags_t flags); +#ifdef LED_MATRIX_MODE_NAME_ENABLE +const char *led_matrix_get_mode_name(uint8_t mode); +#endif // LED_MATRIX_MODE_NAME_ENABLE + static inline bool led_matrix_check_finished_leds(uint8_t led_idx) { #if defined(LED_MATRIX_SPLIT) if (is_keyboard_left()) { diff --git a/quantum/matrix.c b/quantum/matrix.c index a877fb4e41..167a70e5b6 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -25,10 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #ifdef SPLIT_KEYBOARD # include "split_common/split_util.h" # include "split_common/transactions.h" - -# define ROWS_PER_HAND (MATRIX_ROWS / 2) -#else -# define ROWS_PER_HAND (MATRIX_ROWS) #endif #ifdef DIRECT_PINS_RIGHT @@ -52,13 +48,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #endif #ifdef DIRECT_PINS -static SPLIT_MUTABLE pin_t direct_pins[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS; +static SPLIT_MUTABLE pin_t direct_pins[MATRIX_ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS; #elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) # ifdef MATRIX_ROW_PINS -static SPLIT_MUTABLE_ROW pin_t row_pins[ROWS_PER_HAND] = MATRIX_ROW_PINS; +static SPLIT_MUTABLE_ROW pin_t row_pins[MATRIX_ROWS_PER_HAND] = MATRIX_ROW_PINS; # endif // MATRIX_ROW_PINS # ifdef MATRIX_COL_PINS -static SPLIT_MUTABLE_COL pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; +static SPLIT_MUTABLE_COL pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; # endif // MATRIX_COL_PINS #endif @@ -109,7 +105,7 @@ static inline uint8_t readMatrixPin(pin_t pin) { #ifdef DIRECT_PINS __attribute__((weak)) void matrix_init_pins(void) { - for (int row = 0; row < ROWS_PER_HAND; row++) { + for (int row = 0; row < MATRIX_ROWS_PER_HAND; row++) { for (int col = 0; col < MATRIX_COLS; col++) { pin_t pin = direct_pins[row][col]; if (pin != NO_PIN) { @@ -158,7 +154,7 @@ static void unselect_row(uint8_t row) { } static void unselect_rows(void) { - for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { + for (uint8_t x = 0; x < MATRIX_ROWS_PER_HAND; x++) { unselect_row(x); } } @@ -228,7 +224,7 @@ static void unselect_cols(void) { __attribute__((weak)) void matrix_init_pins(void) { unselect_cols(); - for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { + for (uint8_t x = 0; x < MATRIX_ROWS_PER_HAND; x++) { if (row_pins[x] != NO_PIN) { gpio_atomic_set_pin_input_high(row_pins[x]); } @@ -245,7 +241,7 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[] matrix_output_select_delay(); // For each row... - for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) { + for (uint8_t row_index = 0; row_index < MATRIX_ROWS_PER_HAND; row_index++) { // Check row pin state if (readMatrixPin(row_pins[row_index]) == 0) { // Pin LO, set col bit @@ -275,16 +271,16 @@ void matrix_init(void) { // Set pinout for right half if pinout for that half is defined if (!isLeftHand) { # ifdef DIRECT_PINS_RIGHT - const pin_t direct_pins_right[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS_RIGHT; - for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { + const pin_t direct_pins_right[MATRIX_ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS_RIGHT; + for (uint8_t i = 0; i < MATRIX_ROWS_PER_HAND; i++) { for (uint8_t j = 0; j < MATRIX_COLS; j++) { direct_pins[i][j] = direct_pins_right[i][j]; } } # endif # ifdef MATRIX_ROW_PINS_RIGHT - const pin_t row_pins_right[ROWS_PER_HAND] = MATRIX_ROW_PINS_RIGHT; - for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { + const pin_t row_pins_right[MATRIX_ROWS_PER_HAND] = MATRIX_ROW_PINS_RIGHT; + for (uint8_t i = 0; i < MATRIX_ROWS_PER_HAND; i++) { row_pins[i] = row_pins_right[i]; } # endif @@ -296,8 +292,8 @@ void matrix_init(void) { # endif } - thisHand = isLeftHand ? 0 : (ROWS_PER_HAND); - thatHand = ROWS_PER_HAND - thisHand; + thisHand = isLeftHand ? 0 : (MATRIX_ROWS_PER_HAND); + thatHand = MATRIX_ROWS_PER_HAND - thisHand; #endif // initialize key pins @@ -307,7 +303,7 @@ void matrix_init(void) { memset(matrix, 0, sizeof(matrix)); memset(raw_matrix, 0, sizeof(raw_matrix)); - debounce_init(ROWS_PER_HAND); + debounce_init(MATRIX_ROWS_PER_HAND); matrix_init_kb(); } @@ -325,7 +321,7 @@ uint8_t matrix_scan(void) { #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) // Set row, read cols - for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { + for (uint8_t current_row = 0; current_row < MATRIX_ROWS_PER_HAND; current_row++) { matrix_read_cols_on_row(curr_matrix, current_row); } #elif (DIODE_DIRECTION == ROW2COL) @@ -340,9 +336,9 @@ uint8_t matrix_scan(void) { if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix)); #ifdef SPLIT_KEYBOARD - changed = debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed) | matrix_post_scan(); + changed = debounce(raw_matrix, matrix + thisHand, MATRIX_ROWS_PER_HAND, changed) | matrix_post_scan(); #else - changed = debounce(raw_matrix, matrix, ROWS_PER_HAND, changed); + changed = debounce(raw_matrix, matrix, MATRIX_ROWS_PER_HAND, changed); matrix_scan_kb(); #endif return (uint8_t)changed; diff --git a/quantum/matrix.h b/quantum/matrix.h index a5b628fc59..99f01aece2 100644 --- a/quantum/matrix.h +++ b/quantum/matrix.h @@ -35,6 +35,12 @@ typedef uint32_t matrix_row_t; # error "MATRIX_COLS: invalid value" #endif +#ifdef SPLIT_KEYBOARD +# define MATRIX_ROWS_PER_HAND (MATRIX_ROWS / 2) +#else +# define MATRIX_ROWS_PER_HAND (MATRIX_ROWS) +#endif + #define MATRIX_ROW_SHIFTER ((matrix_row_t)1) #ifdef __cplusplus diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c index d02c527caa..b4a86fc483 100644 --- a/quantum/matrix_common.c +++ b/quantum/matrix_common.c @@ -8,10 +8,6 @@ # include "split_common/split_util.h" # include "split_common/transactions.h" # include <string.h> - -# define ROWS_PER_HAND (MATRIX_ROWS / 2) -#else -# define ROWS_PER_HAND (MATRIX_ROWS) #endif #ifndef MATRIX_IO_DELAY @@ -95,8 +91,8 @@ void matrix_print(void) { bool matrix_post_scan(void) { bool changed = false; if (is_keyboard_master()) { - static bool last_connected = false; - matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; + static bool last_connected = false; + matrix_row_t slave_matrix[MATRIX_ROWS_PER_HAND] = {0}; if (transport_master_if_connected(matrix + thisHand, slave_matrix)) { changed = memcmp(matrix + thatHand, slave_matrix, sizeof(slave_matrix)) != 0; @@ -148,8 +144,8 @@ __attribute__((weak)) void matrix_slave_scan_user(void) {} __attribute__((weak)) void matrix_init(void) { #ifdef SPLIT_KEYBOARD - thisHand = isLeftHand ? 0 : (ROWS_PER_HAND); - thatHand = ROWS_PER_HAND - thisHand; + thisHand = isLeftHand ? 0 : (MATRIX_ROWS_PER_HAND); + thatHand = MATRIX_ROWS_PER_HAND - thisHand; #endif matrix_init_custom(); @@ -160,7 +156,7 @@ __attribute__((weak)) void matrix_init(void) { matrix[i] = 0; } - debounce_init(ROWS_PER_HAND); + debounce_init(MATRIX_ROWS_PER_HAND); matrix_init_kb(); } @@ -169,9 +165,9 @@ __attribute__((weak)) uint8_t matrix_scan(void) { bool changed = matrix_scan_custom(raw_matrix); #ifdef SPLIT_KEYBOARD - changed = debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed) | matrix_post_scan(); + changed = debounce(raw_matrix, matrix + thisHand, MATRIX_ROWS_PER_HAND, changed) | matrix_post_scan(); #else - changed = debounce(raw_matrix, matrix, ROWS_PER_HAND, changed); + changed = debounce(raw_matrix, matrix, MATRIX_ROWS_PER_HAND, changed); matrix_scan_kb(); #endif diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index 564c2d294c..fe88d5a1af 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -80,8 +80,10 @@ uint16_t pointing_device_get_shared_cpi(void) { #endif // defined(SPLIT_POINTING_ENABLE) -static report_mouse_t local_mouse_report = {}; -static bool pointing_device_force_send = false; +static report_mouse_t local_mouse_report = {}; +static bool pointing_device_force_send = false; +static pointing_device_status_t pointing_device_status = POINTING_DEVICE_STATUS_UNKNOWN; + #ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE static uint16_t hires_scroll_resolution; #endif @@ -90,7 +92,9 @@ static uint16_t hires_scroll_resolution; #define POINTING_DEVICE_DRIVER(name) POINTING_DEVICE_DRIVER_CONCAT(name) #ifdef POINTING_DEVICE_DRIVER_custom -__attribute__((weak)) void pointing_device_driver_init(void) {} +__attribute__((weak)) bool pointing_device_driver_init(void) { + return false; +} __attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { return mouse_report; } @@ -179,7 +183,11 @@ __attribute__((weak)) void pointing_device_init(void) { if ((POINTING_DEVICE_THIS_SIDE)) #endif { - pointing_device_driver->init(); + if (pointing_device_driver->init()) { + pointing_device_status = POINTING_DEVICE_STATUS_SUCCESS; + } else { + pointing_device_status = POINTING_DEVICE_STATUS_INIT_FAILED; + } #ifdef POINTING_DEVICE_MOTION_PIN # ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW gpio_set_pin_input_high(POINTING_DEVICE_MOTION_PIN); @@ -201,6 +209,28 @@ __attribute__((weak)) void pointing_device_init(void) { } /** + * @brief Gets status of pointing device + * + * Returns current pointing device status + * @return pointing_device_status_t + */ +__attribute__((weak)) pointing_device_status_t pointing_device_get_status(void) { +#ifdef SPLIT_POINTING_ENABLE + // Assume target side is always good, split transaction checksum should stop additional reports being generated. + return POINTING_DEVICE_THIS_SIDE ? pointing_device_status : POINTING_DEVICE_STATUS_SUCCESS; +#else + return pointing_device_status; +#endif +} + +/** + * @brief Sets status of pointing device + */ +void pointing_device_set_status(pointing_device_status_t status) { + pointing_device_status = status; +} + +/** * @brief Sends processed mouse report to host * * This sends the mouse report generated by pointing_device_task if changed since the last report. Once send zeros mouse report except buttons. @@ -281,6 +311,10 @@ __attribute__((weak)) bool pointing_device_task(void) { last_exec = timer_read32(); #endif + if (pointing_device_get_status() != POINTING_DEVICE_STATUS_SUCCESS) { + return false; + } + // Gather report info #ifdef POINTING_DEVICE_MOTION_PIN # if defined(SPLIT_POINTING_ENABLE) diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index e7a0819ed9..5dfb9ce196 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "report.h" typedef struct { - void (*init)(void); + bool (*init)(void); report_mouse_t (*get_report)(report_mouse_t mouse_report); void (*set_cpi)(uint16_t); uint16_t (*get_cpi)(void); @@ -75,7 +75,7 @@ typedef struct { # include "drivers/sensors/pmw33xx_common.h" # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #else -void pointing_device_driver_init(void); +bool pointing_device_driver_init(void); report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report); uint16_t pointing_device_driver_get_cpi(void); void pointing_device_driver_set_cpi(uint16_t cpi); @@ -92,6 +92,13 @@ typedef enum { POINTING_DEVICE_BUTTON8, } pointing_device_buttons_t; +typedef enum { + POINTING_DEVICE_STATUS_UNKNOWN, + POINTING_DEVICE_STATUS_INIT_FAILED, + POINTING_DEVICE_STATUS_FAILED, + POINTING_DEVICE_STATUS_SUCCESS, +} pointing_device_status_t; + #ifdef MOUSE_EXTENDED_REPORT typedef int32_t xy_clamp_range_t; #else @@ -107,13 +114,15 @@ typedef int16_t hv_clamp_range_t; #define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt))) #define CONSTRAIN_HID_XY(amt) ((amt) < MOUSE_REPORT_XY_MIN ? MOUSE_REPORT_XY_MIN : ((amt) > MOUSE_REPORT_XY_MAX ? MOUSE_REPORT_XY_MAX : (amt))) -void pointing_device_init(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); -void pointing_device_set_cpi(uint16_t cpi); +void pointing_device_init(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); +void pointing_device_set_cpi(uint16_t cpi); +pointing_device_status_t pointing_device_get_status(void); +void pointing_device_set_status(pointing_device_status_t status); void pointing_device_init_kb(void); void pointing_device_init_user(void); diff --git a/quantum/process_keycode/process_oneshot.c b/quantum/process_keycode/process_oneshot.c new file mode 100644 index 0000000000..6c43da1011 --- /dev/null +++ b/quantum/process_keycode/process_oneshot.c @@ -0,0 +1,25 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "process_oneshot.h" +#include "action_util.h" + +bool process_oneshot(uint16_t keycode, keyrecord_t *record) { +#ifndef NO_ACTION_ONESHOT + if (record->event.pressed) { + switch (keycode) { + case QK_ONE_SHOT_TOGGLE: + oneshot_toggle(); + return false; + case QK_ONE_SHOT_ON: + oneshot_enable(); + return false; + case QK_ONE_SHOT_OFF: + oneshot_disable(); + return false; + } + } +#endif + + return true; +} diff --git a/quantum/process_keycode/process_oneshot.h b/quantum/process_keycode/process_oneshot.h new file mode 100644 index 0000000000..11445b9b38 --- /dev/null +++ b/quantum/process_keycode/process_oneshot.h @@ -0,0 +1,10 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <stdint.h> +#include <stdbool.h> +#include "action.h" + +bool process_oneshot(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_quantum.c b/quantum/process_keycode/process_quantum.c new file mode 100644 index 0000000000..703e00755b --- /dev/null +++ b/quantum/process_keycode/process_quantum.c @@ -0,0 +1,76 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "process_quantum.h" +#include "quantum.h" + +#ifdef ENABLE_COMPILE_KEYCODE +/** \brief Compiles the firmware, and adds the flash command based on keyboard bootloader + */ +static void send_make_command(void) { +# ifdef NO_ACTION_ONESHOT + const uint8_t temp_mod = mod_config(get_mods()); +# else + const uint8_t temp_mod = mod_config(get_mods() | get_oneshot_mods()); + clear_oneshot_mods(); +# endif + clear_mods(); + + SEND_STRING_DELAY("qmk", TAP_CODE_DELAY); + if (temp_mod & MOD_MASK_SHIFT) { // if shift is held, flash rather than compile + SEND_STRING_DELAY(" flash ", TAP_CODE_DELAY); + } else { + SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY); + } +# if defined(CONVERTER_ENABLED) + SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP " -e CONVERT_TO=" CONVERTER_TARGET SS_TAP(X_ENTER), TAP_CODE_DELAY); +# else + SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY); +# endif + if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) { + reset_keyboard(); + } +} +#endif + +bool process_quantum(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { +#ifndef NO_RESET + case QK_BOOTLOADER: + reset_keyboard(); + return false; + case QK_REBOOT: + soft_reset_keyboard(); + return false; +#endif +#ifndef NO_DEBUG + case QK_DEBUG_TOGGLE: + debug_enable ^= 1; + if (debug_enable) { + print("DEBUG: enabled.\n"); + } else { + print("DEBUG: disabled.\n"); + } + return false; +#endif + case QK_CLEAR_EEPROM: +#ifdef NO_RESET + eeconfig_init(); +#else + eeconfig_disable(); + soft_reset_keyboard(); +#endif + return false; +#ifdef ENABLE_COMPILE_KEYCODE + case QK_MAKE: + send_make_command(); + return false; +#endif + default: + break; + } + } + + return true; +} diff --git a/quantum/process_keycode/process_quantum.h b/quantum/process_keycode/process_quantum.h new file mode 100644 index 0000000000..5c2462be01 --- /dev/null +++ b/quantum/process_keycode/process_quantum.h @@ -0,0 +1,10 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <stdint.h> +#include <stdbool.h> +#include "action.h" + +bool process_quantum(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/process_keycode/process_underglow.c b/quantum/process_keycode/process_underglow.c index b8d8989ef3..78006ee099 100644 --- a/quantum/process_keycode/process_underglow.c +++ b/quantum/process_keycode/process_underglow.c @@ -200,6 +200,11 @@ bool process_underglow(uint16_t keycode, keyrecord_t *record) { } #endif return false; +#ifdef VELOCIKEY_ENABLE + case QK_VELOCIKEY_TOGGLE: + velocikey_toggle(); + return false; +#endif } } diff --git a/quantum/quantum.c b/quantum/quantum.c index 0bb6ee0a91..09e5fe1dac 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -15,6 +15,11 @@ */ #include "quantum.h" +#include "process_quantum.h" + +#ifdef SLEEP_LED_ENABLE +# include "sleep_led.h" +#endif #ifdef BACKLIGHT_ENABLE # include "process_backlight.h" @@ -84,6 +89,10 @@ # include "process_layer_lock.h" #endif +#ifndef NO_ACTION_ONESHOT +# include "process_oneshot.h" +#endif + #ifdef AUDIO_ENABLE # ifndef GOODBYE_SONG # define GOODBYE_SONG SONG(GOODBYE_SOUND) @@ -174,10 +183,6 @@ __attribute__((weak)) bool pre_process_record_user(uint16_t keycode, keyrecord_t return true; } -__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { - return true; -} - __attribute__((weak)) bool process_record_modules(uint16_t keycode, keyrecord_t *record) { return true; } @@ -292,9 +297,10 @@ void post_process_record_quantum(keyrecord_t *record) { post_process_record_kb(keycode, record); } -/* Core keycode function, hands off handling to other functions, - then processes internal quantum keycodes, and then processes - ACTIONs. */ +/** \brief Core keycode function + * + * Hands off handling to other quantum/process_keycode/ functions + */ bool process_record_quantum(keyrecord_t *record) { uint16_t keycode = get_record_keycode(record, true); @@ -439,85 +445,14 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef CONNECTION_ENABLE process_connection(keycode, record) && #endif - true)) { - return false; - } - - if (record->event.pressed) { - switch (keycode) { -#ifndef NO_RESET - case QK_BOOTLOADER: - reset_keyboard(); - return false; - case QK_REBOOT: - soft_reset_keyboard(); - return false; -#endif -#ifndef NO_DEBUG - case QK_DEBUG_TOGGLE: - debug_enable ^= 1; - if (debug_enable) { - print("DEBUG: enabled.\n"); - } else { - print("DEBUG: disabled.\n"); - } -#endif - return false; - case QK_CLEAR_EEPROM: -#ifdef NO_RESET - eeconfig_init(); -#else - eeconfig_disable(); - soft_reset_keyboard(); -#endif - return false; -#ifdef VELOCIKEY_ENABLE - case QK_VELOCIKEY_TOGGLE: - velocikey_toggle(); - return false; -#endif #ifndef NO_ACTION_ONESHOT - case QK_ONE_SHOT_TOGGLE: - oneshot_toggle(); - break; - case QK_ONE_SHOT_ON: - oneshot_enable(); - break; - case QK_ONE_SHOT_OFF: - oneshot_disable(); - break; -#endif -#ifdef ENABLE_COMPILE_KEYCODE - case QK_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader - { -# ifdef NO_ACTION_ONESHOT - const uint8_t temp_mod = mod_config(get_mods()); -# else - const uint8_t temp_mod = mod_config(get_mods() | get_oneshot_mods()); - clear_oneshot_mods(); -# endif - clear_mods(); - - SEND_STRING_DELAY("qmk", TAP_CODE_DELAY); - if (temp_mod & MOD_MASK_SHIFT) { // if shift is held, flash rather than compile - SEND_STRING_DELAY(" flash ", TAP_CODE_DELAY); - } else { - SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY); - } -# if defined(CONVERTER_ENABLED) - SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP " -e CONVERT_TO=" CONVERTER_TARGET SS_TAP(X_ENTER), TAP_CODE_DELAY); -# else - SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY); -# endif - if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) { - reset_keyboard(); - } - } + process_oneshot(keycode, record) && #endif - } + process_quantum(keycode, record))) { + return false; } - return process_action_kb(record); + return true; } void set_single_default_layer(uint8_t default_layer) { @@ -556,6 +491,10 @@ void suspend_power_down_quantum(void) { backlight_level_noeeprom(0); # endif +# ifdef SLEEP_LED_ENABLE + sleep_led_enable(); +# endif + # ifdef LED_MATRIX_ENABLE led_matrix_task(); # endif @@ -602,6 +541,10 @@ __attribute__((weak)) void suspend_wakeup_init_quantum(void) { backlight_init(); #endif +#ifdef SLEEP_LED_ENABLE + sleep_led_disable(); +#endif + // Restore LED indicators led_wakeup(); diff --git a/quantum/quantum.h b/quantum/quantum.h index 3a994e9a03..0036cd784b 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -263,7 +263,6 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); bool pre_process_record_quantum(keyrecord_t *record); bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record); bool pre_process_record_user(uint16_t keycode, keyrecord_t *record); -bool process_action_kb(keyrecord_t *record); bool process_record_kb(uint16_t keycode, keyrecord_t *record); bool process_record_user(uint16_t keycode, keyrecord_t *record); void post_process_record_kb(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 515386756d..a1ae7ed0be 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -66,10 +66,6 @@ #define LCAG(kc) (QK_LCTL | QK_LALT | QK_LGUI | (kc)) #define LSAG(kc) (QK_LSFT | QK_LALT | QK_LGUI | (kc)) -#define SGUI(kc) LSG(kc) -#define SCMD(kc) LSG(kc) -#define SWIN(kc) LSG(kc) - #define RCTL(kc) (QK_RCTL | (kc)) #define RSFT(kc) (QK_RSFT | (kc)) #define RALT(kc) (QK_RALT | (kc)) @@ -90,8 +86,6 @@ #define RCAG(kc) (QK_RCTL | QK_RALT | QK_RGUI | (kc)) #define RSAG(kc) (QK_RSFT | QK_RALT | QK_RGUI | (kc)) -#define SAGR(kc) RSA(kc) - #define HYPR(kc) (QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI | (kc)) #define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc)) @@ -206,10 +200,6 @@ #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) #define LSAG_T(kc) MT(MOD_LSFT | MOD_LALT | MOD_LGUI, kc) -#define SGUI_T(kc) LSG_T(kc) -#define SCMD_T(kc) LSG_T(kc) -#define SWIN_T(kc) LSG_T(kc) - #define RCTL_T(kc) MT(MOD_RCTL, kc) #define RSFT_T(kc) MT(MOD_RSFT, kc) #define RALT_T(kc) MT(MOD_RALT, kc) @@ -230,11 +220,8 @@ #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) #define RSAG_T(kc) MT(MOD_RSFT | MOD_RALT | MOD_RGUI, kc) -#define SAGR_T(kc) RSA_T(kc) - #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) -#define ALL_T(kc) HYPR_T(kc) // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap #define KC_HYPR HYPR(KC_NO) diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 55b0fc3596..e417591fe2 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -3,59 +3,17 @@ // clang-format off // Deprecated Quantum keycodes -#define RGB_TOG QK_UNDERGLOW_TOGGLE -#define RGB_MOD QK_UNDERGLOW_MODE_NEXT -#define RGB_MODE_FORWARD QK_UNDERGLOW_MODE_NEXT -#define RGB_RMOD QK_UNDERGLOW_MODE_PREVIOUS -#define RGB_MODE_REVERSE QK_UNDERGLOW_MODE_PREVIOUS -#define RGB_HUI QK_UNDERGLOW_HUE_UP -#define RGB_HUD QK_UNDERGLOW_HUE_DOWN -#define RGB_SAI QK_UNDERGLOW_SATURATION_UP -#define RGB_SAD QK_UNDERGLOW_SATURATION_DOWN -#define RGB_VAI QK_UNDERGLOW_VALUE_UP -#define RGB_VAD QK_UNDERGLOW_VALUE_DOWN -#define RGB_SPI QK_UNDERGLOW_SPEED_UP -#define RGB_SPD QK_UNDERGLOW_SPEED_DOWN - -#define KC_MS_UP QK_MOUSE_CURSOR_UP -#define KC_MS_U QK_MOUSE_CURSOR_UP -#define KC_MS_DOWN QK_MOUSE_CURSOR_DOWN -#define KC_MS_D QK_MOUSE_CURSOR_DOWN -#define KC_MS_LEFT QK_MOUSE_CURSOR_LEFT -#define KC_MS_L QK_MOUSE_CURSOR_LEFT -#define KC_MS_RIGHT QK_MOUSE_CURSOR_RIGHT -#define KC_MS_R QK_MOUSE_CURSOR_RIGHT -#define KC_MS_BTN1 QK_MOUSE_BUTTON_1 -#define KC_BTN1 QK_MOUSE_BUTTON_1 -#define KC_MS_BTN2 QK_MOUSE_BUTTON_2 -#define KC_BTN2 QK_MOUSE_BUTTON_2 -#define KC_MS_BTN3 QK_MOUSE_BUTTON_3 -#define KC_BTN3 QK_MOUSE_BUTTON_3 -#define KC_MS_BTN4 QK_MOUSE_BUTTON_4 -#define KC_BTN4 QK_MOUSE_BUTTON_4 -#define KC_MS_BTN5 QK_MOUSE_BUTTON_5 -#define KC_BTN5 QK_MOUSE_BUTTON_5 -#define KC_MS_BTN6 QK_MOUSE_BUTTON_6 -#define KC_BTN6 QK_MOUSE_BUTTON_6 -#define KC_MS_BTN7 QK_MOUSE_BUTTON_7 -#define KC_BTN7 QK_MOUSE_BUTTON_7 -#define KC_MS_BTN8 QK_MOUSE_BUTTON_8 -#define KC_BTN8 QK_MOUSE_BUTTON_8 -#define KC_MS_WH_UP QK_MOUSE_WHEEL_UP -#define KC_WH_U QK_MOUSE_WHEEL_UP -#define KC_MS_WH_DOWN QK_MOUSE_WHEEL_DOWN -#define KC_WH_D QK_MOUSE_WHEEL_DOWN -#define KC_MS_WH_LEFT QK_MOUSE_WHEEL_LEFT -#define KC_WH_L QK_MOUSE_WHEEL_LEFT -#define KC_MS_WH_RIGHT QK_MOUSE_WHEEL_RIGHT -#define KC_WH_R QK_MOUSE_WHEEL_RIGHT -#define KC_MS_ACCEL0 QK_MOUSE_ACCELERATION_0 -#define KC_ACL0 QK_MOUSE_ACCELERATION_0 -#define KC_MS_ACCEL1 QK_MOUSE_ACCELERATION_1 -#define KC_ACL1 QK_MOUSE_ACCELERATION_1 -#define KC_MS_ACCEL2 QK_MOUSE_ACCELERATION_2 -#define KC_ACL2 QK_MOUSE_ACCELERATION_2 - #define QK_OUTPUT_AUTO OU_AUTO #define C_S_T(kc) LCS_T(kc) +#define ALL_T(kc) HYPR_T(kc) + +#define SGUI(kc) LSG(kc) +#define SCMD(kc) LSG(kc) +#define SWIN(kc) LSG(kc) +#define SGUI_T(kc) LSG_T(kc) +#define SCMD_T(kc) LSG_T(kc) +#define SWIN_T(kc) LSG_T(kc) + +#define SAGR(kc) RSA(kc) +#define SAGR_T(kc) RSA_T(kc) diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h index 67f568ca38..d11dda50c3 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h @@ -4,6 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE) # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static hsv_t SOLID_REACTIVE_math(hsv_t hsv, uint16_t offset) { + if (offset > 255) offset = 255; # ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); # endif diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h index f20f1b1fb6..22ba42296f 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h @@ -4,6 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static hsv_t SOLID_REACTIVE_SIMPLE_math(hsv_t hsv, uint16_t offset) { + if (offset > 255) offset = 255; # ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); # endif diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h index a87c06f9df..5467ea0a59 100644 --- a/quantum/rgb_matrix/animations/starlight_smooth_anim.h +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -9,7 +9,7 @@ static uint8_t phase_offsets[RGB_MATRIX_LED_COUNT]; hsv_t STARLIGHT_SMOOTH_math(hsv_t hsv, uint8_t i, uint8_t time) { if (phase_offsets[i] == 0) { - phase_offsets[i] = rand() % 255; + phase_offsets[i] = random8(); } hsv.v = scale8(abs8(sin8((time + phase_offsets[i]) / 2) - 128) * 2, hsv.v); return hsv; diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 2679c48342..ab0aa17512 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -109,7 +109,11 @@ void eeconfig_update_rgb_matrix_default(void) { void eeconfig_debug_rgb_matrix(void) { dprintf("rgb_matrix_config EEPROM\n"); dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable); +#ifdef RGB_MATRIX_MODE_NAME_ENABLE + dprintf("rgb_matrix_config.mode = %d (%s)\n", rgb_matrix_config.mode, rgb_matrix_get_mode_name(rgb_matrix_config.mode)); +#else dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode); +#endif // RGB_MATRIX_MODE_NAME_ENABLE dprintf("rgb_matrix_config.hsv.h = %d\n", rgb_matrix_config.hsv.h); dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s); dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v); @@ -560,7 +564,11 @@ void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { } rgb_task_state = STARTING; eeconfig_flag_rgb_matrix(write_to_eeprom); - dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); +#ifdef RGB_MATRIX_MODE_NAME_ENABLE + dprintf("rgb matrix mode [%s]: %u (%s)\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", (unsigned)rgb_matrix_config.mode, rgb_matrix_get_mode_name(rgb_matrix_config.mode)); +#else + dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", (unsigned)rgb_matrix_config.mode); +#endif // RGB_MATRIX_MODE_NAME_ENABLE } void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); @@ -738,3 +746,49 @@ void rgb_matrix_set_flags(led_flags_t flags) { void rgb_matrix_set_flags_noeeprom(led_flags_t flags) { rgb_matrix_set_flags_eeprom_helper(flags, false); } + +//---------------------------------------------------------- +// RGB Matrix naming +#undef RGB_MATRIX_EFFECT +#ifdef RGB_MATRIX_MODE_NAME_ENABLE +const char *rgb_matrix_get_mode_name(uint8_t mode) { + switch (mode) { + case RGB_MATRIX_NONE: + return "NONE"; + +# define RGB_MATRIX_EFFECT(name, ...) \ + case RGB_MATRIX_##name: \ + return #name; +# include "rgb_matrix_effects.inc" +# undef RGB_MATRIX_EFFECT + +# ifdef COMMUNITY_MODULES_ENABLE +# define RGB_MATRIX_EFFECT(name, ...) \ + case RGB_MATRIX_COMMUNITY_MODULE_##name: \ + return #name; +# include "rgb_matrix_community_modules.inc" +# undef RGB_MATRIX_EFFECT +# endif // COMMUNITY_MODULES_ENABLE + +# if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) +# define RGB_MATRIX_EFFECT(name, ...) \ + case RGB_MATRIX_CUSTOM_##name: \ + return #name; + +# ifdef RGB_MATRIX_CUSTOM_KB +# include "rgb_matrix_kb.inc" +# endif // RGB_MATRIX_CUSTOM_KB + +# ifdef RGB_MATRIX_CUSTOM_USER +# include "rgb_matrix_user.inc" +# endif // RGB_MATRIX_CUSTOM_USER + +# undef RGB_MATRIX_EFFECT +# endif // RGB_MATRIX_CUSTOM_KB || RGB_MATRIX_CUSTOM_USER + + default: + return "UNKNOWN"; + } +} +# undef RGB_MATRIX_EFFECT +#endif // RGB_MATRIX_MODE_NAME_ENABLE diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index c6b302631e..a91dded4a8 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -220,6 +220,10 @@ void rgb_matrix_set_flags(led_flags_t flags); void rgb_matrix_set_flags_noeeprom(led_flags_t flags); void rgb_matrix_update_pwm_buffers(void); +#ifdef RGB_MATRIX_MODE_NAME_ENABLE +const char *rgb_matrix_get_mode_name(uint8_t mode); +#endif // RGB_MATRIX_MODE_NAME_ENABLE + #ifndef RGBLIGHT_ENABLE # define eeconfig_update_rgblight_current eeconfig_force_flush_rgb_matrix # define rgblight_reload_from_eeprom rgb_matrix_reload_from_eeprom diff --git a/quantum/via.c b/quantum/via.c index 3682b4ab2b..9446811af6 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -22,6 +22,10 @@ # error "DYNAMIC_KEYMAP_ENABLE is not enabled" #endif +#ifdef VIA_INSECURE +# pragma message "VIA_INSECURE is enabled - firmware is susceptible to keyloggers" +#endif + #include "via.h" #include "raw_hid.h" @@ -318,7 +322,11 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { uint8_t rows = 28 / ((MATRIX_COLS + 7) / 8); uint8_t i = 2; for (uint8_t row = 0; row < rows && row + offset < MATRIX_ROWS; row++) { +#ifdef VIA_INSECURE matrix_row_t value = matrix_get_row(row + offset); +#else + matrix_row_t value = 0; +#endif #if (MATRIX_COLS > 24) command_data[i++] = (value >> 24) & 0xFF; #endif |