diff options
Diffstat (limited to 'quantum')
42 files changed, 509 insertions, 200 deletions
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 93dc6f62b1..647744a686 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -18,6 +18,8 @@ #include <stdint.h> #include <stdbool.h> + +#include "compiler_support.h" #include "musical_notes.h" #include "song_list.h" #include "voices.h" @@ -38,7 +40,7 @@ typedef union audio_config_t { }; } audio_config_t; -_Static_assert(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec."); +STATIC_ASSERT(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec."); /* * a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index 561c7f8a94..2faa8fc4f2 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h @@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdint.h> #include <stdbool.h> +#include "compiler_support.h" + #ifndef BACKLIGHT_LEVELS # define BACKLIGHT_LEVELS 3 #elif BACKLIGHT_LEVELS > 31 @@ -44,7 +46,7 @@ typedef union backlight_config_t { }; } backlight_config_t; -_Static_assert(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec."); +STATIC_ASSERT(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec."); void backlight_init(void); void backlight_toggle(void); 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/compiler_support.h b/quantum/compiler_support.h new file mode 100644 index 0000000000..5c0c4d2835 --- /dev/null +++ b/quantum/compiler_support.h @@ -0,0 +1,15 @@ +// Copyright 2025 QMK Contributors +// SPDX-License-Identifier: GPL-2.0-or-later + +/** + * @brief Perfom an assertion at compile time. + * + * `_Static_assert` is C<23, while `static_assert` is C++/C23. + */ +#if !defined(STATIC_ASSERT) +# ifdef __cplusplus +# define STATIC_ASSERT static_assert +# else +# define STATIC_ASSERT _Static_assert +# endif +#endif diff --git a/quantum/connection/connection.h b/quantum/connection/connection.h index e403141fae..b25160c759 100644 --- a/quantum/connection/connection.h +++ b/quantum/connection/connection.h @@ -3,6 +3,8 @@ #pragma once #include <stdint.h> + +#include "compiler_support.h" #include "util.h" /** @@ -29,7 +31,7 @@ typedef union connection_config_t { connection_host_t desired_host : 8; } PACKED connection_config_t; -_Static_assert(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec."); +STATIC_ASSERT(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec."); /** * \brief Initialize the subsystem. diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 59027fb694..25029e39c4 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -166,6 +166,6 @@ void dynamic_keymap_macro_send(uint8_t id) { ++offset; } - send_string_nvm_state_t state = {.offset = 0}; + send_string_nvm_state_t state = {.offset = offset}; send_string_with_delay_impl(send_string_get_next_nvm, &state, DYNAMIC_KEYMAP_MACRO_DELAY); } diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index d4d8d957be..66f8934a99 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -154,8 +154,8 @@ bool eeconfig_is_user_datablock_valid(void); uint32_t eeconfig_read_user_datablock(void *data, uint32_t offset, uint32_t length) __attribute__((nonnull)); uint32_t eeconfig_update_user_datablock(const void *data, uint32_t offset, uint32_t length) __attribute__((nonnull)); void eeconfig_init_user_datablock(void); -# define eeconfig_read_user_datablock_field(__object, __field) eeconfig_read_user_datablock(&(__object.__field), offsetof(__object, __field), sizeof(__object.__field)) -# define eeconfig_update_user_datablock_field(__object, __field) eeconfig_update_user_datablock(&(__object.__field), offsetof(__object, __field), sizeof(__object.__field)) +# define eeconfig_read_user_datablock_field(__object, __field) eeconfig_read_user_datablock(&(__object.__field), offsetof(typeof(__object), __field), sizeof(__object.__field)) +# define eeconfig_update_user_datablock_field(__object, __field) eeconfig_update_user_datablock(&(__object.__field), offsetof(typeof(__object), __field), sizeof(__object.__field)) #endif // (EECONFIG_USER_DATA_SIZE) > 0 // Any "checked" debounce variant used requires implementation of: diff --git a/quantum/haptic.h b/quantum/haptic.h index e27f546d40..f854c75ec3 100644 --- a/quantum/haptic.h +++ b/quantum/haptic.h @@ -20,6 +20,8 @@ #include <stdint.h> #include <stdbool.h> +#include "compiler_support.h" + #ifndef HAPTIC_DEFAULT_FEEDBACK # define HAPTIC_DEFAULT_FEEDBACK 0 #endif @@ -42,7 +44,7 @@ typedef union haptic_config_t { }; } haptic_config_t; -_Static_assert(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec."); +STATIC_ASSERT(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec."); typedef enum HAPTIC_FEEDBACK { KEY_PRESS, diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index 529cd0e127..804f1381d0 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -16,9 +16,7 @@ #pragma once -#ifdef __cplusplus -# define _Static_assert static_assert -#endif +#include "compiler_support.h" #include "eeconfig.h" #include "keycode.h" @@ -47,6 +45,6 @@ typedef union keymap_config_t { }; } keymap_config_t; -_Static_assert(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec."); +STATIC_ASSERT(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec."); extern keymap_config_t keymap_config; diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index abdcd5c7ba..9be9bae943 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -156,7 +156,7 @@ action_t action_for_keycode(uint16_t keycode) { case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: mod = mod_config(QK_LAYER_MOD_GET_MODS(keycode)); action_layer = QK_LAYER_MOD_GET_LAYER(keycode); - action.code = ACTION_LAYER_MODS(action_layer, (mod & 0x10) ? mod << 4 : mod); + action.code = ACTION_LAYER_MODS(action_layer, (mod & 0x10) ? (mod & 0xF) << 4 : mod); break; #endif // NO_ACTION_LAYER case QK_MOD_TAP ... QK_MOD_TAP_MAX: diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c index 23e842353a..99fd3f929e 100644 --- a/quantum/keymap_introspection.c +++ b/quantum/keymap_introspection.c @@ -13,6 +13,7 @@ # include INTROSPECTION_KEYMAP_C #endif // INTROSPECTION_KEYMAP_C +#include "compiler_support.h" #include "keymap_introspection.h" #include "util.h" @@ -30,9 +31,9 @@ __attribute__((weak)) uint8_t keymap_layer_count(void) { } #ifdef DYNAMIC_KEYMAP_ENABLE -_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT"); +STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT"); #else -_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); +STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); #endif uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) { @@ -61,7 +62,7 @@ __attribute__((weak)) uint8_t encodermap_layer_count(void) { return encodermap_layer_count_raw(); } -_Static_assert(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers"); +STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers"); uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) { if (layer_num < NUM_ENCODERMAP_LAYERS_RAW && encoder_idx < NUM_ENCODERS) { @@ -106,7 +107,7 @@ __attribute__((weak)) uint16_t combo_count(void) { return combo_count_raw(); } -_Static_assert(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?"); +STATIC_ASSERT(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?"); combo_t* combo_get_raw(uint16_t combo_idx) { if (combo_idx >= combo_count_raw()) { @@ -133,7 +134,7 @@ __attribute__((weak)) uint16_t tap_dance_count(void) { return tap_dance_count_raw(); } -_Static_assert(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?"); +STATIC_ASSERT(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?"); tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx) { if (tap_dance_idx >= tap_dance_count_raw()) { @@ -161,7 +162,7 @@ __attribute__((weak)) uint16_t key_override_count(void) { return key_override_count_raw(); } -_Static_assert(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?"); +STATIC_ASSERT(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?"); const key_override_t* key_override_get_raw(uint16_t key_override_idx) { if (key_override_idx >= key_override_count_raw()) { 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/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 810420f46f..26a199701e 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h @@ -18,6 +18,8 @@ #include <stdint.h> #include <stdbool.h> + +#include "compiler_support.h" #include "util.h" #if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES) @@ -82,4 +84,4 @@ typedef union led_eeconfig_t { }; } led_eeconfig_t; -_Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec."); +STATIC_ASSERT(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec."); diff --git a/quantum/nvm/eeprom/nvm_dynamic_keymap.c b/quantum/nvm/eeprom/nvm_dynamic_keymap.c index 5f514acc1a..5ff49795b2 100644 --- a/quantum/nvm/eeprom/nvm_dynamic_keymap.c +++ b/quantum/nvm/eeprom/nvm_dynamic_keymap.c @@ -1,6 +1,7 @@ // Copyright 2024 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later +#include "compiler_support.h" #include "keycodes.h" #include "eeprom.h" #include "dynamic_keymap.h" @@ -25,10 +26,10 @@ # define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1) #endif -_Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver"); +STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver"); // Due to usage of uint16_t check for max 65535 -_Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536"); +STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536"); // If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h, #ifndef DYNAMIC_KEYMAP_EEPROM_ADDR @@ -56,7 +57,7 @@ _Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_M // The keyboard should override DYNAMIC_KEYMAP_LAYER_COUNT to reduce it, // or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has // more than the default. -_Static_assert((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available."); +STATIC_ASSERT((int64_t)(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (int64_t)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available."); #ifndef TOTAL_EEPROM_BYTE_COUNT # error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps. diff --git a/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h index 41b76f1f65..78b8190eaf 100644 --- a/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h +++ b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h @@ -4,6 +4,8 @@ #include <stdint.h> #include <stddef.h> // offsetof + +#include "compiler_support.h" #include "eeconfig.h" #include "util.h" @@ -58,4 +60,4 @@ typedef struct PACKED { // Size of EEPROM being used, other code can refer to this for available EEPROM #define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE)) -_Static_assert((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); +STATIC_ASSERT((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); diff --git a/quantum/painter/qff.h b/quantum/painter/qff.h index c3b831da17..ed88508d73 100644 --- a/quantum/painter/qff.h +++ b/quantum/painter/qff.h @@ -9,6 +9,7 @@ #include <stdint.h> #include <stdbool.h> +#include "compiler_support.h" #include "qp_stream.h" #include "qp_internal.h" #include "qgf.h" @@ -36,7 +37,7 @@ typedef struct QP_PACKED qff_font_descriptor_v1_t { uint8_t transparency_index; // palette index used for transparent pixels (not yet implemented) } qff_font_descriptor_v1_t; -_Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF"); +STATIC_ASSERT(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF"); #define QFF_MAGIC 0x464651 @@ -54,14 +55,14 @@ 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"); +STATIC_ASSERT(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF"); 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; -_Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + (95 * sizeof(qff_ascii_glyph_v1_t))), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF"); +STATIC_ASSERT(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + (95 * sizeof(qff_ascii_glyph_v1_t))), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF"); ///////////////////////////////////////// // Unicode glyph table descriptor @@ -73,7 +74,7 @@ typedef struct QP_PACKED qff_unicode_glyph_v1_t { 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"); +STATIC_ASSERT(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF"); 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) } diff --git a/quantum/painter/qgf.h b/quantum/painter/qgf.h index 33a37709e6..a1e245f15d 100644 --- a/quantum/painter/qgf.h +++ b/quantum/painter/qgf.h @@ -9,6 +9,7 @@ #include <stdint.h> #include <stdbool.h> +#include "compiler_support.h" #include "qp_stream.h" #include "qp_internal.h" @@ -24,7 +25,7 @@ typedef struct QP_PACKED qgf_block_header_v1_t { uint32_t length : 24; // 24-bit blob length, allowing for block sizes of a maximum of 16MB. } qgf_block_header_v1_t; -_Static_assert(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF"); ///////////////////////////////////////// // Graphics descriptor @@ -42,7 +43,7 @@ typedef struct QP_PACKED qgf_graphics_descriptor_v1_t { uint16_t frame_count; // minimum of 1 } qgf_graphics_descriptor_v1_t; -_Static_assert(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF"); #define QGF_MAGIC 0x464751 @@ -56,7 +57,7 @@ typedef struct QP_PACKED qgf_frame_offsets_v1_t { uint32_t offset[0]; // '0' signifies that this struct is immediately followed by the frame offsets } qgf_frame_offsets_v1_t; -_Static_assert(sizeof(qgf_frame_offsets_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_frame_offsets_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_frame_offsets_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_frame_offsets_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); ///////////////////////////////////////// // Frame descriptor @@ -72,7 +73,7 @@ typedef struct QP_PACKED qgf_frame_v1_t { uint16_t delay; // frame delay time for animations (in units of milliseconds) } qgf_frame_v1_t; -_Static_assert(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF"); #define QGF_FRAME_FLAG_DELTA 0x02 #define QGF_FRAME_FLAG_TRANSPARENT 0x01 @@ -88,14 +89,14 @@ typedef struct QP_PACKED qgf_palette_entry_v1_t { uint8_t v; // value component: `[0,1]` is mapped to `[0,255]` uint8_t. } qgf_palette_entry_v1_t; -_Static_assert(sizeof(qgf_palette_entry_v1_t) == 3, "Palette entry is not 3 bytes in size"); +STATIC_ASSERT(sizeof(qgf_palette_entry_v1_t) == 3, "Palette entry is not 3 bytes in size"); typedef struct QP_PACKED qgf_palette_v1_t { qgf_block_header_v1_t header; // = { .type_id = 0x03, .neg_type_id = (~0x03), .length = (N * 3 * sizeof(uint8_t)) } qgf_palette_entry_v1_t hsv[0]; // N * hsv, where N is the number of palette entries depending on the frame format in the descriptor } qgf_palette_v1_t; -_Static_assert(sizeof(qgf_palette_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_palette_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_palette_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_palette_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); ///////////////////////////////////////// // Frame delta descriptor @@ -110,7 +111,7 @@ typedef struct QP_PACKED qgf_delta_v1_t { uint16_t bottom; // The bottom pixel location to to draw the delta image } qgf_delta_v1_t; -_Static_assert(sizeof(qgf_delta_v1_t) == (sizeof(qgf_block_header_v1_t) + 8), "qgf_delta_v1_t must be 13 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_delta_v1_t) == (sizeof(qgf_block_header_v1_t) + 8), "qgf_delta_v1_t must be 13 bytes in v1 of QGF"); ///////////////////////////////////////// // Frame data descriptor @@ -122,7 +123,7 @@ typedef struct QP_PACKED qgf_data_v1_t { uint8_t data[0]; // 0 signifies that this struct is immediately followed by the length of data specified in the header } qgf_data_v1_t; -_Static_assert(sizeof(qgf_data_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_data_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_data_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_data_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // QGF API diff --git a/quantum/painter/qp_draw_core.c b/quantum/painter/qp_draw_core.c index aa5fa4aa76..852abb19e8 100644 --- a/quantum/painter/qp_draw_core.c +++ b/quantum/painter/qp_draw_core.c @@ -2,12 +2,13 @@ // Copyright 2021 Paul Cotter (@gr1mr3aver) // SPDX-License-Identifier: GPL-2.0-or-later +#include "compiler_support.h" #include "qp_internal.h" #include "qp_comms.h" #include "qp_draw.h" #include "qgf.h" -_Static_assert((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE % 16) == 0, "QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE needs to be a non-zero multiple of 16"); +STATIC_ASSERT((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE % 16) == 0, "QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE needs to be a non-zero multiple of 16"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Global variables diff --git a/quantum/painter/qp_internal.c b/quantum/painter/qp_internal.c index 24b881bd09..fe0c598d78 100644 --- a/quantum/painter/qp_internal.c +++ b/quantum/painter/qp_internal.c @@ -3,6 +3,8 @@ #include "qp_internal.h" +#include "compiler_support.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter Core API: device registration @@ -67,7 +69,7 @@ static void qp_internal_display_timeout_task(void) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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"); +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 diff --git a/quantum/painter/qp_internal_formats.h b/quantum/painter/qp_internal_formats.h index 1beb604b9e..bd7105cab2 100644 --- a/quantum/painter/qp_internal_formats.h +++ b/quantum/painter/qp_internal_formats.h @@ -3,6 +3,7 @@ #pragma once +#include "compiler_support.h" #include "qp_internal.h" //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,7 @@ typedef union QP_PACKED qp_pixel_t { uint32_t dummy; } qp_pixel_t; -_Static_assert(sizeof(qp_pixel_t) == 4, "Invalid size for qp_pixel_t"); +STATIC_ASSERT(sizeof(qp_pixel_t) == 4, "Invalid size for qp_pixel_t"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter image format 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 bcaf94af8b..a2a86e175c 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -41,44 +41,59 @@ #define QK_MODS_GET_MODS(kc) (((kc) >> 8) & 0x1F) #define QK_MODS_GET_BASIC_KEYCODE(kc) ((kc)&0xFF) -// Keycode modifiers & aliases +// Modified keycodes #define LCTL(kc) (QK_LCTL | (kc)) #define LSFT(kc) (QK_LSFT | (kc)) #define LALT(kc) (QK_LALT | (kc)) #define LGUI(kc) (QK_LGUI | (kc)) + #define LOPT(kc) LALT(kc) #define LCMD(kc) LGUI(kc) #define LWIN(kc) LGUI(kc) + +#define C(kc) LCTL(kc) +#define S(kc) LSFT(kc) +#define A(kc) LALT(kc) +#define G(kc) LGUI(kc) + +#define LCS(kc) (QK_LCTL | QK_LSFT | (kc)) +#define LCA(kc) (QK_LCTL | QK_LALT | (kc)) +#define LCG(kc) (QK_LCTL | QK_LGUI | (kc)) +#define LSA(kc) (QK_LSFT | QK_LALT | (kc)) +#define LSG(kc) (QK_LSFT | QK_LGUI | (kc)) +#define LAG(kc) (QK_LALT | QK_LGUI | (kc)) +#define LCSG(kc) (QK_LCTL | QK_LSFT | QK_LGUI | (kc)) +#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)) #define RGUI(kc) (QK_RGUI | (kc)) + #define ALGR(kc) RALT(kc) #define ROPT(kc) RALT(kc) #define RCMD(kc) RGUI(kc) #define RWIN(kc) RGUI(kc) -#define HYPR(kc) (QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI | (kc)) -#define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc)) -#define LCAG(kc) (QK_LCTL | QK_LALT | QK_LGUI | (kc)) -#define LSG(kc) (QK_LSFT | QK_LGUI | (kc)) -#define SGUI(kc) LSG(kc) -#define SCMD(kc) LSG(kc) -#define SWIN(kc) LSG(kc) -#define LAG(kc) (QK_LALT | QK_LGUI | (kc)) +#define RCA(kc) (QK_RCTL | QK_RALT | (kc)) +#define RCS(kc) (QK_RCTL | QK_RSFT | (kc)) +#define RCG(kc) (QK_RCTL | QK_RGUI | (kc)) +#define RSA(kc) (QK_RSFT | QK_RALT | (kc)) #define RSG(kc) (QK_RSFT | QK_RGUI | (kc)) #define RAG(kc) (QK_RALT | QK_RGUI | (kc)) -#define LCA(kc) (QK_LCTL | QK_LALT | (kc)) -#define LSA(kc) (QK_LSFT | QK_LALT | (kc)) -#define RSA(kc) (QK_RSFT | QK_RALT | (kc)) -#define RCS(kc) (QK_RCTL | QK_RSFT | (kc)) +#define RCSG(kc) (QK_RCTL | QK_RSFT | QK_RGUI | (kc)) +#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) -// Modified keycode aliases -#define C(kc) LCTL(kc) -#define S(kc) LSFT(kc) -#define A(kc) LALT(kc) -#define G(kc) LGUI(kc) +#define HYPR(kc) (QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI | (kc)) +#define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc)) // GOTO layer - 32 layer max #define TO(layer) (QK_TO | ((layer)&0x1F)) @@ -127,50 +142,63 @@ #define QK_MOD_TAP_GET_MODS(kc) (((kc) >> 8) & 0x1F) #define QK_MOD_TAP_GET_TAP_KEYCODE(kc) ((kc)&0xFF) +// Mod-Tap shortcuts #define LCTL_T(kc) MT(MOD_LCTL, kc) -#define RCTL_T(kc) MT(MOD_RCTL, kc) -#define CTL_T(kc) LCTL_T(kc) - #define LSFT_T(kc) MT(MOD_LSFT, kc) -#define RSFT_T(kc) MT(MOD_RSFT, kc) -#define SFT_T(kc) LSFT_T(kc) - #define LALT_T(kc) MT(MOD_LALT, kc) -#define RALT_T(kc) MT(MOD_RALT, kc) -#define LOPT_T(kc) LALT_T(kc) -#define ROPT_T(kc) RALT_T(kc) -#define ALGR_T(kc) RALT_T(kc) +#define LGUI_T(kc) MT(MOD_LGUI, kc) + +#define CTL_T(kc) LCTL_T(kc) +#define SFT_T(kc) LSFT_T(kc) #define ALT_T(kc) LALT_T(kc) -#define OPT_T(kc) LOPT_T(kc) +#define GUI_T(kc) LGUI_T(kc) -#define LGUI_T(kc) MT(MOD_LGUI, kc) -#define RGUI_T(kc) MT(MOD_RGUI, kc) +#define LOPT_T(kc) LALT_T(kc) #define LCMD_T(kc) LGUI_T(kc) #define LWIN_T(kc) LGUI_T(kc) -#define RCMD_T(kc) RGUI_T(kc) -#define RWIN_T(kc) RGUI_T(kc) -#define GUI_T(kc) LGUI_T(kc) + +#define OPT_T(kc) LOPT_T(kc) #define CMD_T(kc) LCMD_T(kc) #define WIN_T(kc) LWIN_T(kc) -#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal -#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt -#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI -#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI -#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ -#define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI +#define LCS_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) +#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) +#define LCG_T(kc) MT(MOD_LCTL | MOD_LGUI, kc) +#define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc) +#define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) +#define LAG_T(kc) MT(MOD_LALT | MOD_LGUI, kc) +#define LCSG_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LGUI, kc) +#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 LAG_T(kc) MT(MOD_LALT | MOD_LGUI, kc) // Left Alt + GUI -#define RSG_T(kc) MT(MOD_RSFT | MOD_RGUI, kc) // Right Shift + GUI -#define RAG_T(kc) MT(MOD_RALT | MOD_RGUI, kc) // Right Alt + GUI -#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt -#define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc) // Left Shift + Alt -#define RSA_T(kc) MT(MOD_RSFT | MOD_RALT, kc) // Right Shift + Alt -#define RCS_T(kc) MT(MOD_RCTL | MOD_RSFT, kc) // Right Control + Shift + +#define RCTL_T(kc) MT(MOD_RCTL, kc) +#define RSFT_T(kc) MT(MOD_RSFT, kc) +#define RALT_T(kc) MT(MOD_RALT, kc) +#define RGUI_T(kc) MT(MOD_RGUI, kc) + +#define ROPT_T(kc) RALT_T(kc) +#define ALGR_T(kc) RALT_T(kc) +#define RCMD_T(kc) RGUI_T(kc) +#define RWIN_T(kc) RGUI_T(kc) + +#define RCS_T(kc) MT(MOD_RCTL | MOD_RSFT, kc) +#define RCA_T(kc) MT(MOD_RCTL | MOD_RALT, kc) +#define RCG_T(kc) MT(MOD_RCTL | MOD_RGUI, kc) +#define RSA_T(kc) MT(MOD_RSFT | MOD_RALT, kc) +#define RSG_T(kc) MT(MOD_RSFT | MOD_RGUI, kc) +#define RAG_T(kc) MT(MOD_RALT | MOD_RGUI, kc) +#define RCSG_T(kc) MT(MOD_RCTL | MOD_RSFT | MOD_RGUI, kc) +#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 diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 21aec90675..55b0fc3596 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -57,3 +57,5 @@ #define KC_ACL2 QK_MOUSE_ACCELERATION_2 #define QK_OUTPUT_AUTO OU_AUTO + +#define C_S_T(kc) LCS_T(kc) 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/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h index 62005ebea9..0115edee6a 100644 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ b/quantum/rgb_matrix/rgb_matrix_types.h @@ -18,6 +18,8 @@ #include <stdint.h> #include <stdbool.h> + +#include "compiler_support.h" #include "color.h" #include "util.h" @@ -84,4 +86,4 @@ typedef union rgb_config_t { }; } rgb_config_t; -_Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec."); +STATIC_ASSERT(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec."); diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index f5fd450d4c..c061e71895 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -16,6 +16,8 @@ #pragma once +#include "compiler_support.h" + // DEPRECATED DEFINES - DO NOT USE #if defined(RGBLED_NUM) # define RGBLIGHT_LED_COUNT RGBLED_NUM @@ -260,7 +262,7 @@ typedef union rgblight_config_t { }; } rgblight_config_t; -_Static_assert(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec."); +STATIC_ASSERT(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec."); typedef struct _rgblight_status_t { uint8_t base_mode; diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 9af3c29d75..59b6009ec4 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -13,6 +13,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 "compiler_support.h" #include "split_util.h" #include "matrix.h" #include "keyboard.h" @@ -62,7 +64,7 @@ static struct { } split_config; #if defined(SPLIT_USB_DETECT) -_Static_assert((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL."); +STATIC_ASSERT((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL."); static bool usb_bus_detected(void) { for (uint16_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { // This will return true if a USB connection has been established @@ -88,9 +90,9 @@ static inline bool usb_bus_detected(void) { # endif # endif # if defined(SPLIT_USB_DETECT) -_Static_assert(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT."); +STATIC_ASSERT(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT."); # endif -_Static_assert(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check."); +STATIC_ASSERT(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check."); static uint32_t split_watchdog_started = 0; static bool split_watchdog_done = false; diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index 5bfbe2aec7..694737868a 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h @@ -16,6 +16,8 @@ #pragma once +#include "compiler_support.h" + enum serial_transaction_id { #ifdef USE_I2C I2C_EXECUTE_CALLBACK, @@ -122,4 +124,4 @@ enum serial_transaction_id { }; // Ensure we only use 5 bits for transaction -_Static_assert(NUM_TOTAL_TRANSACTIONS <= (1 << 5), "Max number of usable transactions exceeded"); +STATIC_ASSERT(NUM_TOTAL_TRANSACTIONS <= (1 << 5), "Max number of usable transactions exceeded"); diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 83edc34859..ea687af1c2 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c @@ -17,6 +17,7 @@ #include <string.h> #include <debug.h> +#include "compiler_support.h" #include "transactions.h" #include "transport.h" #include "transaction_id_define.h" @@ -36,7 +37,7 @@ # include "i2c_slave.h" // Ensure the I2C buffer has enough space -_Static_assert(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shared_memory_t too large for I2C_SLAVE_REG_COUNT"); +STATIC_ASSERT(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shared_memory_t too large for I2C_SLAVE_REG_COUNT"); split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg; diff --git a/quantum/unicode/unicode.h b/quantum/unicode/unicode.h index f19d803335..7cddc78b7a 100644 --- a/quantum/unicode/unicode.h +++ b/quantum/unicode/unicode.h @@ -17,6 +17,8 @@ #pragma once #include <stdint.h> + +#include "compiler_support.h" #include "unicode_keycodes.h" /** @@ -33,7 +35,7 @@ typedef union unicode_config_t { }; } unicode_config_t; -_Static_assert(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec."); +STATIC_ASSERT(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec."); extern unicode_config_t unicode_config; 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 diff --git a/quantum/wear_leveling/wear_leveling_internal.h b/quantum/wear_leveling/wear_leveling_internal.h index e83f9b22ea..c590f42235 100644 --- a/quantum/wear_leveling/wear_leveling_internal.h +++ b/quantum/wear_leveling/wear_leveling_internal.h @@ -2,9 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#ifdef __cplusplus -# define _Static_assert static_assert -#endif +#include "compiler_support.h" #include <stdint.h> #include <string.h> @@ -62,9 +60,9 @@ typedef uint64_t backing_store_int_t; #endif // WEAR_LEVELING_ASSERTS // Compile-time validation of configurable options -_Static_assert(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size"); -_Static_assert(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size"); -_Static_assert(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size"); +STATIC_ASSERT(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size"); +STATIC_ASSERT(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size"); +STATIC_ASSERT(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size"); // Backing Store API, to be implemented elsewhere by flash driver etc. bool backing_store_init(void); @@ -86,7 +84,7 @@ typedef union write_log_entry_t { uint8_t raw8[8]; } write_log_entry_t; -_Static_assert(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8"); +STATIC_ASSERT(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8"); /** * Log entry type discriminator. @@ -104,7 +102,7 @@ enum { LOG_ENTRY_TYPES }; -_Static_assert(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage"); +STATIC_ASSERT(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage"); #define BITMASK_FOR_BITCOUNT(n) ((1 << (n)) - 1) |