diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 49197dc91e..68f9a1dd08 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -353,7 +353,7 @@ ifeq ($(strip $(LED_MATRIX_ENABLE)), yes) COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations/runners POST_CONFIG_H += $(QUANTUM_DIR)/led_matrix/post_config.h - SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c + SRC += $(QUANTUM_DIR)/process_keycode/process_led_matrix.c SRC += $(QUANTUM_DIR)/led_matrix/led_matrix.c SRC += $(QUANTUM_DIR)/led_matrix/led_matrix_drivers.c LIB8TION_ENABLE := yes diff --git a/quantum/process_keycode/process_backlight.c b/quantum/process_keycode/process_backlight.c index c1596ec07d..dafe979760 100644 --- a/quantum/process_keycode/process_backlight.c +++ b/quantum/process_keycode/process_backlight.c @@ -15,36 +15,11 @@ */ #include "process_backlight.h" - -#ifdef LED_MATRIX_ENABLE -# include "led_matrix.h" -#else -# include "backlight.h" -#endif +#include "backlight.h" bool process_backlight(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { -#ifdef LED_MATRIX_ENABLE - case QK_BACKLIGHT_ON: - led_matrix_enable(); - return false; - case QK_BACKLIGHT_OFF: - led_matrix_disable(); - return false; - case QK_BACKLIGHT_DOWN: - led_matrix_decrease_val(); - return false; - case QK_BACKLIGHT_UP: - led_matrix_increase_val(); - return false; - case QK_BACKLIGHT_TOGGLE: - led_matrix_toggle(); - return false; - case QK_BACKLIGHT_STEP: - led_matrix_step(); - return false; -#else case QK_BACKLIGHT_ON: backlight_level(BACKLIGHT_LEVELS); return false; @@ -63,11 +38,10 @@ bool process_backlight(uint16_t keycode, keyrecord_t *record) { case QK_BACKLIGHT_STEP: backlight_step(); return false; -# ifdef BACKLIGHT_BREATHING +#ifdef BACKLIGHT_BREATHING case QK_BACKLIGHT_TOGGLE_BREATHING: backlight_toggle_breathing(); return false; -# endif #endif } } diff --git a/quantum/process_keycode/process_led_matrix.c b/quantum/process_keycode/process_led_matrix.c new file mode 100644 index 0000000000..217c9a2c28 --- /dev/null +++ b/quantum/process_keycode/process_led_matrix.c @@ -0,0 +1,32 @@ +// Copyright 2024 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "process_led_matrix.h" +#include "led_matrix.h" + +bool process_led_matrix(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { + case QK_BACKLIGHT_ON: + led_matrix_enable(); + return false; + case QK_BACKLIGHT_OFF: + led_matrix_disable(); + return false; + case QK_BACKLIGHT_DOWN: + led_matrix_decrease_val(); + return false; + case QK_BACKLIGHT_UP: + led_matrix_increase_val(); + return false; + case QK_BACKLIGHT_TOGGLE: + led_matrix_toggle(); + return false; + case QK_BACKLIGHT_STEP: + led_matrix_step(); + return false; + } + } + + return true; +} diff --git a/quantum/process_keycode/process_led_matrix.h b/quantum/process_keycode/process_led_matrix.h new file mode 100644 index 0000000000..407d04aa27 --- /dev/null +++ b/quantum/process_keycode/process_led_matrix.h @@ -0,0 +1,10 @@ +// Copyright 2024 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include "action.h" + +bool process_led_matrix(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum.c b/quantum/quantum.c index 6639dc2291..011f9d73e4 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -16,7 +16,7 @@ #include "quantum.h" -#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) +#ifdef BACKLIGHT_ENABLE # include "process_backlight.h" #endif @@ -40,6 +40,10 @@ # include "process_leader.h" #endif +#ifdef LED_MATRIX_ENABLE +# include "process_led_matrix.h" +#endif + #ifdef MAGIC_ENABLE # include "process_magic.h" #endif @@ -333,9 +337,12 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef AUDIO_ENABLE process_audio(keycode, record) && #endif -#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) +#if defined(BACKLIGHT_ENABLE) process_backlight(keycode, record) && #endif +#if defined(LED_MATRIX_ENABLE) + process_led_matrix(keycode, record) && +#endif #ifdef STENO_ENABLE process_steno(keycode, record) && #endif