From a5906493dc85fb309667f793e3bc24a852d1e726 Mon Sep 17 00:00:00 2001 From: Hiiwwy Date: Wed, 15 Jul 2026 20:09:40 +0800 Subject: [PATCH 1/4] Add XL Keyboards XL 87 RGB --- keyboards/xl_keyboards/xl_87_rgb/board.h | 8 + .../xl_keyboards/xl_87_rgb/keyboard.json | 301 ++++++++++++++++++ .../xl_87_rgb/keymaps/default/keymap.c | 27 ++ .../xl_87_rgb/ld/STM32F103xB_uf2boot_wl.ld | 62 ++++ keyboards/xl_keyboards/xl_87_rgb/mcuconf.h | 8 + keyboards/xl_keyboards/xl_87_rgb/readme.md | 26 ++ keyboards/xl_keyboards/xl_87_rgb/rules.mk | 8 + keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c | 157 +++++++++ 8 files changed, 597 insertions(+) create mode 100644 keyboards/xl_keyboards/xl_87_rgb/board.h create mode 100644 keyboards/xl_keyboards/xl_87_rgb/keyboard.json create mode 100644 keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c create mode 100644 keyboards/xl_keyboards/xl_87_rgb/ld/STM32F103xB_uf2boot_wl.ld create mode 100644 keyboards/xl_keyboards/xl_87_rgb/mcuconf.h create mode 100644 keyboards/xl_keyboards/xl_87_rgb/readme.md create mode 100644 keyboards/xl_keyboards/xl_87_rgb/rules.mk create mode 100644 keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c diff --git a/keyboards/xl_keyboards/xl_87_rgb/board.h b/keyboards/xl_keyboards/xl_87_rgb/board.h new file mode 100644 index 000000000000..1cf412bb939e --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/board.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef STM32_HSECLK +#define STM32_HSECLK 16000000 diff --git a/keyboards/xl_keyboards/xl_87_rgb/keyboard.json b/keyboards/xl_keyboards/xl_87_rgb/keyboard.json new file mode 100644 index 000000000000..e4e5df00575f --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/keyboard.json @@ -0,0 +1,301 @@ +{ + "manufacturer": "XL Keyboards", + "keyboard_name": "XL 87 RGB", + "maintainer": "Hiiwwy", + "bootloader": "uf2boot", + "diode_direction": "COL2ROW", + "features": { + "bootmagic": true, + "extrakey": true, + "mousekey": true, + "nkro": true, + "rgb_matrix": true + }, + "matrix_pins": { + "cols": ["A10", "A9", "A8", "B15", "B14", "B13", "B12", "B11", "B10", "B2", "B0", "A7", "A6", "B1", "A5", "A4", "A3"], + "rows": ["B5", "B4", "B3", "A15", "A1", "A2"] + }, + "processor": "STM32F103", + "rgb_matrix": { + "animations": { + "alphas_mods": true, + "band_pinwheel_sat": true, + "band_pinwheel_val": true, + "band_sat": true, + "band_spiral_sat": true, + "band_spiral_val": true, + "band_val": true, + "breathing": true, + "cycle_all": true, + "cycle_left_right": true, + "cycle_out_in": true, + "cycle_out_in_dual": true, + "cycle_pinwheel": true, + "cycle_spiral": true, + "cycle_up_down": true, + "digital_rain": true, + "dual_beacon": true, + "gradient_left_right": true, + "gradient_up_down": true, + "jellybean_raindrops": true, + "multisplash": true, + "rainbow_beacon": true, + "rainbow_moving_chevron": true, + "rainbow_pinwheels": true, + "raindrops": true, + "solid_multisplash": true, + "solid_reactive": true, + "solid_reactive_cross": true, + "solid_reactive_multicross": true, + "solid_reactive_multinexus": true, + "solid_reactive_multiwide": true, + "solid_reactive_nexus": true, + "solid_reactive_simple": true, + "solid_reactive_wide": true, + "solid_splash": true, + "splash": true, + "typing_heatmap": true + }, + "driver": "ws2812", + "layout": [ + {"matrix": [0, 0], "x": 0, "y": 60, "flags": 4}, + {"matrix": [0, 2], "x": 24, "y": 60, "flags": 4}, + {"matrix": [0, 3], "x": 36, "y": 60, "flags": 4}, + {"matrix": [0, 4], "x": 48, "y": 60, "flags": 4}, + {"matrix": [0, 5], "x": 60, "y": 60, "flags": 4}, + {"matrix": [0, 6], "x": 72, "y": 60, "flags": 4}, + {"matrix": [0, 7], "x": 84, "y": 60, "flags": 4}, + {"matrix": [0, 8], "x": 96, "y": 60, "flags": 4}, + {"matrix": [0, 9], "x": 108, "y": 60, "flags": 4}, + {"matrix": [0, 10], "x": 120, "y": 60, "flags": 4}, + {"matrix": [0, 11], "x": 132, "y": 60, "flags": 4}, + {"matrix": [0, 12], "x": 144, "y": 60, "flags": 4}, + {"matrix": [0, 13], "x": 156, "y": 60, "flags": 4}, + {"matrix": [0, 14], "x": 168, "y": 60, "flags": 4}, + {"matrix": [0, 15], "x": 180, "y": 60, "flags": 4}, + {"matrix": [0, 16], "x": 192, "y": 60, "flags": 4}, + + {"matrix": [1, 16], "x": 192, "y": 48, "flags": 4}, + {"matrix": [1, 15], "x": 180, "y": 48, "flags": 4}, + {"matrix": [1, 14], "x": 168, "y": 48, "flags": 4}, + {"matrix": [1, 13], "x": 156, "y": 48, "flags": 4}, + {"matrix": [1, 12], "x": 144, "y": 48, "flags": 4}, + {"matrix": [1, 11], "x": 132, "y": 48, "flags": 4}, + {"matrix": [1, 10], "x": 120, "y": 48, "flags": 4}, + {"matrix": [1, 9], "x": 108, "y": 48, "flags": 4}, + {"matrix": [1, 8], "x": 96, "y": 48, "flags": 4}, + {"matrix": [1, 7], "x": 84, "y": 48, "flags": 4}, + {"matrix": [1, 6], "x": 72, "y": 48, "flags": 4}, + {"matrix": [1, 5], "x": 60, "y": 48, "flags": 4}, + {"matrix": [1, 4], "x": 48, "y": 48, "flags": 4}, + {"matrix": [1, 3], "x": 36, "y": 48, "flags": 4}, + {"matrix": [1, 2], "x": 24, "y": 48, "flags": 4}, + {"matrix": [1, 1], "x": 12, "y": 48, "flags": 4}, + {"matrix": [1, 0], "x": 0, "y": 48, "flags": 4}, + + {"matrix": [2, 0], "x": 0, "y": 36, "flags": 4}, + {"matrix": [2, 1], "x": 12, "y": 36, "flags": 4}, + {"matrix": [2, 2], "x": 24, "y": 36, "flags": 4}, + {"matrix": [2, 3], "x": 36, "y": 36, "flags": 4}, + {"matrix": [2, 4], "x": 48, "y": 36, "flags": 4}, + {"matrix": [2, 5], "x": 60, "y": 36, "flags": 4}, + {"matrix": [2, 6], "x": 72, "y": 36, "flags": 4}, + {"matrix": [2, 7], "x": 84, "y": 36, "flags": 4}, + {"matrix": [2, 8], "x": 96, "y": 36, "flags": 4}, + {"matrix": [2, 9], "x": 108, "y": 36, "flags": 4}, + {"matrix": [2, 10], "x": 120, "y": 36, "flags": 4}, + {"matrix": [2, 11], "x": 132, "y": 36, "flags": 4}, + {"matrix": [2, 12], "x": 144, "y": 36, "flags": 4}, + {"matrix": [2, 13], "x": 156, "y": 36, "flags": 4}, + {"matrix": [2, 14], "x": 168, "y": 36, "flags": 4}, + {"matrix": [2, 15], "x": 180, "y": 36, "flags": 4}, + {"matrix": [2, 16], "x": 192, "y": 36, "flags": 4}, + + {"matrix": [3, 12], "x": 156, "y": 30, "flags": 4}, + {"matrix": [3, 11], "x": 132, "y": 24, "flags": 4}, + {"matrix": [3, 10], "x": 120, "y": 24, "flags": 4}, + {"matrix": [3, 9], "x": 108, "y": 24, "flags": 4}, + {"matrix": [3, 8], "x": 96, "y": 24, "flags": 4}, + {"matrix": [3, 7], "x": 84, "y": 24, "flags": 4}, + {"matrix": [3, 6], "x": 72, "y": 24, "flags": 4}, + {"matrix": [3, 5], "x": 60, "y": 24, "flags": 4}, + {"matrix": [3, 4], "x": 48, "y": 24, "flags": 4}, + {"matrix": [3, 3], "x": 36, "y": 24, "flags": 4}, + {"matrix": [3, 2], "x": 24, "y": 24, "flags": 4}, + {"matrix": [3, 1], "x": 12, "y": 24, "flags": 4}, + {"matrix": [3, 0], "x": 0, "y": 24, "flags": 4}, + + {"matrix": [4, 0], "x": 0, "y": 12, "flags": 4}, + {"matrix": [4, 1], "x": 12, "y": 12, "flags": 4}, + {"matrix": [4, 2], "x": 24, "y": 12, "flags": 4}, + {"matrix": [4, 3], "x": 36, "y": 12, "flags": 4}, + {"matrix": [4, 4], "x": 48, "y": 12, "flags": 4}, + {"matrix": [4, 5], "x": 60, "y": 12, "flags": 4}, + {"matrix": [4, 6], "x": 72, "y": 12, "flags": 4}, + {"matrix": [4, 7], "x": 84, "y": 12, "flags": 4}, + {"matrix": [4, 8], "x": 96, "y": 12, "flags": 4}, + {"matrix": [4, 9], "x": 108, "y": 12, "flags": 4}, + {"matrix": [4, 10], "x": 120, "y": 12, "flags": 4}, + {"matrix": [4, 11], "x": 156, "y": 12, "flags": 4}, + {"matrix": [4, 15], "x": 180, "y": 12, "flags": 4}, + + {"matrix": [5, 16], "x": 192, "y": 0, "flags": 4}, + {"matrix": [5, 15], "x": 180, "y": 0, "flags": 4}, + {"matrix": [5, 14], "x": 168, "y": 0, "flags": 4}, + {"matrix": [5, 12], "x": 156, "y": 0, "flags": 4}, + {"matrix": [5, 11], "x": 144, "y": 0, "flags": 4}, + {"matrix": [5, 10], "x": 132, "y": 0, "flags": 4}, + {"matrix": [5, 9], "x": 120, "y": 0, "flags": 4}, + {"x": 84, "y": 0, "flags": 4}, + {"x": 72, "y": 0, "flags": 4}, + {"matrix": [5, 5], "x": 60, "y": 0, "flags": 4}, + {"x": 48, "y": 0, "flags": 4}, + {"x": 36, "y": 0, "flags": 4}, + {"matrix": [5, 2], "x": 24, "y": 0, "flags": 4}, + {"matrix": [5, 1], "x": 12, "y": 0, "flags": 4}, + {"matrix": [5, 0], "x": 0, "y": 0, "flags": 4}, + + {"x": 16, "y": 64, "flags": 2}, + {"x": 37, "y": 64, "flags": 2}, + {"x": 58, "y": 64, "flags": 2}, + {"x": 80, "y": 64, "flags": 2}, + {"x": 101, "y": 64, "flags": 2}, + {"x": 123, "y": 64, "flags": 2}, + {"x": 144, "y": 64, "flags": 2}, + {"x": 165, "y": 64, "flags": 2}, + {"x": 187, "y": 64, "flags": 2}, + {"x": 208, "y": 64, "flags": 2}, + {"x": 224, "y": 56, "flags": 2}, + {"x": 224, "y": 46, "flags": 2}, + {"x": 224, "y": 36, "flags": 2}, + {"x": 224, "y": 27, "flags": 2}, + {"x": 224, "y": 17, "flags": 2}, + {"x": 224, "y": 8, "flags": 2}, + {"x": 208, "y": 0, "flags": 2}, + {"x": 187, "y": 0, "flags": 2}, + {"x": 165, "y": 0, "flags": 2}, + {"x": 144, "y": 0, "flags": 2}, + {"x": 123, "y": 0, "flags": 2}, + {"x": 101, "y": 0, "flags": 2}, + {"x": 80, "y": 0, "flags": 2}, + {"x": 58, "y": 0, "flags": 2}, + {"x": 37, "y": 0, "flags": 2}, + {"x": 16, "y": 0, "flags": 2}, + {"x": 0, "y": 8, "flags": 2}, + {"x": 0, "y": 17, "flags": 2}, + {"x": 0, "y": 27, "flags": 2}, + {"x": 0, "y": 36, "flags": 2}, + {"x": 0, "y": 46, "flags": 2}, + {"x": 0, "y": 56, "flags": 2} + ], + "max_brightness": 170 + }, + "url": "https://m.tb.cn/h.81WiQXl29FMSp3b", + "usb": { + "device_version": "1.0.0", + "pid": "0x0226", + "vid": "0x0715" + }, + "ws2812": { + "pin": "A0" + }, + "community_layouts": ["tkl_ansi"], + "layouts": { + "LAYOUT_tkl_ansi": { + "layout": [ + {"matrix": [0, 0], "x": 0, "y": 0}, + {"matrix": [0, 2], "x": 2, "y": 0}, + {"matrix": [0, 3], "x": 3, "y": 0}, + {"matrix": [0, 4], "x": 4, "y": 0}, + {"matrix": [0, 5], "x": 5, "y": 0}, + {"matrix": [0, 6], "x": 6.5, "y": 0}, + {"matrix": [0, 7], "x": 7.5, "y": 0}, + {"matrix": [0, 8], "x": 8.5, "y": 0}, + {"matrix": [0, 9], "x": 9.5, "y": 0}, + {"matrix": [0, 10], "x": 11, "y": 0}, + {"matrix": [0, 11], "x": 12, "y": 0}, + {"matrix": [0, 12], "x": 13, "y": 0}, + {"matrix": [0, 13], "x": 14, "y": 0}, + {"matrix": [0, 14], "x": 15.25, "y": 0}, + {"matrix": [0, 15], "x": 16.25, "y": 0}, + {"matrix": [0, 16], "x": 17.25, "y": 0}, + + {"matrix": [1, 0], "x": 0, "y": 1.3}, + {"matrix": [1, 1], "x": 1, "y": 1.3}, + {"matrix": [1, 2], "x": 2, "y": 1.3}, + {"matrix": [1, 3], "x": 3, "y": 1.3}, + {"matrix": [1, 4], "x": 4, "y": 1.3}, + {"matrix": [1, 5], "x": 5, "y": 1.3}, + {"matrix": [1, 6], "x": 6, "y": 1.3}, + {"matrix": [1, 7], "x": 7, "y": 1.3}, + {"matrix": [1, 8], "x": 8, "y": 1.3}, + {"matrix": [1, 9], "x": 9, "y": 1.3}, + {"matrix": [1, 10], "x": 10, "y": 1.3}, + {"matrix": [1, 11], "x": 11, "y": 1.3}, + {"matrix": [1, 12], "x": 12, "y": 1.3}, + {"matrix": [1, 13], "x": 13, "y": 1.3, "w": 2}, + {"matrix": [1, 14], "x": 15.25, "y": 1.3}, + {"matrix": [1, 15], "x": 16.25, "y": 1.3}, + {"matrix": [1, 16], "x": 17.25, "y": 1.3}, + + {"matrix": [2, 0], "x": 0, "y": 2.6, "w": 1.5}, + {"matrix": [2, 1], "x": 1.5, "y": 2.6}, + {"matrix": [2, 2], "x": 2.5, "y": 2.6}, + {"matrix": [2, 3], "x": 3.5, "y": 2.6}, + {"matrix": [2, 4], "x": 4.5, "y": 2.6}, + {"matrix": [2, 5], "x": 5.5, "y": 2.6}, + {"matrix": [2, 6], "x": 6.5, "y": 2.6}, + {"matrix": [2, 7], "x": 7.5, "y": 2.6}, + {"matrix": [2, 8], "x": 8.5, "y": 2.6}, + {"matrix": [2, 9], "x": 9.5, "y": 2.6}, + {"matrix": [2, 10], "x": 10.5, "y": 2.6}, + {"matrix": [2, 11], "x": 11.5, "y": 2.6}, + {"matrix": [2, 12], "x": 12.5, "y": 2.6}, + {"matrix": [2, 13], "x": 13.5, "y": 2.6, "w": 1.5}, + {"matrix": [2, 14], "x": 15.25, "y": 2.6}, + {"matrix": [2, 15], "x": 16.25, "y": 2.6}, + {"matrix": [2, 16], "x": 17.25, "y": 2.6}, + + {"matrix": [3, 0], "x": 0, "y": 3.9, "w": 1.75}, + {"matrix": [3, 1], "x": 1.75, "y": 3.9}, + {"matrix": [3, 2], "x": 2.75, "y": 3.9}, + {"matrix": [3, 3], "x": 3.75, "y": 3.9}, + {"matrix": [3, 4], "x": 4.75, "y": 3.9}, + {"matrix": [3, 5], "x": 5.75, "y": 3.9}, + {"matrix": [3, 6], "x": 6.75, "y": 3.9}, + {"matrix": [3, 7], "x": 7.75, "y": 3.9}, + {"matrix": [3, 8], "x": 8.75, "y": 3.9}, + {"matrix": [3, 9], "x": 9.75, "y": 3.9}, + {"matrix": [3, 10], "x": 10.75, "y": 3.9}, + {"matrix": [3, 11], "x": 11.75, "y": 3.9}, + {"matrix": [3, 12], "x": 12.75, "y": 3.9, "w": 2.25}, + + {"matrix": [4, 0], "x": 0, "y": 5.2, "w": 2.25}, + {"matrix": [4, 1], "x": 2.25, "y": 5.2}, + {"matrix": [4, 2], "x": 3.25, "y": 5.2}, + {"matrix": [4, 3], "x": 4.25, "y": 5.2}, + {"matrix": [4, 4], "x": 5.25, "y": 5.2}, + {"matrix": [4, 5], "x": 6.25, "y": 5.2}, + {"matrix": [4, 6], "x": 7.25, "y": 5.2}, + {"matrix": [4, 7], "x": 8.25, "y": 5.2}, + {"matrix": [4, 8], "x": 9.25, "y": 5.2}, + {"matrix": [4, 9], "x": 10.25, "y": 5.2}, + {"matrix": [4, 10], "x": 11.25, "y": 5.2}, + {"matrix": [4, 11], "x": 12.25, "y": 5.2, "w": 2.75}, + {"matrix": [4, 15], "x": 16.25, "y": 5.2}, + + {"matrix": [5, 0], "x": 0, "y": 6.5, "w": 1.25}, + {"matrix": [5, 1], "x": 1.25, "y": 6.5, "w": 1.25}, + {"matrix": [5, 2], "x": 2.5, "y": 6.5, "w": 1.25}, + {"matrix": [5, 5], "x": 3.75, "y": 6.5, "w": 6.25}, + {"matrix": [5, 9], "x": 10, "y": 6.5, "w": 1.25}, + {"matrix": [5, 10], "x": 11.25, "y": 6.5, "w": 1.25}, + {"matrix": [5, 11], "x": 12.5, "y": 6.5, "w": 1.25}, + {"matrix": [5, 12], "x": 13.75, "y": 6.5, "w": 1.25}, + {"matrix": [5, 14], "x": 15.25, "y": 6.5}, + {"matrix": [5, 15], "x": 16.25, "y": 6.5}, + {"matrix": [5, 16], "x": 17.25, "y": 6.5} + ] + } + } +} diff --git a/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c b/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c new file mode 100644 index 000000000000..9dd480c9d384 --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +enum layers { + _BASE, + _FN, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT_tkl_ansi( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SCRL, KC_PAUS, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + [_FN] = LAYOUT_tkl_ansi( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALD, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RM_HUED, RM_HUEU, RM_SATD, RM_SATU, RM_PREV, RM_NEXT, RM_SPDD, RM_SPDU, KC_TRNS, RM_TOGG, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ) +}; diff --git a/keyboards/xl_keyboards/xl_87_rgb/ld/STM32F103xB_uf2boot_wl.ld b/keyboards/xl_keyboards/xl_87_rgb/ld/STM32F103xB_uf2boot_wl.ld new file mode 100644 index 000000000000..11c5597529b1 --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/ld/STM32F103xB_uf2boot_wl.ld @@ -0,0 +1,62 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + * STM32F103xB memory setup for a 16 kB uf2boot bootloader and a 2 kB + * embedded-flash wear-leveling backing store at the top of 128 kB flash. + */ +MEMORY +{ + flash0 (rx) : org = 0x08000000 + 16K, len = 128k - 16K - 2K + flash1 (rx) : org = 0x00000000, len = 0 + flash2 (rx) : org = 0x00000000, len = 0 + flash3 (rx) : org = 0x00000000, len = 0 + flash4 (rx) : org = 0x00000000, len = 0 + flash5 (rx) : org = 0x00000000, len = 0 + flash6 (rx) : org = 0x00000000, len = 0 + flash7 (rx) : org = 0x00000000, len = 0 + ram0 (wx) : org = 0x20000000, len = 20k + ram1 (wx) : org = 0x00000000, len = 0 + ram2 (wx) : org = 0x00000000, len = 0 + ram3 (wx) : org = 0x00000000, len = 0 + ram4 (wx) : org = 0x00000000, len = 0 + ram5 (wx) : org = 0x00000000, len = 0 + ram6 (wx) : org = 0x00000000, len = 0 + ram7 (wx) : org = 0x00000000, len = 0 +} + +REGION_ALIAS("VECTORS_FLASH", flash0); +REGION_ALIAS("VECTORS_FLASH_LMA", flash0); +REGION_ALIAS("XTORS_FLASH", flash0); +REGION_ALIAS("XTORS_FLASH_LMA", flash0); +REGION_ALIAS("TEXT_FLASH", flash0); +REGION_ALIAS("TEXT_FLASH_LMA", flash0); +REGION_ALIAS("RODATA_FLASH", flash0); +REGION_ALIAS("RODATA_FLASH_LMA", flash0); +REGION_ALIAS("VARIOUS_FLASH", flash0); +REGION_ALIAS("VARIOUS_FLASH_LMA", flash0); +REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0); +REGION_ALIAS("MAIN_STACK_RAM", ram0); +REGION_ALIAS("PROCESS_STACK_RAM", ram0); +REGION_ALIAS("DATA_RAM", ram0); +REGION_ALIAS("DATA_RAM_LMA", flash0); +REGION_ALIAS("BSS_RAM", ram0); +REGION_ALIAS("HEAP_RAM", ram0); + +INCLUDE rules.ld + +/* This is based on the code within uf2-stm32f103's backup.c. */ +_board_magic_reg = ORIGIN(ram0) + 16k; diff --git a/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h b/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h new file mode 100644 index 000000000000..8be30f05beb9 --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef STM32_PLLXTPRE +#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV2 diff --git a/keyboards/xl_keyboards/xl_87_rgb/readme.md b/keyboards/xl_keyboards/xl_87_rgb/readme.md new file mode 100644 index 000000000000..b38e48976089 --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/readme.md @@ -0,0 +1,26 @@ +# XL Keyboards XL 87 RGB + +An 87-key keyboard using an APM32F103CBT6 MCU through the STM32F103-compatible +QMK platform, with a 16 MHz external crystal, the uf2boot bootloader, and 123 +WS2812 RGB LEDs: 91 on the top side and 32 on the underside. + +* Keyboard Maintainer: [Hiiwwy](https://github.com/Hiiwwy) +* Hardware Supported: XL Keyboards XL 87 RGB +* Hardware Availability: [XL 87 RGB](https://m.tb.cn/h.81WiQXl29FMSp3b) + +Make example for this keyboard (after setting up your build environment): + + make xl_keyboards/xl_87_rgb:default + +Flashing example for this keyboard: + + make xl_keyboards/xl_87_rgb:default:flash + +This keyboard uses the uf2boot bootloader. Enter it by double-tapping the +reset button, by pressing a key mapped to `QK_BOOT`, or by holding the key at +matrix position `0,0` while plugging in the keyboard. Copy the generated UF2 +file to the USB mass-storage device presented by the bootloader. + +See the [build environment setup](https://docs.qmk.fm/#/newbs_getting_started) +and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) +for more information. diff --git a/keyboards/xl_keyboards/xl_87_rgb/rules.mk b/keyboards/xl_keyboards/xl_87_rgb/rules.mk new file mode 100644 index 000000000000..243e039d8dbf --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/rules.mk @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Reserve the final two 1 kB flash pages for the embedded-flash wear-leveling +# backing store. The application is placed after the 16 kB uf2boot bootloader. +MCU_LDSCRIPT = STM32F103xB_uf2boot_wl + +EEPROM_DRIVER = wear_leveling +WEAR_LEVELING_DRIVER = embedded_flash diff --git a/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c b/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c new file mode 100644 index 000000000000..cdcee537bbcd --- /dev/null +++ b/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c @@ -0,0 +1,157 @@ +// Copyright 2026 Hiiwwy +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "quantum.h" +#include "eeconfig.h" + +#ifdef VIA_ENABLE +# include "via.h" +#endif + +enum xl_87_rgb_led_index { + XL_87_RGB_SCROLL_LOCK_LED = 14, + XL_87_RGB_CAPS_LOCK_LED = 62, +}; + +// The high 24 bits identify this keyboard's configuration; bit 0 stores the +// ordinary-lighting state. +#define XL_87_RGB_CONFIG_MAGIC 0x584C8700UL +#define XL_87_RGB_CONFIG_MAGIC_MASK 0xFFFFFF00UL +#define XL_87_RGB_LIGHTING_ENABLED_BIT (1UL << 0) + +static uint32_t xl_87_rgb_config; + +static bool xl_87_rgb_lighting_is_enabled(void) { + return (xl_87_rgb_config & XL_87_RGB_LIGHTING_ENABLED_BIT) != 0; +} + +static void xl_87_rgb_save_config(void) { + eeconfig_update_kb(xl_87_rgb_config); +} + +static void xl_87_rgb_set_lighting_enabled(bool enabled) { + if (enabled) { + xl_87_rgb_config |= XL_87_RGB_LIGHTING_ENABLED_BIT; + } else { + xl_87_rgb_config &= ~XL_87_RGB_LIGHTING_ENABLED_BIT; + } + + // Keep RGB Matrix rendering active so lock indicators can still be drawn. + rgb_matrix_enable_noeeprom(); +} + +static void xl_87_rgb_set_default_config(void) { + xl_87_rgb_config = XL_87_RGB_CONFIG_MAGIC | XL_87_RGB_LIGHTING_ENABLED_BIT; +} + +void eeconfig_init_kb(void) { + xl_87_rgb_set_default_config(); + xl_87_rgb_save_config(); + + eeconfig_init_user(); +} + +void keyboard_post_init_kb(void) { + xl_87_rgb_config = eeconfig_read_kb(); + + if ((xl_87_rgb_config & XL_87_RGB_CONFIG_MAGIC_MASK) != XL_87_RGB_CONFIG_MAGIC) { + xl_87_rgb_set_default_config(); + xl_87_rgb_save_config(); + } + + // A previously stored RGB Matrix off-state must not stop the indicators. + rgb_matrix_enable_noeeprom(); + + keyboard_post_init_user(); +} + +bool rgb_matrix_indicators_kb(void) { + if (!rgb_matrix_indicators_user()) { + return false; + } + + led_t led_state = host_keyboard_led_state(); + + // This runs after the regular effect, so it first clears ordinary lighting + // when requested and then restores active lock indicators. + if (!xl_87_rgb_lighting_is_enabled()) { + rgb_matrix_set_color_all(RGB_OFF); + } + + if (led_state.caps_lock) { + rgb_matrix_set_color(XL_87_RGB_CAPS_LOCK_LED, RGB_WHITE); + } + + if (led_state.scroll_lock) { + rgb_matrix_set_color(XL_87_RGB_SCROLL_LOCK_LED, RGB_WHITE); + } + + return true; +} + +// Do not allow RM_TOGG to stop RGB Matrix itself: it only controls ordinary +// lighting, leaving the lock indicators available. +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + if (!process_record_user(keycode, record)) { + return false; + } + + if (keycode == RM_TOGG) { + if (record->event.pressed) { + xl_87_rgb_set_lighting_enabled(!xl_87_rgb_lighting_is_enabled()); + xl_87_rgb_save_config(); + } + + return false; + } + + return true; +} + +#ifdef VIA_ENABLE + +enum xl_87_rgb_via_value { + id_xl_87_rgb_lighting_enabled = 1, +}; + +void via_custom_value_command_kb(uint8_t *data, uint8_t length) { + // data = [command_id, channel_id, value_id, value_data] + uint8_t *command_id = &data[0]; + uint8_t *channel_id = &data[1]; + uint8_t *value_id = &data[2]; + uint8_t *value_data = &data[3]; + + (void)length; + + if (*channel_id != id_custom_channel) { + *command_id = id_unhandled; + return; + } + + switch (*command_id) { + case id_custom_set_value: + if (*value_id == id_xl_87_rgb_lighting_enabled) { + xl_87_rgb_set_lighting_enabled(*value_data != 0); + return; + } + break; + + case id_custom_get_value: + if (*value_id == id_xl_87_rgb_lighting_enabled) { + *value_data = xl_87_rgb_lighting_is_enabled(); + return; + } + break; + + case id_custom_save: + xl_87_rgb_save_config(); + return; + + default: + break; + } + + *command_id = id_unhandled; +} + +#endif From 1b14c32eac3f650248835fab26ed09b764d6c0d5 Mon Sep 17 00:00:00 2001 From: Hiiwwy Date: Wed, 15 Jul 2026 20:50:55 +0800 Subject: [PATCH 2/4] Add independent RGB lighting controls --- keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c | 72 ++++++++++++++------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c b/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c index cdcee537bbcd..a818dcc83783 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c +++ b/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c @@ -13,27 +13,29 @@ enum xl_87_rgb_led_index { XL_87_RGB_CAPS_LOCK_LED = 62, }; -// The high 24 bits identify this keyboard's configuration; bit 0 stores the -// ordinary-lighting state. -#define XL_87_RGB_CONFIG_MAGIC 0x584C8700UL -#define XL_87_RGB_CONFIG_MAGIC_MASK 0xFFFFFF00UL -#define XL_87_RGB_LIGHTING_ENABLED_BIT (1UL << 0) +// The high 24 bits identify this keyboard's configuration. The low two bits +// store the ordinary-lighting state for the keylight and underglow groups. +#define XL_87_RGB_LEGACY_CONFIG_MAGIC 0x584C8700UL +#define XL_87_RGB_CONFIG_MAGIC 0x584C8800UL +#define XL_87_RGB_CONFIG_MAGIC_MASK 0xFFFFFF00UL +#define XL_87_RGB_KEYLIGHT_ENABLED_BIT (1UL << 0) +#define XL_87_RGB_UNDERGLOW_ENABLED_BIT (1UL << 1) static uint32_t xl_87_rgb_config; -static bool xl_87_rgb_lighting_is_enabled(void) { - return (xl_87_rgb_config & XL_87_RGB_LIGHTING_ENABLED_BIT) != 0; +static bool xl_87_rgb_lighting_is_enabled(uint32_t enabled_bit) { + return (xl_87_rgb_config & enabled_bit) != 0; } static void xl_87_rgb_save_config(void) { eeconfig_update_kb(xl_87_rgb_config); } -static void xl_87_rgb_set_lighting_enabled(bool enabled) { +static void xl_87_rgb_set_lighting_enabled(uint32_t enabled_bit, bool enabled) { if (enabled) { - xl_87_rgb_config |= XL_87_RGB_LIGHTING_ENABLED_BIT; + xl_87_rgb_config |= enabled_bit; } else { - xl_87_rgb_config &= ~XL_87_RGB_LIGHTING_ENABLED_BIT; + xl_87_rgb_config &= ~enabled_bit; } // Keep RGB Matrix rendering active so lock indicators can still be drawn. @@ -41,7 +43,7 @@ static void xl_87_rgb_set_lighting_enabled(bool enabled) { } static void xl_87_rgb_set_default_config(void) { - xl_87_rgb_config = XL_87_RGB_CONFIG_MAGIC | XL_87_RGB_LIGHTING_ENABLED_BIT; + xl_87_rgb_config = XL_87_RGB_CONFIG_MAGIC | XL_87_RGB_KEYLIGHT_ENABLED_BIT | XL_87_RGB_UNDERGLOW_ENABLED_BIT; } void eeconfig_init_kb(void) { @@ -54,7 +56,14 @@ void eeconfig_init_kb(void) { void keyboard_post_init_kb(void) { xl_87_rgb_config = eeconfig_read_kb(); - if ((xl_87_rgb_config & XL_87_RGB_CONFIG_MAGIC_MASK) != XL_87_RGB_CONFIG_MAGIC) { + if ((xl_87_rgb_config & XL_87_RGB_CONFIG_MAGIC_MASK) == XL_87_RGB_LEGACY_CONFIG_MAGIC) { + bool lighting_was_enabled = xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT); + + xl_87_rgb_set_default_config(); + xl_87_rgb_set_lighting_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT, lighting_was_enabled); + xl_87_rgb_set_lighting_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT, lighting_was_enabled); + xl_87_rgb_save_config(); + } else if ((xl_87_rgb_config & XL_87_RGB_CONFIG_MAGIC_MASK) != XL_87_RGB_CONFIG_MAGIC) { xl_87_rgb_set_default_config(); xl_87_rgb_save_config(); } @@ -72,10 +81,15 @@ bool rgb_matrix_indicators_kb(void) { led_t led_state = host_keyboard_led_state(); - // This runs after the regular effect, so it first clears ordinary lighting - // when requested and then restores active lock indicators. - if (!xl_87_rgb_lighting_is_enabled()) { - rgb_matrix_set_color_all(RGB_OFF); + // This runs after the regular effect, so it can independently clear either + // ordinary-lighting group before restoring active lock indicators. + for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + led_flags_t flags = g_led_config.flags[i]; + + if ((!xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT) && HAS_FLAGS(flags, LED_FLAG_KEYLIGHT)) || + (!xl_87_rgb_lighting_is_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT) && HAS_FLAGS(flags, LED_FLAG_UNDERGLOW))) { + rgb_matrix_set_color(i, RGB_OFF); + } } if (led_state.caps_lock) { @@ -98,7 +112,10 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { if (keycode == RM_TOGG) { if (record->event.pressed) { - xl_87_rgb_set_lighting_enabled(!xl_87_rgb_lighting_is_enabled()); + bool ordinary_lighting_is_enabled = xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT) || xl_87_rgb_lighting_is_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT); + + xl_87_rgb_set_lighting_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT, !ordinary_lighting_is_enabled); + xl_87_rgb_set_lighting_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT, !ordinary_lighting_is_enabled); xl_87_rgb_save_config(); } @@ -111,7 +128,8 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { #ifdef VIA_ENABLE enum xl_87_rgb_via_value { - id_xl_87_rgb_lighting_enabled = 1, + id_xl_87_rgb_keylight_enabled = 1, + id_xl_87_rgb_underglow_enabled = 2, }; void via_custom_value_command_kb(uint8_t *data, uint8_t length) { @@ -130,15 +148,25 @@ void via_custom_value_command_kb(uint8_t *data, uint8_t length) { switch (*command_id) { case id_custom_set_value: - if (*value_id == id_xl_87_rgb_lighting_enabled) { - xl_87_rgb_set_lighting_enabled(*value_data != 0); + if (*value_id == id_xl_87_rgb_keylight_enabled) { + xl_87_rgb_set_lighting_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT, *value_data != 0); + return; + } + + if (*value_id == id_xl_87_rgb_underglow_enabled) { + xl_87_rgb_set_lighting_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT, *value_data != 0); return; } break; case id_custom_get_value: - if (*value_id == id_xl_87_rgb_lighting_enabled) { - *value_data = xl_87_rgb_lighting_is_enabled(); + if (*value_id == id_xl_87_rgb_keylight_enabled) { + *value_data = xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT); + return; + } + + if (*value_id == id_xl_87_rgb_underglow_enabled) { + *value_data = xl_87_rgb_lighting_is_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT); return; } break; From 45cf59d0ab6104dec09364410849af5d5dfde482 Mon Sep 17 00:00:00 2001 From: Hiiwwy Date: Wed, 15 Jul 2026 21:20:40 +0800 Subject: [PATCH 3/4] Address review feedback --- keyboards/xl_keyboards/xl_87_rgb/board.h | 1 + .../xl_87_rgb/keymaps/default/keymap.c | 3 +- keyboards/xl_keyboards/xl_87_rgb/mcuconf.h | 1 + keyboards/xl_keyboards/xl_87_rgb/readme.md | 17 +- keyboards/xl_keyboards/xl_87_rgb/rules.mk | 3 - keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c | 164 +----------------- 6 files changed, 15 insertions(+), 174 deletions(-) diff --git a/keyboards/xl_keyboards/xl_87_rgb/board.h b/keyboards/xl_keyboards/xl_87_rgb/board.h index 1cf412bb939e..2467ea79b27d 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/board.h +++ b/keyboards/xl_keyboards/xl_87_rgb/board.h @@ -1,3 +1,4 @@ +// Copyright 2026 Hiiwwy // SPDX-License-Identifier: GPL-2.0-or-later #pragma once diff --git a/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c b/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c index 9dd480c9d384..08fe7120c35c 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c +++ b/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c @@ -1,3 +1,4 @@ +// Copyright 2026 Hiiwwy // SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H @@ -18,7 +19,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [_FN] = LAYOUT_tkl_ansi( KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, + QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_HUED, RM_HUEU, RM_SATD, RM_SATU, RM_PREV, RM_NEXT, RM_SPDD, RM_SPDU, KC_TRNS, RM_TOGG, KC_TRNS, KC_TRNS, diff --git a/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h b/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h index 8be30f05beb9..17f0ff746109 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h +++ b/keyboards/xl_keyboards/xl_87_rgb/mcuconf.h @@ -1,3 +1,4 @@ +// Copyright 2026 Hiiwwy // SPDX-License-Identifier: GPL-2.0-or-later #pragma once diff --git a/keyboards/xl_keyboards/xl_87_rgb/readme.md b/keyboards/xl_keyboards/xl_87_rgb/readme.md index b38e48976089..a25d3a3bf6b1 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/readme.md +++ b/keyboards/xl_keyboards/xl_87_rgb/readme.md @@ -16,11 +16,12 @@ Flashing example for this keyboard: make xl_keyboards/xl_87_rgb:default:flash -This keyboard uses the uf2boot bootloader. Enter it by double-tapping the -reset button, by pressing a key mapped to `QK_BOOT`, or by holding the key at -matrix position `0,0` while plugging in the keyboard. Copy the generated UF2 -file to the USB mass-storage device presented by the bootloader. - -See the [build environment setup](https://docs.qmk.fm/#/newbs_getting_started) -and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) -for more information. +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader in one of the following ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard +* **Physical reset button**: Double-tap the reset button on the PCB +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available diff --git a/keyboards/xl_keyboards/xl_87_rgb/rules.mk b/keyboards/xl_keyboards/xl_87_rgb/rules.mk index 243e039d8dbf..495a05d3d9f0 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/rules.mk +++ b/keyboards/xl_keyboards/xl_87_rgb/rules.mk @@ -3,6 +3,3 @@ # Reserve the final two 1 kB flash pages for the embedded-flash wear-leveling # backing store. The application is placed after the 16 kB uf2boot bootloader. MCU_LDSCRIPT = STM32F103xB_uf2boot_wl - -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = embedded_flash diff --git a/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c b/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c index a818dcc83783..6160ed40c009 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c +++ b/keyboards/xl_keyboards/xl_87_rgb/xl_87_rgb.c @@ -2,77 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "quantum.h" -#include "eeconfig.h" -#ifdef VIA_ENABLE -# include "via.h" -#endif - -enum xl_87_rgb_led_index { - XL_87_RGB_SCROLL_LOCK_LED = 14, - XL_87_RGB_CAPS_LOCK_LED = 62, -}; - -// The high 24 bits identify this keyboard's configuration. The low two bits -// store the ordinary-lighting state for the keylight and underglow groups. -#define XL_87_RGB_LEGACY_CONFIG_MAGIC 0x584C8700UL -#define XL_87_RGB_CONFIG_MAGIC 0x584C8800UL -#define XL_87_RGB_CONFIG_MAGIC_MASK 0xFFFFFF00UL -#define XL_87_RGB_KEYLIGHT_ENABLED_BIT (1UL << 0) -#define XL_87_RGB_UNDERGLOW_ENABLED_BIT (1UL << 1) - -static uint32_t xl_87_rgb_config; - -static bool xl_87_rgb_lighting_is_enabled(uint32_t enabled_bit) { - return (xl_87_rgb_config & enabled_bit) != 0; -} - -static void xl_87_rgb_save_config(void) { - eeconfig_update_kb(xl_87_rgb_config); -} - -static void xl_87_rgb_set_lighting_enabled(uint32_t enabled_bit, bool enabled) { - if (enabled) { - xl_87_rgb_config |= enabled_bit; - } else { - xl_87_rgb_config &= ~enabled_bit; - } - - // Keep RGB Matrix rendering active so lock indicators can still be drawn. - rgb_matrix_enable_noeeprom(); -} - -static void xl_87_rgb_set_default_config(void) { - xl_87_rgb_config = XL_87_RGB_CONFIG_MAGIC | XL_87_RGB_KEYLIGHT_ENABLED_BIT | XL_87_RGB_UNDERGLOW_ENABLED_BIT; -} - -void eeconfig_init_kb(void) { - xl_87_rgb_set_default_config(); - xl_87_rgb_save_config(); - - eeconfig_init_user(); -} - -void keyboard_post_init_kb(void) { - xl_87_rgb_config = eeconfig_read_kb(); - - if ((xl_87_rgb_config & XL_87_RGB_CONFIG_MAGIC_MASK) == XL_87_RGB_LEGACY_CONFIG_MAGIC) { - bool lighting_was_enabled = xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT); - - xl_87_rgb_set_default_config(); - xl_87_rgb_set_lighting_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT, lighting_was_enabled); - xl_87_rgb_set_lighting_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT, lighting_was_enabled); - xl_87_rgb_save_config(); - } else if ((xl_87_rgb_config & XL_87_RGB_CONFIG_MAGIC_MASK) != XL_87_RGB_CONFIG_MAGIC) { - xl_87_rgb_set_default_config(); - xl_87_rgb_save_config(); - } - - // A previously stored RGB Matrix off-state must not stop the indicators. - rgb_matrix_enable_noeeprom(); - - keyboard_post_init_user(); -} +#define XL_87_RGB_SCROLL_LOCK_LED 14 +#define XL_87_RGB_CAPS_LOCK_LED 62 bool rgb_matrix_indicators_kb(void) { if (!rgb_matrix_indicators_user()) { @@ -81,17 +13,6 @@ bool rgb_matrix_indicators_kb(void) { led_t led_state = host_keyboard_led_state(); - // This runs after the regular effect, so it can independently clear either - // ordinary-lighting group before restoring active lock indicators. - for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { - led_flags_t flags = g_led_config.flags[i]; - - if ((!xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT) && HAS_FLAGS(flags, LED_FLAG_KEYLIGHT)) || - (!xl_87_rgb_lighting_is_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT) && HAS_FLAGS(flags, LED_FLAG_UNDERGLOW))) { - rgb_matrix_set_color(i, RGB_OFF); - } - } - if (led_state.caps_lock) { rgb_matrix_set_color(XL_87_RGB_CAPS_LOCK_LED, RGB_WHITE); } @@ -102,84 +23,3 @@ bool rgb_matrix_indicators_kb(void) { return true; } - -// Do not allow RM_TOGG to stop RGB Matrix itself: it only controls ordinary -// lighting, leaving the lock indicators available. -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - if (!process_record_user(keycode, record)) { - return false; - } - - if (keycode == RM_TOGG) { - if (record->event.pressed) { - bool ordinary_lighting_is_enabled = xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT) || xl_87_rgb_lighting_is_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT); - - xl_87_rgb_set_lighting_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT, !ordinary_lighting_is_enabled); - xl_87_rgb_set_lighting_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT, !ordinary_lighting_is_enabled); - xl_87_rgb_save_config(); - } - - return false; - } - - return true; -} - -#ifdef VIA_ENABLE - -enum xl_87_rgb_via_value { - id_xl_87_rgb_keylight_enabled = 1, - id_xl_87_rgb_underglow_enabled = 2, -}; - -void via_custom_value_command_kb(uint8_t *data, uint8_t length) { - // data = [command_id, channel_id, value_id, value_data] - uint8_t *command_id = &data[0]; - uint8_t *channel_id = &data[1]; - uint8_t *value_id = &data[2]; - uint8_t *value_data = &data[3]; - - (void)length; - - if (*channel_id != id_custom_channel) { - *command_id = id_unhandled; - return; - } - - switch (*command_id) { - case id_custom_set_value: - if (*value_id == id_xl_87_rgb_keylight_enabled) { - xl_87_rgb_set_lighting_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT, *value_data != 0); - return; - } - - if (*value_id == id_xl_87_rgb_underglow_enabled) { - xl_87_rgb_set_lighting_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT, *value_data != 0); - return; - } - break; - - case id_custom_get_value: - if (*value_id == id_xl_87_rgb_keylight_enabled) { - *value_data = xl_87_rgb_lighting_is_enabled(XL_87_RGB_KEYLIGHT_ENABLED_BIT); - return; - } - - if (*value_id == id_xl_87_rgb_underglow_enabled) { - *value_data = xl_87_rgb_lighting_is_enabled(XL_87_RGB_UNDERGLOW_ENABLED_BIT); - return; - } - break; - - case id_custom_save: - xl_87_rgb_save_config(); - return; - - default: - break; - } - - *command_id = id_unhandled; -} - -#endif From b9032bcee38b97fc76b072b98b4f248946c83ddd Mon Sep 17 00:00:00 2001 From: Hiiwwy Date: Thu, 16 Jul 2026 12:25:26 +0800 Subject: [PATCH 4/4] Update USB VID and boot key position --- keyboards/xl_keyboards/xl_87_rgb/keyboard.json | 2 +- keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/keyboards/xl_keyboards/xl_87_rgb/keyboard.json b/keyboards/xl_keyboards/xl_87_rgb/keyboard.json index e4e5df00575f..106efb621557 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/keyboard.json +++ b/keyboards/xl_keyboards/xl_87_rgb/keyboard.json @@ -194,7 +194,7 @@ "usb": { "device_version": "1.0.0", "pid": "0x0226", - "vid": "0x0715" + "vid": "0x584C" }, "ws2812": { "pin": "A0" diff --git a/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c b/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c index 08fe7120c35c..c2cbac1b58a5 100644 --- a/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c +++ b/keyboards/xl_keyboards/xl_87_rgb/keymaps/default/keymap.c @@ -18,8 +18,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT ), [_FN] = LAYOUT_tkl_ansi( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, + QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_VALD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RM_HUED, RM_HUEU, RM_SATD, RM_SATU, RM_PREV, RM_NEXT, RM_SPDD, RM_SPDU, KC_TRNS, RM_TOGG, KC_TRNS, KC_TRNS,