Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate RGBLight/RGB Matrix keycode handling #23679

Merged
merged 10 commits into from
Oct 12, 2024
8 changes: 2 additions & 6 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
POST_CONFIG_H += $(QUANTUM_DIR)/rgblight/rgblight_post_config.h
OPT_DEFS += -DRGBLIGHT_ENABLE
OPT_DEFS += -DRGBLIGHT_$(strip $(shell echo $(RGBLIGHT_DRIVER) | tr '[:lower:]' '[:upper:]'))
SRC += $(QUANTUM_DIR)/process_keycode/process_underglow.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgblight/rgblight.c
SRC += $(QUANTUM_DIR)/rgblight/rgblight_drivers.c
CIE1931_CURVE := yes
RGB_KEYCODES_ENABLE := yes
endif

ifeq ($(strip $(RGBLIGHT_DRIVER)), ws2812)
Expand Down Expand Up @@ -461,12 +461,12 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners
POST_CONFIG_H += $(QUANTUM_DIR)/rgb_matrix/post_config.h
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb_matrix.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix_drivers.c
LIB8TION_ENABLE := yes
CIE1931_CURVE := yes
RGB_KEYCODES_ENABLE := yes

ifeq ($(strip $(RGB_MATRIX_DRIVER)), aw20216s)
SPI_DRIVER_REQUIRED = yes
Expand Down Expand Up @@ -569,10 +569,6 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
endif
endif

ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
endif

VARIABLE_TRACE ?= no
ifneq ($(strip $(VARIABLE_TRACE)),no)
SRC += $(QUANTUM_DIR)/variable_trace.c
Expand Down
226 changes: 0 additions & 226 deletions quantum/process_keycode/process_rgb.c

This file was deleted.

22 changes: 0 additions & 22 deletions quantum/process_keycode/process_rgb.h

This file was deleted.

101 changes: 101 additions & 0 deletions quantum/process_keycode/process_rgb_matrix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#include "process_rgb_matrix.h"
#include "rgb_matrix.h"
#include "action_util.h"
#include "keycodes.h"
#include "modifiers.h"

bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#ifdef RGB_TRIGGER_ON_KEYDOWN
if (record->event.pressed) {
#else
if (!record->event.pressed) {
#endif
bool shifted = get_mods() & MOD_MASK_SHIFT;
switch (keycode) {
case QK_RGB_MATRIX_ON:
rgb_matrix_enable();
return false;
case QK_RGB_MATRIX_OFF:
rgb_matrix_disable();
return false;
case QK_RGB_MATRIX_TOGGLE:
rgb_matrix_toggle();
return false;
case QK_RGB_MATRIX_MODE_NEXT:
if (shifted) {
rgb_matrix_step_reverse();
} else {
rgb_matrix_step();
}
return false;
case QK_RGB_MATRIX_MODE_PREVIOUS:
if (shifted) {
rgb_matrix_step();
} else {
rgb_matrix_step_reverse();
}
return false;
case QK_RGB_MATRIX_HUE_UP:
if (shifted) {
rgb_matrix_decrease_hue();
} else {
rgb_matrix_increase_hue();
}
return false;
case QK_RGB_MATRIX_HUE_DOWN:
if (shifted) {
rgb_matrix_increase_hue();
} else {
rgb_matrix_decrease_hue();
}
return false;
case QK_RGB_MATRIX_SATURATION_UP:
if (shifted) {
rgb_matrix_decrease_sat();
} else {
rgb_matrix_increase_sat();
}
return false;
case QK_RGB_MATRIX_SATURATION_DOWN:
if (shifted) {
rgb_matrix_increase_sat();
} else {
rgb_matrix_decrease_sat();
}
return false;
case QK_RGB_MATRIX_VALUE_UP:
if (shifted) {
rgb_matrix_decrease_val();
} else {
rgb_matrix_increase_val();
}
return false;
case QK_RGB_MATRIX_VALUE_DOWN:
if (shifted) {
rgb_matrix_increase_val();
} else {
rgb_matrix_decrease_val();
}
return false;
case QK_RGB_MATRIX_SPEED_UP:
if (shifted) {
rgb_matrix_decrease_speed();
} else {
rgb_matrix_increase_speed();
}
return false;
case QK_RGB_MATRIX_SPEED_DOWN:
if (shifted) {
rgb_matrix_increase_speed();
} else {
rgb_matrix_decrease_speed();
}
return false;
}
}

return true;
}
Loading
Loading