Add per-key/mixed RGB to Keychron Q4

This commit is contained in:
lokher
2026-01-29 10:47:11 +08:00
parent a3045e836e
commit e0d30d404f
24 changed files with 1098 additions and 122 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,4 +17,4 @@
#pragma once
/* Enable CapsLock LED*/
#define CAPS_LOCK_LED_INDEX 28
#define CAPS_LOCK_INDEX 28

View File

@@ -0,0 +1,69 @@
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#include "keychron_common.h"
enum layers {
MAC_BASE,
WIN_BASE,
MAC_FN,
WIN_FN,
_FN2,
};
#define FN_WIN MO(MAC_FN)
#define FN_MAC MO(WIN_FN)
#define FN2 MO(_FN2)
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_ansi_61(
KC_ESC, 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_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_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_LCTL, KC_LOPTN, KC_LCMMD, KC_SPC, KC_RCMMD, FN_WIN, FN2, KC_RCTL),
[WIN_BASE] = LAYOUT_ansi_61(
KC_ESC, 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_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_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_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, FN_MAC, FN2, KC_RCTL),
[MAC_FN] = LAYOUT_ansi_61(
KC_GRV, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, UG_VALD, UG_VALU, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, UG_NEXT,
UG_TOGG, UG_NEXT, UG_VALU, UG_HUEU, UG_SATU, UG_SPDU, _______, _______, _______, _______, KC_INS, KC_PGUP, KC_HOME, _______,
_______, UG_PREV, UG_VALD, UG_HUED, UG_SATD, UG_SPDD, _______, _______, KC_UP, _______, KC_PGDN, KC_END, _______,
_______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RIGHT, KC_DEL, _______,
_______, _______, _______, _______, _______, _______, _______, _______),
[WIN_FN] = LAYOUT_ansi_61(
KC_GRV, KC_BRID, KC_BRIU, KC_TASK, KC_FILE, UG_VALD, UG_VALU, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, UG_NEXT,
UG_TOGG, UG_NEXT, UG_VALU, UG_HUEU, UG_SATU, UG_SPDU, _______, _______, KC_APP, KC_SCRL, KC_INS, KC_PGUP, KC_HOME, _______,
_______, UG_PREV, UG_VALD, UG_HUED, UG_SATD, UG_SPDD, _______, _______, KC_UP, KC_PSCR, KC_PGDN, KC_END, _______,
_______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RIGHT, KC_DEL, _______,
_______, _______, _______, _______, _______, _______, _______, _______),
[_FN2] = LAYOUT_ansi_61(
KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______,
UG_TOGG, UG_NEXT, UG_VALU, UG_HUEU, UG_SATU, UG_SPDU, _______, _______, _______, _______, _______, _______, _______, _______,
_______, UG_PREV, UG_VALD, UG_HUED, UG_SATD, UG_SPDD, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______)
};

View File

@@ -0,0 +1 @@
VIA_ENABLE = yes

View File

@@ -0,0 +1 @@
KEYCHRON_RGB_ENABLE = yes

View File

@@ -92,4 +92,25 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
{1, CB6_CA14, CB4_CA14, CB5_CA14},
};
// Default Color of Per Key RGB
#define DC_RED {HSV_RED}
#define DC_BLU {HSV_BLUE}
#define DC_YLW {HSV_YELLOW}
HSV default_per_key_led[RGB_MATRIX_LED_COUNT] = {
DC_RED, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_YLW,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_RED,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_YLW,
DC_YLW, DC_YLW, DC_YLW, DC_BLU, DC_YLW, DC_YLW, DC_YLW, DC_YLW
};
// Default mixed RGB region
uint8_t default_region[RGB_MATRIX_LED_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
#endif

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
{
"usb": {
"device_version": "2.0.0"
"device_version": "2.1.0"
}
}

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
#include "quantum.h"
#ifdef RGB_MATRIX_ENABLE
// clang-format off
const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
/* Refer to SNLED27351 manual for these locations
* driver
@@ -55,19 +55,19 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
{0, CB9_CA13, CB7_CA13, CB8_CA13},
{0, CB9_CA14, CB7_CA14, CB8_CA14},
{0, CB12_CA1, CB10_CA1, CB11_CA1},
{0, CB12_CA2, CB10_CA2, CB11_CA2},
{0, CB12_CA3, CB10_CA3, CB11_CA3},
{0, CB12_CA4, CB10_CA4, CB11_CA4},
{0, CB12_CA5, CB10_CA5, CB11_CA5},
{0, CB12_CA6, CB10_CA6, CB11_CA6},
{0, CB12_CA7, CB10_CA7, CB11_CA7},
{0, CB12_CA8, CB10_CA8, CB11_CA8},
{0, CB12_CA9, CB10_CA9, CB11_CA9},
{0, CB12_CA10, CB10_CA10, CB11_CA10},
{0, CB12_CA11, CB10_CA11, CB11_CA11},
{0, CB12_CA12, CB10_CA12, CB11_CA12},
{0, CB12_CA14, CB10_CA14, CB11_CA14},
{0, CB12_CA1, CB10_CA1, CB11_CA1},
{0, CB12_CA2, CB10_CA2, CB11_CA2},
{0, CB12_CA3, CB10_CA3, CB11_CA3},
{0, CB12_CA4, CB10_CA4, CB11_CA4},
{0, CB12_CA5, CB10_CA5, CB11_CA5},
{0, CB12_CA6, CB10_CA6, CB11_CA6},
{0, CB12_CA7, CB10_CA7, CB11_CA7},
{0, CB12_CA8, CB10_CA8, CB11_CA8},
{0, CB12_CA9, CB10_CA9, CB11_CA9},
{0, CB12_CA10, CB10_CA10, CB11_CA10},
{0, CB12_CA11, CB10_CA11, CB11_CA11},
{0, CB12_CA12, CB10_CA12, CB11_CA12},
{0, CB12_CA14, CB10_CA14, CB11_CA14},
{0, CB3_CA1, CB1_CA1, CB2_CA1},
{0, CB3_CA3, CB1_CA3, CB2_CA3},
@@ -84,12 +84,33 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
{0, CB3_CA15, CB1_CA15, CB2_CA15},
{0, CB3_CA16, CB1_CA16, CB2_CA16},
{0, CB12_CA15, CB10_CA15, CB11_CA15},
{0, CB12_CA16, CB10_CA16, CB11_CA16},
{0, CB12_CA15, CB10_CA15, CB11_CA15},
{0, CB12_CA16, CB10_CA16, CB11_CA16},
{0, CB9_CA15, CB7_CA15, CB8_CA15},
{0, CB9_CA16, CB7_CA16, CB8_CA16},
{0, CB6_CA15, CB4_CA15, CB5_CA15},
{0, CB6_CA16, CB4_CA16, CB5_CA16},
};
// Default Color of Per Key RGB
#define DC_RED {HSV_RED}
#define DC_BLU {HSV_BLUE}
#define DC_YLW {HSV_YELLOW}
HSV default_per_key_led[RGB_MATRIX_LED_COUNT] = {
DC_RED, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_YLW,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_RED,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_YLW,
DC_YLW, DC_YLW, DC_YLW, DC_BLU, DC_YLW, DC_YLW, DC_YLW, DC_YLW
};
// Default mixed RGB region
uint8_t default_region[RGB_MATRIX_LED_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
#endif

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,5 +16,25 @@
#pragma once
#define SNLED27351_CURRENT_TUNE \
{ 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60 }
#include "eeconfig_kb.h"
#ifdef RGB_MATRIX_ENABLE
/* Increase I2C speed to 1000 KHz */
# define I2C1_TIMINGR_PRESC 0U
# define I2C1_TIMINGR_SCLDEL 3U
# define I2C1_TIMINGR_SDADEL 0U
# define I2C1_TIMINGR_SCLH 15U
# define I2C1_TIMINGR_SCLL 51U
/* Set LED current */
# define SNLED27351_CURRENT_TUNE \
{ 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60, 0xCA, 0xCA, 0x60 }
#endif
#define CUSTOM_KEYCODES_ENABLE
/* Factory test keys */
#define FN_KEY_1 MO(2)
#define FN_KEY_2 MO(3)
#define FN_KEY_3 MO(4)
#define FN_BL_TRIG_KEY KC_END

View File

@@ -1,4 +1,4 @@
/* Copyright 2020 QMK
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,20 +1,12 @@
{
"manufacturer": "Keychron",
"keyboard_name": "Keychron Q4",
"maintainer": "lalalademaxiya1",
"url": "https://github.com/Keychron",
"maintainer": "Keychron",
"processor": "STM32L432",
"bootloader": "stm32-dfu",
"diode_direction": "ROW2COL",
"dip_switch": {
"enabled": true,
"matrix_grid": [ [4, 4] ]
},
"dynamic_keymap": {
"layer_count": 5
},
"eeprom": {
"wear_leveling": {
"backing_size": 4096
}
"usb": {
"vid": "0x3434"
},
"features": {
"bootmagic": true,
@@ -23,12 +15,32 @@
"nkro": true,
"rgb_matrix": true
},
"dip_switch": {
"enabled": true,
"matrix_grid": [ [4, 4] ]
},
"matrix_pins": {
"cols": ["C14", "C15", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "B0", "B1", "A8", "A9"],
"rows": ["B4", "B3", "A15", "A14", "A13"]
},
"processor": "STM32L432",
"diode_direction": "ROW2COL",
"build": {
"debounce_type": "custom"
},
"debounce": 50,
"eeprom": {
"wear_leveling": {
"driver": "embedded_flash",
"logical_size": 3072,
"backing_size": 6144
}
},
"dynamic_keymap": {
"layer_count": 5
},
"rgb_matrix": {
"driver": "snled27351",
"sleep": true,
"animations": {
"band_spiral_val": true,
"breathing": true,
@@ -51,12 +63,6 @@
"solid_splash": true,
"splash": true,
"typing_heatmap": true
},
"driver": "snled27351",
"sleep": true
},
"url": "https://github.com/Keychron",
"usb": {
"vid": "0x3434"
}
}
}
}

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,4 +20,4 @@
#define SNLED27351_I2C_ADDRESS_1 SNLED27351_I2C_ADDRESS_GND
/* Enable CapsLock LED*/
#define CAPS_LOCK_LED_INDEX 27
#define CAPS_LOCK_INDEX 27

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
#include "quantum.h"
#ifdef RGB_MATRIX_ENABLE
// clang-format off
const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
/* Refer to SNLED27351 manual for these locations
* driver
@@ -54,19 +54,19 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
{0, CB9_CA12, CB7_CA12, CB8_CA12},
{0, CB9_CA13, CB7_CA13, CB8_CA13},
{0, CB12_CA1, CB10_CA1, CB11_CA1},
{0, CB12_CA2, CB10_CA2, CB11_CA2},
{0, CB12_CA3, CB10_CA3, CB11_CA3},
{0, CB12_CA4, CB10_CA4, CB11_CA4},
{0, CB12_CA5, CB10_CA5, CB11_CA5},
{0, CB12_CA6, CB10_CA6, CB11_CA6},
{0, CB12_CA7, CB10_CA7, CB11_CA7},
{0, CB12_CA8, CB10_CA8, CB11_CA8},
{0, CB12_CA9, CB10_CA9, CB11_CA9},
{0, CB12_CA10, CB10_CA10, CB11_CA10},
{0, CB12_CA11, CB10_CA11, CB11_CA11},
{0, CB12_CA12, CB10_CA12, CB11_CA12},
{0, CB12_CA14, CB10_CA14, CB11_CA14},
{0, CB12_CA1, CB10_CA1, CB11_CA1},
{0, CB12_CA2, CB10_CA2, CB11_CA2},
{0, CB12_CA3, CB10_CA3, CB11_CA3},
{0, CB12_CA4, CB10_CA4, CB11_CA4},
{0, CB12_CA5, CB10_CA5, CB11_CA5},
{0, CB12_CA6, CB10_CA6, CB11_CA6},
{0, CB12_CA7, CB10_CA7, CB11_CA7},
{0, CB12_CA8, CB10_CA8, CB11_CA8},
{0, CB12_CA9, CB10_CA9, CB11_CA9},
{0, CB12_CA10, CB10_CA10, CB11_CA10},
{0, CB12_CA11, CB10_CA11, CB11_CA11},
{0, CB12_CA12, CB10_CA12, CB11_CA12},
{0, CB12_CA14, CB10_CA14, CB11_CA14},
{0, CB9_CA14, CB7_CA14, CB8_CA14},
{0, CB3_CA1, CB1_CA1, CB2_CA1},
@@ -85,12 +85,33 @@ const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
{0, CB3_CA15, CB1_CA15, CB2_CA15},
{0, CB3_CA16, CB1_CA16, CB2_CA16},
{0, CB12_CA15, CB10_CA15, CB11_CA15},
{0, CB12_CA16, CB10_CA16, CB11_CA16},
{0, CB12_CA15, CB10_CA15, CB11_CA15},
{0, CB12_CA16, CB10_CA16, CB11_CA16},
{0, CB9_CA15, CB7_CA15, CB8_CA15},
{0, CB9_CA16, CB7_CA16, CB8_CA16},
{0, CB6_CA15, CB4_CA15, CB5_CA15},
{0, CB6_CA16, CB4_CA16, CB5_CA16},
};
// Default Color of Per Key RGB
#define DC_RED {HSV_RED}
#define DC_BLU {HSV_BLUE}
#define DC_YLW {HSV_YELLOW}
HSV default_per_key_led[RGB_MATRIX_LED_COUNT] = {
DC_RED, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_YLW,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_RED,
DC_YLW, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_BLU, DC_YLW,
DC_YLW, DC_YLW, DC_YLW, DC_BLU, DC_YLW, DC_YLW, DC_YLW, DC_YLW
};
// Default mixed RGB region
uint8_t default_region[RGB_MATRIX_LED_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
#endif

View File

@@ -1,7 +1,7 @@
{
"usb": {
"pid": "0x0142",
"device_version": "1.0.0"
"device_version": "1.1.0"
},
"rgb_matrix": {
"layout": [

View File

@@ -0,0 +1,69 @@
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#include "keychron_common.h"
enum layers {
MAC_BASE,
WIN_BASE,
MAC_FN,
WIN_FN,
_FN2,
};
#define FN_WIN MO(MAC_FN)
#define FN_MAC MO(WIN_FN)
#define FN2 MO(_FN2)
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[MAC_BASE] = LAYOUT_iso_62(
KC_ESC, 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_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_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT,
KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
KC_LCTL, KC_LOPTN, KC_LCMMD, KC_SPC, KC_RCMMD, FN_WIN, FN2, KC_RCTL),
[WIN_BASE] = LAYOUT_iso_62(
KC_ESC, 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_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_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT,
KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, FN_MAC, FN2, KC_RCTL),
[MAC_FN] = LAYOUT_iso_62(
KC_GRV, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, UG_VALD, UG_VALU, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, UG_NEXT,
UG_TOGG, UG_NEXT, UG_VALU, UG_HUEU, UG_SATU, UG_SPDU, _______, _______, _______, _______, KC_INS, KC_PGUP, KC_HOME,
_______, UG_PREV, UG_VALD, UG_HUED, UG_SATD, UG_SPDD, _______, _______, KC_UP, _______, KC_PGDN, KC_END, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RIGHT, KC_DEL, _______,
_______, _______, _______, _______, _______, _______, _______, _______),
[WIN_FN] = LAYOUT_iso_62(
KC_GRV, KC_BRID, KC_BRIU, KC_TASK, KC_FILE, UG_VALD, UG_VALU, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, UG_NEXT,
UG_TOGG, UG_NEXT, UG_VALU, UG_HUEU, UG_SATU, UG_SPDU, _______, _______, KC_APP, KC_SCRL, KC_INS, KC_PGUP, KC_HOME,
_______, UG_PREV, UG_VALD, UG_HUED, UG_SATD, UG_SPDD, _______, _______, KC_UP, KC_PSCR, KC_PGDN, KC_END, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RIGHT, KC_DEL, _______,
_______, _______, _______, _______, _______, _______, _______, _______),
[_FN2] = LAYOUT_iso_62(
KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______,
UG_TOGG, UG_NEXT, UG_VALU, UG_HUEU, UG_SATU, UG_SPDU, _______, _______, _______, _______, _______, _______, _______,
_______, UG_PREV, UG_VALD, UG_HUED, UG_SATD, UG_SPDD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______)
};

View File

@@ -0,0 +1 @@
VIA_ENABLE = yes

View File

@@ -0,0 +1 @@
KEYCHRON_RGB_ENABLE = yes

View File

@@ -0,0 +1,39 @@
/* Copyright 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "keycodes.h"
enum custom_keycodes {
KC_LOPTN = QK_KB_2,
KC_ROPTN,
KC_LCMMD,
KC_RCMMD,
KC_MAC_SIRI,
KC_WIN_TASK_VIEW,
KC_WIN_FILE_EXPLORER,
KC_MAC_SCREEN_SHOT,
KC_WIN_CORTANA,
NEW_SAFE_RANGE,
};
#define KC_SIRI KC_MAC_SIRI
#define KC_TASK KC_WIN_TASK_VIEW
#define KC_FILE KC_WIN_FILE_EXPLORER
#define KC_SNAP KC_MAC_SCREEN_SHOT
#define KC_CTANA KC_WIN_CORTANA

View File

@@ -1,4 +1,4 @@
/* Copyright 2020 QMK
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,4 +1,4 @@
/* Copyright 2022 @ Keychron (https://www.keychron.com)
/* Copyright 2023 ~ 2025 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,60 +14,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "quantum.h"
#include "keychron.h"
#ifdef DIP_SWITCH_ENABLE
bool dip_switch_update_kb(uint8_t index, bool active) {
if (!dip_switch_update_user(index, active)) { return false;}
if (!dip_switch_update_user(index, active)) {
return false;
}
if (index == 0) {
default_layer_set(1UL << (active ? 1 : 0));
}
return true;
}
#endif // DIP_SWITCH_ENABLE
#if defined(RGB_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX)
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) { return false; }
switch (keycode) {
#ifdef RGB_MATRIX_ENABLE
case QK_RGB_MATRIX_TOGGLE:
if (record->event.pressed) {
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL: {
rgb_matrix_set_flags(LED_FLAG_NONE);
rgb_matrix_set_color_all(0, 0, 0);
} break;
default: {
rgb_matrix_set_flags(LED_FLAG_ALL);
} break;
}
}
if (!rgb_matrix_is_enabled()) {
rgb_matrix_set_flags(LED_FLAG_ALL);
rgb_matrix_enable();
}
return false;
#endif
}
return true;
}
bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
return false;
}
// RGB_MATRIX_INDICATOR_SET_COLOR(index, red, green, blue);
if (host_keyboard_led_state().caps_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_LED_INDEX, 255, 255, 255);
} else {
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_LED_INDEX, 0, 0, 0);
}
}
return true;
void keyboard_post_init_kb(void) {
keychron_common_init();
keyboard_post_init_user();
}
#endif // CAPS_LOCK_LED_INDEX

View File

@@ -4,7 +4,7 @@
A customizable 60% keyboard.
Q4 Version 1 uses only 2 ICs for CKLED2001 and Q4 Version 2 uses only one IC.
Q4 Version 1 uses only 2 LED driver and Q4 Version 2 uses only one.
* Keyboard Maintainer: [Keychron](https://github.com/keychron)
* Hardware Supported: Keychron Q4
@@ -12,15 +12,15 @@ Q4 Version 1 uses only 2 ICs for CKLED2001 and Q4 Version 2 uses only one IC.
Make example for this keyboard (after setting up your build environment):
make keychron/q4/ansi/v1:default
make keychron/q4/ansi/v2:default
make keychron/q4/iso:default
make keychron/q4/ansi/v1:keychron
make keychron/q4/ansi/v2:keychron
make keychron/q4/iso:keychron
Flashing example for this keyboard:
make keychron/q4/ansi/v1:default:flash
make keychron/q4/ansi/v2:default:flash
make keychron/q4/iso:default:flash
make keychron/q4/ansi/v1:keychron:flash
make keychron/q4/ansi/v2:keychron:flash
make keychron/q4/iso:keychron:flash
**Reset Key**: Hold down the key located at *K00*, commonly programmed as *Esc* while plugging in the keyboard.

View File

@@ -0,0 +1 @@
include keyboards/keychron/common/keychron_common.mk

View File

@@ -0,0 +1,372 @@
{
"name": "Keychron Q4 ANSI",
"vendorId": "0x3434",
"productId": "0x0140",
"matrix": {
"rows": 5,
"cols": 14
},
"customKeycodes": [
{
"name": "Mission Control",
"title": "Mission Control in macOS",
"shortName": "MCtrl"
},
{
"name": "Launch Pad",
"title": "Launch Pad in macOS",
"shortName": "LPad"
},
{
"name": "Left Option",
"title": "Left Option in macOS",
"shortName": "LOpt"
},
{
"name": "Right Option",
"title": "Right Option in macOS",
"shortName": "ROpt"
},
{
"name": "Left Cmd",
"title": "Left Command in macOS",
"shortName": "LCmd"
},
{
"name": "Right Cmd",
"title": "Right Command in macOS",
"shortName": "RCmd"
},
{
"name": "Siri",
"title": "Siri in macOS",
"shortName": "Siri"
},
{
"name": "Task View",
"title": "Task View in windows",
"shortName": "Task"
},
{
"name": "File Explorer",
"title": "File Explorer in windows",
"shortName": "File"
},
{
"name": "Screen Shot",
"title": "Screenshot in macOS",
"shortName": "SShot"
},
{
"name": "Cortana",
"title": "Cortana in windows",
"shortName": "Cortana"
}
],
"keycodes": [
"qmk_lighting"
],
"menus": [
{
"label": "Lighting",
"content": [
{
"label": "Backlight",
"content": [
{
"label": "Brightness",
"type": "range",
"options": [
0,
255
],
"content": [
"id_qmk_rgb_matrix_brightness",
3,
1
]
},
{
"label": "Effect",
"type": "dropdown",
"content": [
"id_qmk_rgb_matrix_effect",
3,
2
],
"options": [
[
"None",
0
],
[
"Solid Color",
1
],
[
"Breathing",
2
],
[
"Band Spiral Val",
3
],
[
"Cycle All",
4
],
[
"Cycle Left Right",
5
],
[
"Cycle Up Down",
6
],
[
"Rainbow Moving Chevron",
7
],
[
"Cycle Out In",
8
],
[
"Cycle Out In Dual",
9
],
[
"Cycle Pinwheel",
10
],
[
"Cycle Spiral",
11
],
[
"Dual Beacon",
12
],
[
"Rainbow Beacon",
13
],
[
"Jellybean Raindrops",
14
],
[
"Pixel Rain",
15
],
[
"Typing Heatmap",
16
],
[
"Digital Rain",
17
],
[
"Reactive Simple",
18
],
[
"Reactive Multiwide",
19
],
[
"Reactive Multinexus",
20
],
[
"Splash",
21
],
[
"Solid Splash",
22
],
[
"Per Key RGB",
23
],
[
"Mix RGB",
24
]
]
},
{
"showIf": "{id_qmk_rgb_matrix_effect} > 1 && {id_qmk_rgb_matrix_effect} < 23",
"label": "Effect Speed",
"type": "range",
"options": [
0,
255
],
"content": [
"id_qmk_rgb_matrix_effect_speed",
3,
3
]
},
{
"showIf": "({id_qmk_rgb_matrix_effect} >= 1 && {id_qmk_rgb_matrix_effect} <= 3) || ({id_qmk_rgb_matrix_effect} >= 18 && {id_qmk_rgb_matrix_effect} <= 20) || {id_qmk_rgb_matrix_effect} == 22",
"label": "Color",
"type": "color",
"content": [
"id_qmk_rgb_matrix_color",
3,
4
]
}
]
}
]
}
],
"layouts": {
"keymap": [
[
{
"y": 0.25,
"c": "#777777"
},
"0,0",
{
"c": "#cccccc"
},
"0,1",
"0,2",
"0,3",
"0,4",
"0,5",
"0,6",
"0,7",
"0,8",
"0,9",
"0,10",
"0,11",
"0,12",
{
"c": "#aaaaaa",
"w": 2
},
"0,13"
],
[
{
"w": 1.5
},
"1,0",
{
"c": "#cccccc"
},
"1,1",
"1,2",
"1,3",
"1,4",
"1,5",
"1,6",
"1,7",
"1,8",
"1,9",
"1,10",
"1,11",
"1,12",
{
"w": 1.5
},
"1,13"
],
[
{
"c": "#aaaaaa",
"w": 1.75
},
"2,0",
{
"c": "#cccccc"
},
"2,1",
"2,2",
"2,3",
"2,4",
"2,5",
"2,6",
"2,7",
"2,8",
"2,9",
"2,10",
"2,11",
{
"c": "#777777",
"w": 2.25
},
"2,13"
],
[
{
"c": "#aaaaaa",
"w": 2.25
},
"3,0",
{
"c": "#cccccc"
},
"3,2",
"3,3",
"3,4",
"3,5",
"3,6",
"3,7",
"3,8",
"3,9",
"3,10",
"3,11",
{
"c": "#aaaaaa",
"w": 2.75
},
"3,13"
],
[
{
"w": 1.25
},
"4,0",
{
"w": 1.25
},
"4,1",
{
"w": 1.25
},
"4,2",
{
"c": "#cccccc",
"w": 6.25
},
"4,6",
{
"c": "#aaaaaa",
"w": 1.25
},
"4,10",
{
"w": 1.25
},
"4,11",
{
"w": 1.25
},
"4,12",
{
"w": 1.25
},
"4,13"
]
]
}
}

View File

@@ -0,0 +1,372 @@
{
"name": "Keychron Q4 ISO",
"vendorId": "0x3434",
"productId": "0x0142",
"matrix": {
"rows": 5,
"cols": 14
},
"customKeycodes": [
{
"name": "Mission Control",
"title": "Mission Control in macOS",
"shortName": "MCtrl"
},
{
"name": "Launch Pad",
"title": "Launch Pad in macOS",
"shortName": "LPad"
},
{
"name": "Left Option",
"title": "Left Option in macOS",
"shortName": "LOpt"
},
{
"name": "Right Option",
"title": "Right Option in macOS",
"shortName": "ROpt"
},
{
"name": "Left Cmd",
"title": "Left Command in macOS",
"shortName": "LCmd"
},
{
"name": "Right Cmd",
"title": "Right Command in macOS",
"shortName": "RCmd"
},
{
"name": "Siri",
"title": "Siri in macOS",
"shortName": "Siri"
},
{
"name": "Task View",
"title": "Task View in windows",
"shortName": "Task"
},
{
"name": "File Explorer",
"title": "File Explorer in windows",
"shortName": "File"
},
{
"name": "Screen Shot",
"title": "Screenshot in macOS",
"shortName": "SShot"
},
{
"name": "Cortana",
"title": "Cortana in windows",
"shortName": "Cortana"
}
],
"keycodes": [
"qmk_lighting"
],
"menus": [
{
"label": "Lighting",
"content": [
{
"label": "Backlight",
"content": [
{
"label": "Brightness",
"type": "range",
"options": [
0,
255
],
"content": [
"id_qmk_rgb_matrix_brightness",
3,
1
]
},
{
"label": "Effect",
"type": "dropdown",
"content": [
"id_qmk_rgb_matrix_effect",
3,
2
],
"options": [
[
"None",
0
],
[
"Solid Color",
1
],
[
"Breathing",
2
],
[
"Band Spiral Val",
3
],
[
"Cycle All",
4
],
[
"Cycle Left Right",
5
],
[
"Cycle Up Down",
6
],
[
"Rainbow Moving Chevron",
7
],
[
"Cycle Out In",
8
],
[
"Cycle Out In Dual",
9
],
[
"Cycle Pinwheel",
10
],
[
"Cycle Spiral",
11
],
[
"Dual Beacon",
12
],
[
"Rainbow Beacon",
13
],
[
"Jellybean Raindrops",
14
],
[
"Pixel Rain",
15
],
[
"Typing Heatmap",
16
],
[
"Digital Rain",
17
],
[
"Reactive Simple",
18
],
[
"Reactive Multiwide",
19
],
[
"Reactive Multinexus",
20
],
[
"Splash",
21
],
[
"Solid Splash",
22
],
[
"Per Key RGB",
23
],
[
"Mix RGB",
24
]
]
},
{
"showIf": "{id_qmk_rgb_matrix_effect} > 1 && {id_qmk_rgb_matrix_effect} < 23",
"label": "Effect Speed",
"type": "range",
"options": [
0,
255
],
"content": [
"id_qmk_rgb_matrix_effect_speed",
3,
3
]
},
{
"showIf": "({id_qmk_rgb_matrix_effect} >= 1 && {id_qmk_rgb_matrix_effect} <= 3) || ({id_qmk_rgb_matrix_effect} >= 18 && {id_qmk_rgb_matrix_effect} <= 20) || {id_qmk_rgb_matrix_effect} == 22",
"label": "Color",
"type": "color",
"content": [
"id_qmk_rgb_matrix_color",
3,
4
]
}
]
}
]
}
],
"layouts": {
"keymap": [
[
{
"y": 0.25,
"c": "#777777"
},
"0,0",
{
"c": "#cccccc"
},
"0,1",
"0,2",
"0,3",
"0,4",
"0,5",
"0,6",
"0,7",
"0,8",
"0,9",
"0,10",
"0,11",
"0,12",
{
"c": "#aaaaaa",
"w": 2
},
"0,13"
],
[
{
"w": 1.5
},
"1,0",
{
"c": "#cccccc"
},
"1,1",
"1,2",
"1,3",
"1,4",
"1,5",
"1,6",
"1,7",
"1,8",
"1,9",
"1,10",
"1,11",
"1,12",
{
"x": 0.25,
"c": "#777777",
"w": 1.25,
"h": 2
},
"1,13"
],
[
{
"c": "#aaaaaa",
"w": 1.75
},
"2,0",
{
"c": "#cccccc"
},
"2,1",
"2,2",
"2,3",
"2,4",
"2,5",
"2,6",
"2,7",
"2,8",
"2,9",
"2,10",
"2,11",
"2,13"
],
[
{
"c": "#aaaaaa",
"w": 1.25
},
"3,0",
{
"c": "#cccccc"
},
"3,1",
"3,2",
"3,3",
"3,4",
"3,5",
"3,6",
"3,7",
"3,8",
"3,9",
"3,10",
"3,11",
{
"c": "#aaaaaa",
"w": 2.75
},
"3,13"
],
[
{
"w": 1.25
},
"4,0",
{
"w": 1.25
},
"4,1",
{
"w": 1.25
},
"4,2",
{
"c": "#cccccc",
"w": 6.25
},
"4,6",
{
"c": "#aaaaaa",
"w": 1.25
},
"4,10",
{
"w": 1.25
},
"4,11",
{
"w": 1.25
},
"4,12",
{
"w": 1.25
},
"4,13"
]
]
}
}