Browse Source

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

pull/23455/head
Ryan 2 weeks ago
committed by GitHub
parent
commit
25f608c1b4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
5 changed files with 54 additions and 31 deletions
  1. +1
    -1
      builddefs/common_features.mk
  2. +2
    -28
      quantum/process_keycode/process_backlight.c
  3. +32
    -0
      quantum/process_keycode/process_led_matrix.c
  4. +10
    -0
      quantum/process_keycode/process_led_matrix.h
  5. +9
    -2
      quantum/quantum.c

+ 1
- 1
builddefs/common_features.mk View File

@ -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


+ 2
- 28
quantum/process_keycode/process_backlight.c View File

@ -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
}
}


+ 32
- 0
quantum/process_keycode/process_led_matrix.c View File

@ -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;
}

+ 10
- 0
quantum/process_keycode/process_led_matrix.h View File

@ -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);

+ 9
- 2
quantum/quantum.c View File

@ -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


Loading…
Cancel
Save