From 27a59c897c28c1d12c5a3f03fe6097cc323c71a0 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 12 Jul 2024 08:17:54 +0700 Subject: [PATCH] fix: restores status led control voyager / moonlander --- keyboards/zsa/common/oryx.c | 22 +++++++++ keyboards/zsa/moonlander/matrix.c | 12 ++--- keyboards/zsa/moonlander/moonlander.c | 69 ++++++++++++++------------- keyboards/zsa/moonlander/moonlander.h | 12 ++--- keyboards/zsa/voyager/voyager.c | 14 ++++-- 5 files changed, 79 insertions(+), 50 deletions(-) diff --git a/keyboards/zsa/common/oryx.c b/keyboards/zsa/common/oryx.c index da639a7b45eb..97fcdcc546ce 100644 --- a/keyboards/zsa/common/oryx.c +++ b/keyboards/zsa/common/oryx.c @@ -2,11 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include QMK_KEYBOARD_H #include "oryx.h" rawhid_state_t rawhid_state = { .paired = false, .rgb_control = false, + .status_led_control = false, }; uint8_t pairing_input_index = 0; @@ -250,6 +252,26 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { } case ORYX_STATUS_LED_CONTROL: { rawhid_state.status_led_control = param[0]; + if (!param[0]) { +#ifdef STATUS_LED_1 + STATUS_LED_1(0); +#endif +#ifdef STATUS_LED_2 + STATUS_LED_2(0); +#endif +#ifdef STATUS_LED_3 + STATUS_LED_3(0); +#endif +#ifdef STATUS_LED_4 + STATUS_LED_4(0); +#endif +#ifdef STATUS_LED_5 + STATUS_LED_5(0); +#endif +#ifdef STATUS_LED_6 + STATUS_LED_6(0); +#endif + } uint8_t event[RAW_EPSIZE]; event[0] = ORYX_EVT_STATUS_LED_CONTROL; event[1] = rawhid_state.status_led_control; diff --git a/keyboards/zsa/moonlander/matrix.c b/keyboards/zsa/moonlander/matrix.c index c301cdbb3be1..d0a1a82b04e1 100644 --- a/keyboards/zsa/moonlander/matrix.c +++ b/keyboards/zsa/moonlander/matrix.c @@ -191,12 +191,12 @@ void matrix_power_up(void) { is_launching = temp_launching; if (!is_launching) { - ML_LED_1(false); - ML_LED_2(false); - ML_LED_3(false); - ML_LED_4(false); - ML_LED_5(false); - ML_LED_6(false); + STATUS_LED_1(false); + STATUS_LED_2(false); + STATUS_LED_3(false); + STATUS_LED_4(false); + STATUS_LED_5(false); + STATUS_LED_6(false); } // initialize matrix state: all keys off diff --git a/keyboards/zsa/moonlander/moonlander.c b/keyboards/zsa/moonlander/moonlander.c index ed59b1d1f5a7..011d049e4fc6 100644 --- a/keyboards/zsa/moonlander/moonlander.c +++ b/keyboards/zsa/moonlander/moonlander.c @@ -31,14 +31,14 @@ static uint32_t dynamic_macro_led(uint32_t trigger_time, void *cb_arg) { static bool led_state = true; if (!is_launching) { led_state = !led_state; - ML_LED_3(led_state); + STATUS_LED_3(led_state); } return 100; } void dynamic_macro_record_start_user(int8_t direction) { if (dynamic_macro_token == INVALID_DEFERRED_TOKEN) { - ML_LED_3(true); + STATUS_LED_3(true); dynamic_macro_token = defer_exec(100, dynamic_macro_led, NULL); } } @@ -46,7 +46,7 @@ void dynamic_macro_record_start_user(int8_t direction) { void dynamic_macro_record_end_user(int8_t direction) { if (cancel_deferred_exec(dynamic_macro_token)) { dynamic_macro_token = INVALID_DEFERRED_TOKEN; - ML_LED_3(false); + STATUS_LED_3(false); } } # endif @@ -56,45 +56,45 @@ static uint32_t startup_exec(uint32_t trigger_time, void *cb_arg) { switch (startup_loop++) { case 0: - ML_LED_1(true); - ML_LED_2(false); - ML_LED_3(false); - ML_LED_4(false); - ML_LED_5(false); - ML_LED_6(false); + STATUS_LED_1(true); + STATUS_LED_2(false); + STATUS_LED_3(false); + STATUS_LED_4(false); + STATUS_LED_5(false); + STATUS_LED_6(false); break; case 1: - ML_LED_2(true); + STATUS_LED_2(true); break; case 2: - ML_LED_3(true); + STATUS_LED_3(true); break; case 3: - ML_LED_4(true); + STATUS_LED_4(true); break; case 4: - ML_LED_5(true); + STATUS_LED_5(true); break; case 5: - ML_LED_6(true); + STATUS_LED_6(true); break; case 6: - ML_LED_1(false); + STATUS_LED_1(false); break; case 7: - ML_LED_2(false); + STATUS_LED_2(false); break; case 8: - ML_LED_3(false); + STATUS_LED_3(false); break; case 9: - ML_LED_4(false); + STATUS_LED_4(false); break; case 10: - ML_LED_5(false); + STATUS_LED_5(false); break; case 11: - ML_LED_6(false); + STATUS_LED_6(false); break; case 12: is_launching = false; @@ -121,6 +121,9 @@ layer_state_t layer_state_set_kb(layer_state_t state) { #if !defined(MOONLANDER_USER_LEDS) state = layer_state_set_user(state); if (is_launching || !keyboard_config.led_level) return state; +#ifdef ORYX_ENABLE + if (rawhid_state.status_led_control) return state; +#endif bool LED_1 = false; bool LED_2 = false; bool LED_3 = false; @@ -161,13 +164,13 @@ layer_state_t layer_state_set_kb(layer_state_t state) { break; } - ML_LED_1(LED_1); - ML_LED_2(LED_2); - ML_LED_3(LED_3); - ML_LED_4(LED_4); - ML_LED_5(LED_5); + STATUS_LED_1(LED_1); + STATUS_LED_2(LED_2); + STATUS_LED_3(LED_3); + STATUS_LED_4(LED_4); + STATUS_LED_5(LED_5); #if !defined(CAPS_LOCK_STATUS) - ML_LED_6(LED_6); + STATUS_LED_6(LED_6); #endif #endif #ifdef ORYX_ENABLE @@ -330,7 +333,7 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = { #ifdef CAPS_LOCK_STATUS void led_update_ports(led_t led_state) { - ML_LED_6(led_state.caps_lock); + STATUS_LED_6(led_state.caps_lock); } #endif @@ -345,12 +348,12 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { if (keyboard_config.led_level) { layer_state_set_kb(layer_state); } else { - ML_LED_1(false); - ML_LED_2(false); - ML_LED_3(false); - ML_LED_4(false); - ML_LED_5(false); - ML_LED_6(false); + STATUS_LED_1(false); + STATUS_LED_2(false); + STATUS_LED_3(false); + STATUS_LED_4(false); + STATUS_LED_5(false); + STATUS_LED_6(false); } } break; diff --git a/keyboards/zsa/moonlander/moonlander.h b/keyboards/zsa/moonlander/moonlander.h index a5c7552d6a52..34e00e2c0f6e 100644 --- a/keyboards/zsa/moonlander/moonlander.h +++ b/keyboards/zsa/moonlander/moonlander.h @@ -29,13 +29,13 @@ extern bool mcp23018_leds[]; #define MCP23018_DEFAULT_ADDRESS 0b0100000 -#define ML_LED_1(status) gpio_write_pin(B5, (bool)status) -#define ML_LED_2(status) gpio_write_pin(B4, (bool)status) -#define ML_LED_3(status) gpio_write_pin(B3, (bool)status) +#define STATUS_LED_1(status) gpio_write_pin(B5, (bool)status) +#define STATUS_LED_2(status) gpio_write_pin(B4, (bool)status) +#define STATUS_LED_3(status) gpio_write_pin(B3, (bool)status) -#define ML_LED_4(status) mcp23018_leds[0] = (bool)status -#define ML_LED_5(status) mcp23018_leds[1] = (bool)status -#define ML_LED_6(status) mcp23018_leds[2] = (bool)status +#define STATUS_LED_4(status) mcp23018_leds[0] = (bool)status +#define STATUS_LED_5(status) mcp23018_leds[1] = (bool)status +#define STATUS_LED_6(status) mcp23018_leds[2] = (bool)status enum planck_ez_keycodes { TOGGLE_LAYER_COLOR = QK_KB_0, diff --git a/keyboards/zsa/voyager/voyager.c b/keyboards/zsa/voyager/voyager.c index 9e65ea9a6934..d1ced480d7f3 100644 --- a/keyboards/zsa/voyager/voyager.c +++ b/keyboards/zsa/voyager/voyager.c @@ -97,16 +97,20 @@ layer_state_t layer_state_set_kb(layer_state_t state) { #if !defined(VOYAGER_USER_LEDS) state = layer_state_set_user(state); if (is_launching || !keyboard_config.led_level) return state; - +#ifdef ORYX_ENABLE + if (rawhid_state.status_led_control) return state; +#endif uint8_t layer = get_highest_layer(state); - STATUS_LED_1(layer & (1 << 0)); - STATUS_LED_2(layer & (1 << 1)); - STATUS_LED_3(layer & (1 << 2)); + if(!rawhid_state.status_led_control) { + STATUS_LED_1(layer & (1 << 0)); + STATUS_LED_2(layer & (1 << 1)); + STATUS_LED_3(layer & (1 << 2)); # if !defined(CAPS_LOCK_STATUS) - STATUS_LED_4(layer & (1 << 3)); + STATUS_LED_4(layer & (1 << 3)); # endif + } #endif #ifdef ORYX_ENABLE layer_state_set_oryx(state);