logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git
commit: 25f608c1b437060e8c9b451ed81c7e37a2531284
parent 4acdddbf48707e5221cb754b4aa5caf32ce28276
Author: Ryan <fauxpark@gmail.com>
Date:   Thu, 11 Apr 2024 14:06:36 +1000

Separate keycode handling for LED Matrix and Backlight (#23426)


Diffstat:

Mbuilddefs/common_features.mk2+-
Mquantum/process_keycode/process_backlight.c30++----------------------------
Aquantum/process_keycode/process_led_matrix.c32++++++++++++++++++++++++++++++++
Aquantum/process_keycode/process_led_matrix.h10++++++++++
Mquantum/quantum.c11+++++++++--
5 files changed, 54 insertions(+), 31 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -0,0 +1,10 @@ +// Copyright 2024 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <stdint.h> +#include <stdbool.h> +#include "action.h" + +bool process_led_matrix(uint16_t keycode, keyrecord_t *record); diff --git 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