mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-25 01:47:10 +06:00
Update c1 pro and c2 pro
This commit is contained in:
parent
da49c5d43c
commit
159719cc29
|
@ -8,6 +8,20 @@
|
|||
"pid": "0x0510",
|
||||
"device_version": "1.0.1"
|
||||
},
|
||||
"features": {
|
||||
"bootmagic": true,
|
||||
"command": false,
|
||||
"console": false,
|
||||
"dip_switch": true,
|
||||
"encoder": false,
|
||||
"extrakey": true,
|
||||
"mousekey": true,
|
||||
"nkro": true,
|
||||
"rgb_matrix": true
|
||||
},
|
||||
"rgb_matrix": {
|
||||
"driver": "CKLED2001"
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["C14", "C15", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "B0", "B1", "A8", "A9", "A10", "H3"],
|
||||
"rows": ["B5", "B4", "B3", "A15", "A14", "A13"]
|
||||
|
|
|
@ -61,26 +61,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE)
|
||||
extern void rgb_matrix_update_pwm_buffers(void);
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
#if defined(RGB_MATRIX_ENABLE)
|
||||
if (!rgb_matrix_is_enabled()) {
|
||||
# if defined(CAPS_SYSTEM_LOCK_LED_INDEX)
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 0, 255, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 0, 0, 255);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 255, 255, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 255, 0, 0);
|
||||
}
|
||||
# endif // SYSTEM_LED_INDEX
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "keychron_common.h"
|
||||
#include "keychron_ft_common.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -26,40 +27,6 @@ enum layers{
|
|||
WIN_FN
|
||||
};
|
||||
|
||||
enum custom_keycodes {
|
||||
KC_LOPTN = QK_KB_2,
|
||||
KC_ROPTN,
|
||||
KC_LCMMD,
|
||||
KC_RCMMD,
|
||||
KC_SIRI,
|
||||
KC_TASK_VIEW,
|
||||
KC_FILE_EXPLORER,
|
||||
KC_SCREEN_SHOT,
|
||||
KC_CORTANA
|
||||
};
|
||||
|
||||
#define KC_TASK KC_TASK_VIEW
|
||||
#define KC_FLXP KC_FILE_EXPLORER
|
||||
#define KC_SNAP KC_SCREEN_SHOT
|
||||
#define KC_CRTA KC_CORTANA
|
||||
|
||||
typedef struct PACKED {
|
||||
uint8_t len;
|
||||
uint8_t keycode[3];
|
||||
} key_combination_t;
|
||||
|
||||
bool is_siri_active = false;
|
||||
uint32_t siri_timer = 0;
|
||||
// clang-format off
|
||||
key_combination_t key_comb_list[4] = {
|
||||
{2, {KC_LWIN, KC_TAB}},
|
||||
{2, {KC_LWIN, KC_E}},
|
||||
{3, {KC_LSFT, KC_LCMD, KC_4}},
|
||||
{2, {KC_LWIN, KC_C}}
|
||||
};
|
||||
|
||||
static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[MAC_BASE] = LAYOUT_ansi_87(
|
||||
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_SNAP, KC_SIRI, RGB_MOD,
|
||||
|
@ -96,84 +63,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
|
||||
// clang-format on
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(CAPS_MAC_WIN_LOCK_LED_INDEX)
|
||||
extern void rgb_matrix_update_pwm_buffers(void);
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
if (is_siri_active) {
|
||||
if (sync_timer_elapsed32(siri_timer) >= 500) {
|
||||
unregister_code(KC_LCMD);
|
||||
unregister_code(KC_SPACE);
|
||||
is_siri_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(CAPS_MAC_WIN_LOCK_LED_INDEX)
|
||||
if (!rgb_matrix_is_enabled()) {
|
||||
# if defined(CAPS_MAC_WIN_LOCK_LED_INDEX)
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 0, 255, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 0, 0, 255);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 255, 255, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 255, 0, 0);
|
||||
}
|
||||
# endif // SYSTEM_LED_INDEX
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
housekeeping_task_keychron();
|
||||
housekeeping_task_keychron_ft();
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if(!process_record_keychron_ft(keycode, record)) {
|
||||
if (!process_record_keychron(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
if (!process_record_keychron_ft(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case KC_LOPTN:
|
||||
case KC_ROPTN:
|
||||
case KC_LCMMD:
|
||||
case KC_RCMMD:
|
||||
if (record->event.pressed) {
|
||||
register_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
} else {
|
||||
unregister_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_SIRI:
|
||||
if (record->event.pressed) {
|
||||
if (!is_siri_active) {
|
||||
is_siri_active = true;
|
||||
register_code(KC_LCMD);
|
||||
register_code(KC_SPACE);
|
||||
}
|
||||
siri_timer = sync_timer_read32();
|
||||
} else {
|
||||
// Do something else when release
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_TASK:
|
||||
case KC_FLXP:
|
||||
case KC_SNAP:
|
||||
case KC_CRTA:
|
||||
if (record->event.pressed) {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
register_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
unregister_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
default:
|
||||
return true; // Process all other keycodes normally
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
VIA_ENABLE = yes
|
||||
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += keychron_ft_common.c
|
||||
SRC += keychron_common.c keychron_ft_common.c
|
||||
|
|
|
@ -61,26 +61,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE)
|
||||
extern void rgb_matrix_update_pwm_buffers(void);
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
#if defined(RGB_MATRIX_ENABLE)
|
||||
if (!rgb_matrix_is_enabled()) {
|
||||
# if defined(CAPS_SYSTEM_LOCK_LED_INDEX)
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 0, 255, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 0, 0, 255);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 255, 255, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_SYSTEM_LOCK_LED_INDEX, 255, 0, 0);
|
||||
}
|
||||
# endif // SYSTEM_LED_INDEX
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
}
|
||||
|
|
|
@ -140,18 +140,18 @@ led_config_t g_led_config = {
|
|||
{0,0}, {26,0}, {39,0}, {52,0}, {65,0}, {85,0}, {98,0}, {111,0}, {124,0}, {143,0}, {156,0}, {169,0}, {182,0}, {198,0}, {211,0}, {224,0},
|
||||
{0,15}, {13,15}, {26,15}, {39,15}, {52,15}, {65,15}, {78,15}, {91,15}, {104,15}, {117,15}, {130,15}, {143,15}, {156,15}, {176,15}, {198,15}, {211,15}, {224,15},
|
||||
{3,27}, {20,27}, {33,27}, {46,27}, {59,27}, {72,27}, {85,27}, {98,27}, {111,27}, {124,27}, {137,27}, {150,27}, {163,27}, {179,27}, {198,27}, {211,27}, {224,27},
|
||||
{5,39}, {23,39}, {36,39}, {49,39}, {62,39}, {75,39}, {88,39}, {101,39}, {114,39}, {127,39}, {140,39}, {153,39}, {174,39},
|
||||
{5,39}, {23,39}, {36,39}, {49,39}, {62,39}, {75,39}, {88,39}, {101,39}, {114,39}, {127,39}, {140,39}, {153,39}, {174,39}, {221,39},
|
||||
{8,52}, {29,52}, {42,52}, {55,52}, {68,52}, {82,52}, {95,52}, {108,52}, {121,52}, {134,52}, {147,52}, {171,52}, {211,52},
|
||||
{2,64}, {18,64}, {34,64}, {83,64}, {132,64}, {148,64}, {165,64}, {181,64}, {198,64}, {211,64}, {224,64}, {221,39},
|
||||
{2,64}, {18,64}, {34,64}, {83,64}, {132,64}, {148,64}, {165,64}, {181,64}, {198,64}, {211,64}, {224,64},
|
||||
},
|
||||
{
|
||||
// RGB LED Index to Flag
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 8,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 8,
|
||||
1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
# Build Options
|
||||
# change yes to no to disable.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable USB N-key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
DIP_SWITCH_ENABLE = yes
|
||||
RGB_MATRIX_ENABLE = yes
|
||||
RGB_MATRIX_DRIVER = CKLED2001
|
||||
EEPROM_DRIVER = wear_leveling
|
||||
WEAR_LEVELING_DRIVER = embedded_flash
|
||||
|
||||
|
|
|
@ -8,6 +8,20 @@
|
|||
"pid": "0x0513",
|
||||
"device_version": "1.0.1"
|
||||
},
|
||||
"features": {
|
||||
"bootmagic": true,
|
||||
"command": false,
|
||||
"console": false,
|
||||
"dip_switch": true,
|
||||
"encoder": false,
|
||||
"extrakey": true,
|
||||
"mousekey": true,
|
||||
"nkro": true,
|
||||
"led_matrix": true
|
||||
},
|
||||
"led_matrix": {
|
||||
"driver": "CKLED2001"
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["C14", "C15", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "B0", "B1", "A8", "A9", "A10", "H3"],
|
||||
"rows": ["B5", "B4", "B3", "A15", "A14", "A13"]
|
||||
|
|
|
@ -61,34 +61,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE)
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
#if defined(LED_MATRIX_ENABLE)
|
||||
if (!led_matrix_is_enabled()) {
|
||||
# if defined(CAPS_LOCK_LED_INDEX) && defined(MAC_LOCK_LED_INDEX) && defined(WIN_LOCK_LED_INDEX)
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
}
|
||||
# endif // SYSTEM_LED_INDEX
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "keychron_common.h"
|
||||
#include "keychron_ft_common.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -26,40 +27,6 @@ enum layers{
|
|||
WIN_FN
|
||||
};
|
||||
|
||||
enum custom_keycodes {
|
||||
KC_LOPTN = QK_KB_2,
|
||||
KC_ROPTN,
|
||||
KC_LCMMD,
|
||||
KC_RCMMD,
|
||||
KC_SIRI,
|
||||
KC_TASK_VIEW,
|
||||
KC_FILE_EXPLORER,
|
||||
KC_SCREEN_SHOT,
|
||||
KC_CORTANA
|
||||
};
|
||||
|
||||
#define KC_TASK KC_TASK_VIEW
|
||||
#define KC_FLXP KC_FILE_EXPLORER
|
||||
#define KC_SNAP KC_SCREEN_SHOT
|
||||
#define KC_CRTA KC_CORTANA
|
||||
|
||||
typedef struct PACKED {
|
||||
uint8_t len;
|
||||
uint8_t keycode[3];
|
||||
} key_combination_t;
|
||||
|
||||
bool is_siri_active = false;
|
||||
uint32_t siri_timer = 0;
|
||||
// clang-format off
|
||||
key_combination_t key_comb_list[4] = {
|
||||
{2, {KC_LWIN, KC_TAB}},
|
||||
{2, {KC_LWIN, KC_E}},
|
||||
{3, {KC_LSFT, KC_LCMD, KC_4}},
|
||||
{2, {KC_LWIN, KC_C}}
|
||||
};
|
||||
|
||||
static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[MAC_BASE] = LAYOUT_ansi_87(
|
||||
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, BL_DOWN, BL_UP, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_SNAP, KC_SIRI, BL_STEP,
|
||||
|
@ -96,90 +63,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
|
||||
// clang-format on
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX) && defined(MAC_LOCK_LED_INDEX) && defined(WIN_LOCK_LED_INDEX)
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
if (is_siri_active) {
|
||||
if (sync_timer_elapsed32(siri_timer) >= 500) {
|
||||
unregister_code(KC_LCMD);
|
||||
unregister_code(KC_SPACE);
|
||||
is_siri_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX) && defined(MAC_LOCK_LED_INDEX) && defined(WIN_LOCK_LED_INDEX)
|
||||
if (!led_matrix_is_enabled()) {
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
}
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
housekeeping_task_keychron();
|
||||
housekeeping_task_keychron_ft();
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!process_record_keychron(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
if (!process_record_keychron_ft(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case KC_LOPTN:
|
||||
case KC_ROPTN:
|
||||
case KC_LCMMD:
|
||||
case KC_RCMMD:
|
||||
if (record->event.pressed) {
|
||||
register_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
} else {
|
||||
unregister_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_SIRI:
|
||||
if (record->event.pressed) {
|
||||
if (!is_siri_active) {
|
||||
is_siri_active = true;
|
||||
register_code(KC_LCMD);
|
||||
register_code(KC_SPACE);
|
||||
}
|
||||
siri_timer = sync_timer_read32();
|
||||
} else {
|
||||
// Do something else when release
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_TASK:
|
||||
case KC_FLXP:
|
||||
case KC_SNAP:
|
||||
case KC_CRTA:
|
||||
if (record->event.pressed) {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
register_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
unregister_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
default:
|
||||
return true; // Process all other keycodes normally
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
VIA_ENABLE = yes
|
||||
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += keychron_ft_common.c
|
||||
SRC += keychron_common.c keychron_ft_common.c
|
||||
|
|
|
@ -61,34 +61,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE)
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
#if defined(LED_MATRIX_ENABLE)
|
||||
if (!led_matrix_is_enabled()) {
|
||||
# if defined(CAPS_LOCK_LED_INDEX) && defined(MAC_LOCK_LED_INDEX) && defined(WIN_LOCK_LED_INDEX)
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
}
|
||||
# endif // SYSTEM_LED_INDEX
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
}
|
||||
|
|
|
@ -1,24 +1,4 @@
|
|||
# MCU name
|
||||
MCU = STM32L432
|
||||
|
||||
# Bootloader selection
|
||||
BOOTLOADER = stm32-dfu
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable USB N-key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
DIP_SWITCH_ENABLE = yes
|
||||
LED_MATRIX_ENABLE = yes
|
||||
LED_MATRIX_DRIVER = CKLED2001
|
||||
EEPROM_DRIVER = wear_leveling
|
||||
WEAR_LEVELING_DRIVER = embedded_flash
|
||||
|
||||
|
|
|
@ -140,19 +140,19 @@ led_config_t g_led_config = {
|
|||
{0,0}, {26,0}, {39,0}, {52,0}, {65,0}, {85,0}, {98,0}, {111,0}, {124,0}, {143,0}, {156,0}, {169,0}, {182,0}, {198,0}, {211,0}, {224,0},
|
||||
{0,15}, {26,15}, {13,15}, {39,15}, {52,15}, {65,15}, {78,15}, {91,15}, {104,15}, {117,15}, {130,15}, {143,15}, {156,15}, {176,15}, {198,15}, {211,15}, {224,15},
|
||||
{3,27}, {20,27}, {46,27}, {59,27}, {33,27}, {72,27}, {85,27}, {98,27}, {111,27}, {124,27}, {137,27}, {150,27}, {163,27}, {179,27}, {198,27}, {211,27}, {224,27},
|
||||
{5,39}, {23,39}, {36,39}, {49,39}, {62,39}, {75,39}, {88,39}, {101,39}, {114,39}, {127,39}, {140,39}, {153,39}, {174,39},
|
||||
{5,39}, {23,39}, {36,39}, {49,39}, {62,39}, {75,39}, {88,39}, {101,39}, {114,39}, {127,39}, {140,39}, {153,39}, {174,39}, {198,39}, {211, 39},{224,39},
|
||||
{8,52}, {29,52}, {42,52}, {55,52}, {68,52}, {82,52}, {95,52}, {108,52}, {121,52}, {134,52}, {147,52}, {171,52}, {211,52},
|
||||
{2,64}, {18,64}, {34,64}, {83,64}, {132,64}, {149,64}, {181,64}, {165,64}, {198,64}, {211,64}, {224,64}, {181,52}, {198, 52}, {95, 64},
|
||||
{2,64}, {18,64}, {34,64}, {83,64}, {132,64}, {149,64}, {181,64}, {165,64}, {198,64}, {211,64}, {224,64},
|
||||
},
|
||||
{
|
||||
// RGB LED Index to Flag
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 8, 8, 8,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 8, 8, 8,
|
||||
1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1,
|
||||
}
|
||||
};
|
||||
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
#endif
|
||||
|
|
|
@ -96,14 +96,31 @@ bool led_update_kb(led_t led_state) {
|
|||
} else if ((!led_state.caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 255, 0, 0);
|
||||
}
|
||||
# endif // CAPS_LOCK_LED_INDEX
|
||||
# endif
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // CAPS_MAC_WIN_LOCK_LED_INDEX
|
||||
void housekeeping_task_kb(void) {
|
||||
# if defined(RGB_MATRIX_ENABLE) && defined(CAPS_MAC_WIN_LOCK_LED_INDEX)
|
||||
if (!rgb_matrix_is_enabled()) {
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 0, 255, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 0, 0, 255);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 255, 255, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
rgb_matrix_set_color(CAPS_MAC_WIN_LOCK_LED_INDEX, 255, 0, 0);
|
||||
}
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX) && defined(MAC_LOCK_LED_INDEX) && defined(WIN_LOCK_LED_INDEX)
|
||||
|
||||
|
@ -160,11 +177,36 @@ bool led_update_kb(led_t led_state) {
|
|||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
}
|
||||
# endif
|
||||
led_matrix_update_pwm_buffers();
|
||||
# endif
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // LED_MATRIX_ENABLE
|
||||
void housekeeping_task_kb(void) {
|
||||
# if defined(LED_MATRIX_ENABLE) && defined(CAPS_LOCK_LED_INDEX) && defined(MAC_LOCK_LED_INDEX) && defined(WIN_LOCK_LED_INDEX)
|
||||
if (!led_matrix_is_enabled()) {
|
||||
if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
|
||||
} else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
} else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
|
||||
led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
|
||||
}
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Keychron C1 Pro
|
||||
|
||||
![Keychron C1 Pro](https://i.imgur.com/Svdm4lp.jpg[/img])
|
||||
![Keychron C1 Pro](https://i.imgur.com/Svdm4lp.jpg)
|
||||
|
||||
A customizable 100% keyboard.
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#define DRIVER_COUNT 2
|
||||
#define DRIVER_ADDR_1 0b1110111
|
||||
#define DRIVER_ADDR_2 0b1110100
|
||||
|
||||
/* Set LED driver current */
|
||||
#define CKLED2001_CURRENT_TUNE \
|
||||
{ 0xAA, 0xAA, 0x56, 0xAA, 0xAA, 0x56, 0xAA, 0xAA, 0x56, 0xAA, 0xAA, 0x56 }
|
||||
|
||||
|
@ -29,8 +31,8 @@
|
|||
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
|
||||
|
||||
/* Enable indicator LED*/
|
||||
#define NUM_LOCK_LED_INDEX 16
|
||||
#define CAPS_LOCK_LED_INDEX 17
|
||||
#define NUM_LOCK_INDEX 16
|
||||
#define CAPS_LOCK_INDEX 17
|
||||
#define MAC_OS_LED_INDEX 18
|
||||
#define WIN_OS_LED_INDEX 19
|
||||
|
||||
|
|
|
@ -8,6 +8,20 @@
|
|||
"pid": "0x0520",
|
||||
"device_version": "1.0.2"
|
||||
},
|
||||
"features": {
|
||||
"bootmagic": true,
|
||||
"command": false,
|
||||
"console": false,
|
||||
"dip_switch": true,
|
||||
"encoder": false,
|
||||
"extrakey": true,
|
||||
"mousekey": true,
|
||||
"nkro": true,
|
||||
"rgb_matrix": true
|
||||
},
|
||||
"rgb_matrix": {
|
||||
"driver": "CKLED2001"
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["A10", "A9", "A8", "B1", "B0", "A7", "A6", "A5", "A4", "A3", "A2", null, null, null, null, null, null, null, null, "C14"],
|
||||
"rows": ["B5", "B4", "B3", "A15", "A14", "A13"]
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "keychron_common.h"
|
||||
#include "keychron_ft_common.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -26,40 +27,6 @@ enum layers{
|
|||
WIN_FN
|
||||
};
|
||||
|
||||
enum custom_keycodes {
|
||||
KC_LOPTN = QK_KB_2, // TECH DEBT: Starts at QK_KB_2 to maintain ordering with VIA definitions. See #19884. Revert to QK_KB_0 when VIA catches up with QMK.
|
||||
KC_ROPTN,
|
||||
KC_LCMMD,
|
||||
KC_RCMMD,
|
||||
KC_SIRI,
|
||||
KC_TASK_VIEW,
|
||||
KC_FILE_EXPLORER,
|
||||
KC_SCREEN_SHOT,
|
||||
KC_CORTANA
|
||||
};
|
||||
|
||||
#define KC_TASK KC_TASK_VIEW
|
||||
#define KC_FLXP KC_FILE_EXPLORER
|
||||
#define KC_SNAP KC_SCREEN_SHOT
|
||||
#define KC_CRTA KC_CORTANA
|
||||
|
||||
typedef struct PACKED {
|
||||
uint8_t len;
|
||||
uint8_t keycode[3];
|
||||
} key_combination_t;
|
||||
|
||||
bool is_siri_active = false;
|
||||
uint32_t siri_timer = 0;
|
||||
// clang-format off
|
||||
key_combination_t key_comb_list[4] = {
|
||||
{2, {KC_LWIN, KC_TAB}},
|
||||
{2, {KC_LWIN, KC_E}},
|
||||
{3, {KC_LSFT, KC_LCMD, KC_4}},
|
||||
{2, {KC_LWIN, KC_C}}
|
||||
};
|
||||
|
||||
static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[MAC_BASE] = LAYOUT_ansi_104(
|
||||
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_SNAP, KC_SIRI, RGB_MOD,
|
||||
|
@ -96,87 +63,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
|
||||
// clang-format on
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
extern void rgb_matrix_update_pwm_buffers(void);
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
if (is_siri_active) {
|
||||
if (sync_timer_elapsed32(siri_timer) >= 500) {
|
||||
unregister_code(KC_LCMD);
|
||||
unregister_code(KC_SPACE);
|
||||
is_siri_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
if (!rgb_matrix_is_enabled()) {
|
||||
# if defined(MAC_OS_LED_INDEX)
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
rgb_matrix_set_color(MAC_OS_LED_INDEX, 255, 255, 255);
|
||||
} else {
|
||||
rgb_matrix_set_color(MAC_OS_LED_INDEX, 0, 0, 0);
|
||||
}
|
||||
# endif // MAC_OS_LED_INDEX
|
||||
# if defined(WIN_OS_LED_INDEX)
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
rgb_matrix_set_color(WIN_OS_LED_INDEX, 255, 255, 255);
|
||||
} else {
|
||||
rgb_matrix_set_color(WIN_OS_LED_INDEX, 0, 0, 0);
|
||||
}
|
||||
# endif // WIN_OS_LED_INDEX
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
housekeeping_task_keychron();
|
||||
housekeeping_task_keychron_ft();
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!process_record_keychron(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
if (!process_record_keychron_ft(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case KC_LOPTN:
|
||||
case KC_ROPTN:
|
||||
case KC_LCMMD:
|
||||
case KC_RCMMD:
|
||||
if (record->event.pressed) {
|
||||
register_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
} else {
|
||||
unregister_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_SIRI:
|
||||
if (record->event.pressed) {
|
||||
if (!is_siri_active) {
|
||||
is_siri_active = true;
|
||||
register_code(KC_LCMD);
|
||||
register_code(KC_SPACE);
|
||||
}
|
||||
siri_timer = sync_timer_read32();
|
||||
} else {
|
||||
// Do something else when release
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_TASK:
|
||||
case KC_FLXP:
|
||||
case KC_SNAP:
|
||||
case KC_CRTA:
|
||||
if (record->event.pressed) {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
register_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
unregister_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
default:
|
||||
return true; // Process all other keycodes normally
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
VIA_ENABLE = yes
|
||||
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += keychron_ft_common.c
|
||||
SRC += keychron_common.c keychron_ft_common.c
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
# Build Options
|
||||
# change yes to no to disable.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable USB N-key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
DIP_SWITCH_ENABLE = yes
|
||||
RGB_MATRIX_ENABLE = yes
|
||||
RGB_MATRIX_DRIVER = CKLED2001
|
||||
EEPROM_DRIVER = wear_leveling
|
||||
WEAR_LEVELING_DRIVER = embedded_flash
|
||||
|
||||
|
@ -22,5 +8,5 @@ OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE
|
|||
# custom matrix setup
|
||||
CUSTOM_MATRIX = lite
|
||||
|
||||
VPATH ?= keyboards/keychron/common
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += matrix.c
|
||||
|
|
|
@ -19,15 +19,18 @@
|
|||
/* RGB Matrix Driver Configuration */
|
||||
#define DRIVER_COUNT 1
|
||||
#define DRIVER_ADDR_1 0b1110100
|
||||
#define CKLED2001_CURRENT_TUNE { 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0 }
|
||||
|
||||
/* Set LED driver current */
|
||||
#define CKLED2001_CURRENT_TUNE \
|
||||
{ 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0 }
|
||||
|
||||
/* RGB Matrix Configuration */
|
||||
#define DRIVER_1_LED_TOTAL 108
|
||||
#define LED_MATRIX_LED_COUNT DRIVER_1_LED_TOTAL
|
||||
|
||||
/* Enable indicator LED*/
|
||||
#define NUM_LOCK_LED_INDEX 16
|
||||
#define CAPS_LOCK_LED_INDEX 17
|
||||
#define NUM_LOCK_INDEX 16
|
||||
#define CAPS_LOCK_INDEX 17
|
||||
#define MAC_OS_LED_INDEX 18
|
||||
#define WIN_OS_LED_INDEX 19
|
||||
|
||||
|
|
|
@ -8,6 +8,20 @@
|
|||
"pid": "0x0523",
|
||||
"device_version": "1.0.1"
|
||||
},
|
||||
"features": {
|
||||
"bootmagic": true,
|
||||
"command": false,
|
||||
"console": false,
|
||||
"dip_switch": true,
|
||||
"encoder": false,
|
||||
"extrakey": true,
|
||||
"mousekey": true,
|
||||
"nkro": true,
|
||||
"led_matrix": true
|
||||
},
|
||||
"led_matrix": {
|
||||
"driver": "CKLED2001"
|
||||
},
|
||||
"matrix_pins": {
|
||||
"cols": ["A10", "A9", "A8", "B1", "B0", "A7", "A6", "A5", "A4", "A3", "A2", null, null, null, null, null, null, null, null, "C14"],
|
||||
"rows": ["B5", "B4", "B3", "A15", "A14", "A13"]
|
||||
|
|
|
@ -52,7 +52,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
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_P4, KC_P5, KC_P6,
|
||||
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_P1, KC_P2, KC_P3, KC_PENT,
|
||||
KC_LCTL, KC_LWIN, KC_LALT, KC_SPC, KC_RALT, KC_RWIN, MO(WIN_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT),
|
||||
|
||||
|
||||
[WIN_FN] = LAYOUT_ansi_104(
|
||||
_______, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, BL_DOWN, BL_UP, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, BL_TOGG,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
|
@ -61,25 +61,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
if (!led_matrix_is_enabled()) {
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 0);
|
||||
}
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 0);
|
||||
}
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "keychron_common.h"
|
||||
#include "keychron_ft_common.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -26,40 +27,6 @@ enum layers{
|
|||
WIN_FN
|
||||
};
|
||||
|
||||
enum custom_keycodes {
|
||||
KC_LOPTN = QK_KB_2, // TECH DEBT: Starts at QK_KB_2 to maintain ordering with VIA definitions. See #19884. Revert to QK_KB_0 when VIA catches up with QMK.
|
||||
KC_ROPTN,
|
||||
KC_LCMMD,
|
||||
KC_RCMMD,
|
||||
KC_SIRI,
|
||||
KC_TASK_VIEW,
|
||||
KC_FILE_EXPLORER,
|
||||
KC_SCREEN_SHOT,
|
||||
KC_CORTANA
|
||||
};
|
||||
|
||||
#define KC_TASK KC_TASK_VIEW
|
||||
#define KC_FLXP KC_FILE_EXPLORER
|
||||
#define KC_SNAP KC_SCREEN_SHOT
|
||||
#define KC_CRTA KC_CORTANA
|
||||
|
||||
typedef struct PACKED {
|
||||
uint8_t len;
|
||||
uint8_t keycode[3];
|
||||
} key_combination_t;
|
||||
|
||||
bool is_siri_active = false;
|
||||
uint32_t siri_timer = 0;
|
||||
// clang-format off
|
||||
key_combination_t key_comb_list[4] = {
|
||||
{2, {KC_LWIN, KC_TAB}},
|
||||
{2, {KC_LWIN, KC_E}},
|
||||
{3, {KC_LSFT, KC_LCMD, KC_4}},
|
||||
{2, {KC_LWIN, KC_C}}
|
||||
};
|
||||
|
||||
static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[MAC_BASE] = LAYOUT_ansi_104(
|
||||
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, BL_DOWN, BL_UP, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_SNAP, KC_SIRI, BL_STEP,
|
||||
|
@ -96,82 +63,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
|
||||
// clang-format on
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
#endif
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
if (is_siri_active) {
|
||||
if (sync_timer_elapsed32(siri_timer) >= 500) {
|
||||
unregister_code(KC_LCMD);
|
||||
unregister_code(KC_SPACE);
|
||||
is_siri_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
if (!led_matrix_is_enabled()) {
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 0);
|
||||
}
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 0);
|
||||
}
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
#endif
|
||||
housekeeping_task_keychron();
|
||||
housekeeping_task_keychron_ft();
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!process_record_keychron(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
if (!process_record_keychron_ft(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process_record_keychron(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case KC_LOPTN:
|
||||
case KC_ROPTN:
|
||||
case KC_LCMMD:
|
||||
case KC_RCMMD:
|
||||
if (record->event.pressed) {
|
||||
register_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
} else {
|
||||
unregister_code(mac_keycode[keycode - KC_LOPTN]);
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_SIRI:
|
||||
if (record->event.pressed) {
|
||||
if (!is_siri_active) {
|
||||
is_siri_active = true;
|
||||
register_code(KC_LCMD);
|
||||
register_code(KC_SPACE);
|
||||
}
|
||||
siri_timer = sync_timer_read32();
|
||||
} else {
|
||||
// Do something else when release
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
case KC_TASK:
|
||||
case KC_FLXP:
|
||||
case KC_SNAP:
|
||||
case KC_CRTA:
|
||||
if (record->event.pressed) {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
register_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < key_comb_list[keycode - KC_TASK].len; i++) {
|
||||
unregister_code(key_comb_list[keycode - KC_TASK].keycode[i]);
|
||||
}
|
||||
}
|
||||
return false; // Skip all further processing of this key
|
||||
default:
|
||||
return true; // Process all other keycodes normally
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
VIA_ENABLE = yes
|
||||
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += keychron_ft_common.c
|
||||
SRC += keychron_common.c keychron_ft_common.c
|
||||
|
|
|
@ -59,25 +59,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
if (!led_matrix_is_enabled()) {
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 0);
|
||||
}
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 0);
|
||||
}
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
# Build Options
|
||||
# change yes to no to disable.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Enable USB N-key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
DIP_SWITCH_ENABLE = yes
|
||||
LED_MATRIX_ENABLE = yes
|
||||
LED_MATRIX_DRIVER = CKLED2001
|
||||
EEPROM_DRIVER = wear_leveling
|
||||
WEAR_LEVELING_DRIVER = embedded_flash
|
||||
|
||||
|
@ -22,4 +8,5 @@ OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE
|
|||
# custom matrix setup
|
||||
CUSTOM_MATRIX = lite
|
||||
|
||||
VPATH += keyboards/keychron/common
|
||||
SRC += matrix.c
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
// clang-format off
|
||||
const matrix_row_t matrix_mask[] = {
|
||||
0b11111111111111111111,
|
||||
0b11111111111111111111,
|
||||
|
@ -24,7 +24,7 @@ const matrix_row_t matrix_mask[] = {
|
|||
0b11111111111111111111,
|
||||
0b11111111111111101111,
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
|
||||
bool dip_switch_update_kb(uint8_t index, bool active) {
|
||||
|
@ -39,158 +39,131 @@ bool dip_switch_update_kb(uint8_t index, bool active) {
|
|||
|
||||
#endif // DIP_SWITCH_ENABLE
|
||||
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(NUM_LOCK_LED_INDEX) && defined(CAPS_LOCK_LED_INDEX) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
#if (defined(RGB_MATRIX_ENABLE) || defined(LED_MATRIX_ENABLE)) && defined(NUM_LOCK_INDEX) && defined(CAPS_LOCK_INDEX) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
|
||||
extern void rgb_matrix_update_pwm_buffers(void);
|
||||
# ifdef RGB_MATRIX_ENABLE
|
||||
# define LED_MATRIX_INDICATORS_KB rgb_matrix_indicators_kb
|
||||
# define LED_MATRIX_INDICATORS_USER rgb_matrix_indicators_user
|
||||
# define LED_MATRIX_SET_COLOR rgb_matrix_set_color
|
||||
# define LED_MATRIX_UPDATE_PWN_BUFFERS rgb_matrix_update_pwm_buffers
|
||||
# define LED_MATRIX_INDICATORS_NONE_KB rgb_matrix_indicators_none_kb
|
||||
# define LED_MATRIX_IS_ENABLED rgb_matrix_is_enabled
|
||||
# define COLOR_WHITE 255, 255, 255
|
||||
# define COLOR_BLACK 0, 0, 0
|
||||
# endif
|
||||
|
||||
bool rgb_matrix_indicators_kb(void) {
|
||||
if (!rgb_matrix_indicators_user()) {
|
||||
# ifdef LED_MATRIX_ENABLE
|
||||
# define LED_MATRIX_INDICATORS_KB led_matrix_indicators_kb
|
||||
# define LED_MATRIX_INDICATORS_USER led_matrix_indicators_user
|
||||
# define LED_MATRIX_SET_COLOR led_matrix_set_value
|
||||
# define LED_MATRIX_UPDATE_PWN_BUFFERS led_matrix_update_pwm_buffers
|
||||
# define LED_MATRIX_INDICATORS_NONE_KB led_matrix_indicators_none_kb
|
||||
# define LED_MATRIX_IS_ENABLED led_matrix_is_enabled
|
||||
# define COLOR_WHITE 255
|
||||
# define COLOR_BLACK 0
|
||||
# endif
|
||||
|
||||
extern void LED_MATRIX_UPDATE_PWN_BUFFERS(void);
|
||||
|
||||
bool LED_MATRIX_INDICATORS_KB(void) {
|
||||
if (!LED_MATRIX_INDICATORS_USER()) {
|
||||
return false;
|
||||
}
|
||||
# if defined(CAPS_LOCK_LED_INDEX)
|
||||
# if defined(CAPS_LOCK_INDEX)
|
||||
if (host_keyboard_led_state().caps_lock) {
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, 255, 255, 255);
|
||||
LED_MATRIX_SET_COLOR(CAPS_LOCK_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, 0, 0, 0);
|
||||
LED_MATRIX_SET_COLOR(CAPS_LOCK_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // CAPS_LOCK_LED_INDEX
|
||||
# if defined(NUM_LOCK_LED_INDEX)
|
||||
# endif // CAPS_LOCK_INDEX
|
||||
# if defined(NUM_LOCK_INDEX)
|
||||
if (host_keyboard_led_state().num_lock) {
|
||||
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, 255, 255, 255);
|
||||
LED_MATRIX_SET_COLOR(NUM_LOCK_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, 0, 0, 0);
|
||||
LED_MATRIX_SET_COLOR(NUM_LOCK_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // NUM_LOCK_LED_INDEX
|
||||
# endif // NUM_LOCK_INDEX
|
||||
# if defined(MAC_OS_LED_INDEX)
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
rgb_matrix_set_color(MAC_OS_LED_INDEX, 255, 255, 255);
|
||||
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
rgb_matrix_set_color(MAC_OS_LED_INDEX, 0, 0, 0);
|
||||
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // MAC_OS_LED_INDEX
|
||||
# if defined(WIN_OS_LED_INDEX)
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
rgb_matrix_set_color(WIN_OS_LED_INDEX, 255, 255, 255);
|
||||
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
rgb_matrix_set_color(WIN_OS_LED_INDEX, 0, 0, 0);
|
||||
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // WIN_OS_LED_INDEX
|
||||
return true;
|
||||
}
|
||||
|
||||
void rgb_matrix_indicators_none_kb(void) {
|
||||
rgb_matrix_indicators_kb();
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
void LED_MATRIX_INDICATORS_NONE_KB(void) {
|
||||
LED_MATRIX_INDICATORS_KB();
|
||||
LED_MATRIX_UPDATE_PWN_BUFFERS();
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
|
||||
if (rgb_matrix_is_enabled()
|
||||
# if defined(ENABLE_RGB_MATRIX_RAINDROPS)
|
||||
if (LED_MATRIX_IS_ENABLED()
|
||||
# if defined(RGB_MATRIX_ENABLE)
|
||||
# if defined(ENABLE_RGB_MATRIX_RAINDROPS)
|
||||
&& (rgb_matrix_get_mode() != RGB_MATRIX_RAINDROPS)
|
||||
# endif
|
||||
# if defined(ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS)
|
||||
# endif
|
||||
# if defined(ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS)
|
||||
&& (rgb_matrix_get_mode() != RGB_MATRIX_JELLYBEAN_RAINDROPS)
|
||||
# endif
|
||||
# if defined(ENABLE_RGB_MATRIX_PIXEL_RAIN)
|
||||
# endif
|
||||
# if defined(ENABLE_RGB_MATRIX_PIXEL_RAIN)
|
||||
&& (rgb_matrix_get_mode() != RGB_MATRIX_PIXEL_RAIN)
|
||||
# endif
|
||||
# endif
|
||||
) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (res) {
|
||||
# if defined(NUM_LOCK_LED_INDEX)
|
||||
# if defined(NUM_LOCK_INDEX)
|
||||
if (led_state.num_lock) {
|
||||
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, 255, 255, 255);
|
||||
LED_MATRIX_SET_COLOR(NUM_LOCK_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
rgb_matrix_set_color(NUM_LOCK_LED_INDEX, 0, 0, 0);
|
||||
LED_MATRIX_SET_COLOR(NUM_LOCK_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // NUM_LOCK_LED_INDEX
|
||||
# if defined(CAPS_LOCK_LED_INDEX)
|
||||
# endif // NUM_LOCK_INDEX
|
||||
# if defined(CAPS_LOCK_INDEX)
|
||||
if (led_state.caps_lock) {
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, 255, 255, 255);
|
||||
LED_MATRIX_SET_COLOR(CAPS_LOCK_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
rgb_matrix_set_color(CAPS_LOCK_LED_INDEX, 0, 0, 0);
|
||||
LED_MATRIX_SET_COLOR(CAPS_LOCK_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // CAPS_LOCK_LED_INDEX
|
||||
# endif // CAPS_LOCK_INDEX
|
||||
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
LED_MATRIX_UPDATE_PWN_BUFFERS();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(NUM_LOCK_LED_INDEX) && defined(CAPS_LOCK_LED_INDEX) && defined(MAC_OS_LED_INDEX) && defined(WIN_OS_LED_INDEX)
|
||||
|
||||
extern void led_matrix_update_pwm_buffers(void);
|
||||
|
||||
bool led_matrix_indicators_kb(void) {
|
||||
if (!led_matrix_indicators_user()) {
|
||||
return false;
|
||||
}
|
||||
# if defined(CAPS_LOCK_LED_INDEX)
|
||||
if (host_keyboard_led_state().caps_lock) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
}
|
||||
# endif // CAPS_LOCK_LED_INDEX
|
||||
# if defined(NUM_LOCK_LED_INDEX)
|
||||
if (host_keyboard_led_state().num_lock) {
|
||||
led_matrix_set_value(NUM_LOCK_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(NUM_LOCK_LED_INDEX, 0);
|
||||
}
|
||||
# endif // NUM_LOCK_LED_INDEX
|
||||
void housekeeping_task_kb(void) {
|
||||
if (!LED_MATRIX_IS_ENABLED()) {
|
||||
# if defined(MAC_OS_LED_INDEX)
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(MAC_OS_LED_INDEX, 0);
|
||||
}
|
||||
if (default_layer_state == (1 << 0)) {
|
||||
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // MAC_OS_LED_INDEX
|
||||
# if defined(WIN_OS_LED_INDEX)
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(WIN_OS_LED_INDEX, 0);
|
||||
}
|
||||
if (default_layer_state == (1 << 2)) {
|
||||
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_WHITE);
|
||||
} else {
|
||||
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_BLACK);
|
||||
}
|
||||
# endif // WIN_OS_LED_INDEX
|
||||
return true;
|
||||
}
|
||||
|
||||
void led_matrix_indicators_none_kb(void) {
|
||||
led_matrix_indicators_kb();
|
||||
led_matrix_update_pwm_buffers();
|
||||
}
|
||||
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
|
||||
if (res) {
|
||||
# if defined(NUM_LOCK_LED_INDEX)
|
||||
if (led_state.num_lock) {
|
||||
led_matrix_set_value(NUM_LOCK_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(NUM_LOCK_LED_INDEX, 0);
|
||||
}
|
||||
# endif // NUM_LOCK_LED_INDEX
|
||||
# if defined(CAPS_LOCK_LED_INDEX)
|
||||
if (led_state.caps_lock) {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
|
||||
} else {
|
||||
led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
|
||||
}
|
||||
# endif // CAPS_LOCK_LED_INDEX
|
||||
|
||||
led_matrix_update_pwm_buffers();
|
||||
LED_MATRIX_UPDATE_PWN_BUFFERS();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,3 +43,9 @@
|
|||
/* Factory test keys */
|
||||
#define FN_KEY1 MO(1)
|
||||
#define FN_KEY2 MO(3)
|
||||
|
||||
#define HC595_STCP A0
|
||||
#define HC595_SHCP A1
|
||||
#define HC595_DS C15
|
||||
#define SHIFT_COL_START 11
|
||||
#define SHIFT_COL_END 19
|
||||
|
|
|
@ -1,208 +0,0 @@
|
|||
/* Copyright 2023 @ 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 "quantum.h"
|
||||
|
||||
#define HC595_STCP A0
|
||||
#define HC595_SHCP A1
|
||||
#define HC595_DS C15
|
||||
|
||||
pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
|
||||
pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||
|
||||
#define ROWS_PER_HAND (MATRIX_ROWS)
|
||||
|
||||
static inline void setPinOutput_writeLow(pin_t pin) {
|
||||
ATOMIC_BLOCK_FORCEON {
|
||||
setPinOutput(pin);
|
||||
writePinLow(pin);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setPinOutput_writeHigh(pin_t pin) {
|
||||
ATOMIC_BLOCK_FORCEON {
|
||||
setPinOutput(pin);
|
||||
writePinHigh(pin);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setPinInputHigh_atomic(pin_t pin) {
|
||||
ATOMIC_BLOCK_FORCEON {
|
||||
setPinInputHigh(pin);
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint8_t readMatrixPin(pin_t pin) {
|
||||
if (pin != NO_PIN) {
|
||||
return readPin(pin);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void HC595_delay(uint16_t n) {
|
||||
while (n-- > 0) {
|
||||
asm volatile("nop" ::: "memory");
|
||||
};
|
||||
}
|
||||
|
||||
static void HC595_output(uint8_t data) {
|
||||
ATOMIC_BLOCK_FORCEON {
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
if (data & 0x1) {
|
||||
writePinHigh(HC595_DS);
|
||||
} else {
|
||||
writePinLow(HC595_DS);
|
||||
}
|
||||
data = data >> 1;
|
||||
writePinHigh(HC595_SHCP);
|
||||
HC595_delay(3);
|
||||
writePinLow(HC595_SHCP);
|
||||
}
|
||||
writePinHigh(HC595_STCP);
|
||||
HC595_delay(3);
|
||||
writePinLow(HC595_STCP);
|
||||
}
|
||||
}
|
||||
|
||||
static void HC595_output_bit(uint8_t data) {
|
||||
ATOMIC_BLOCK_FORCEON {
|
||||
if (data & 0x1) {
|
||||
writePinHigh(HC595_DS);
|
||||
} else {
|
||||
writePinLow(HC595_DS);
|
||||
}
|
||||
writePinHigh(HC595_SHCP);
|
||||
HC595_delay(3);
|
||||
writePinLow(HC595_SHCP);
|
||||
writePinHigh(HC595_STCP);
|
||||
HC595_delay(3);
|
||||
writePinLow(HC595_STCP);
|
||||
}
|
||||
}
|
||||
|
||||
static bool select_col(uint8_t col) {
|
||||
pin_t pin = col_pins[col];
|
||||
|
||||
if (pin != NO_PIN) {
|
||||
setPinOutput_writeLow(pin);
|
||||
return true;
|
||||
} else {
|
||||
if (col == 10) {
|
||||
HC595_output_bit(0x00);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void unselect_col(uint8_t col) {
|
||||
pin_t pin = col_pins[col];
|
||||
|
||||
if (pin != NO_PIN) {
|
||||
#ifdef MATRIX_UNSELECT_DRIVE_HIGH
|
||||
setPinOutput_writeHigh(pin);
|
||||
#else
|
||||
setPinInputHigh_atomic(pin);
|
||||
#endif
|
||||
} else {
|
||||
HC595_output_bit(0x01);
|
||||
}
|
||||
}
|
||||
|
||||
static void unselect_cols(void) {
|
||||
// unselect column pins
|
||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
pin_t pin = col_pins[x];
|
||||
|
||||
if (pin != NO_PIN) {
|
||||
#ifdef MATRIX_UNSELECT_DRIVE_HIGH
|
||||
setPinOutput_writeHigh(pin);
|
||||
#else
|
||||
setPinInputHigh_atomic(pin);
|
||||
#endif
|
||||
}
|
||||
if (x == 10)
|
||||
HC595_output(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
static void matrix_init_pins(void) {
|
||||
setPinOutput(HC595_DS);
|
||||
setPinOutput(HC595_SHCP);
|
||||
setPinOutput(HC595_STCP);
|
||||
#ifdef MATRIX_UNSELECT_DRIVE_HIGH
|
||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
if (col_pins[x] != NO_PIN) {
|
||||
setPinOutput(col_pins[x]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
unselect_cols();
|
||||
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||
if (row_pins[x] != NO_PIN) {
|
||||
setPinInputHigh_atomic(row_pins[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter) {
|
||||
bool key_pressed = false;
|
||||
|
||||
// Select col
|
||||
if (!select_col(current_col)) { // select col
|
||||
return; // skip NO_PIN col
|
||||
}
|
||||
|
||||
matrix_output_select_delay();
|
||||
|
||||
// For each row...
|
||||
for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
|
||||
// Check row pin state
|
||||
if (readMatrixPin(row_pins[row_index]) == 0) {
|
||||
// Pin LO, set col bit
|
||||
current_matrix[row_index] |= row_shifter;
|
||||
key_pressed = true;
|
||||
} else {
|
||||
// Pin HI, clear col bit
|
||||
current_matrix[row_index] &= ~row_shifter;
|
||||
}
|
||||
}
|
||||
|
||||
// Unselect col
|
||||
unselect_col(current_col);
|
||||
matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH
|
||||
}
|
||||
|
||||
void matrix_init_custom(void) {
|
||||
// initialize key pins
|
||||
matrix_init_pins();
|
||||
}
|
||||
|
||||
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
||||
matrix_row_t curr_matrix[MATRIX_ROWS] = {0};
|
||||
|
||||
// Set col, read rows
|
||||
matrix_row_t row_shifter = MATRIX_ROW_SHIFTER;
|
||||
for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++, row_shifter <<= 1) {
|
||||
matrix_read_rows_on_col(curr_matrix, current_col, row_shifter);
|
||||
}
|
||||
|
||||
bool changed = memcmp(current_matrix, curr_matrix, sizeof(curr_matrix)) != 0;
|
||||
if (changed) memcpy(current_matrix, curr_matrix, sizeof(curr_matrix));
|
||||
|
||||
return changed;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
# Keychron C2 Pro
|
||||
|
||||
![Keychron C2 Pro](https://i.imgur.com/BQE1tFO.jpg[/img])
|
||||
![Keychron C2 Pro](https://i.imgur.com/BQE1tFO.jpg)
|
||||
|
||||
A customizable 100% keyboard.
|
||||
|
||||
|
|
|
@ -24,18 +24,15 @@
|
|||
#endif
|
||||
|
||||
#if defined(SHIFT_COL_START) && defined(SHIFT_COL_END)
|
||||
# if ((SHIFT_COL_END - SHIFT_COL_START) > 8)
|
||||
# define SIZE_T uint16_t
|
||||
# define CLEAR_VAL 0x0000
|
||||
# define SET_VAL 0xFFFF
|
||||
# elif ((SHIFT_COL_END - SHIFT_COL_START) > 16)
|
||||
# if ((SHIFT_COL_END - SHIFT_COL_START) > 16)
|
||||
# define SIZE_T uint32_t
|
||||
# define CLEAR_VAL 0x00000000
|
||||
# define SET_VAL 0xFFFFFFFF
|
||||
# define UNSELECT_ALL_COL 0xFFFFFFFF
|
||||
# elif ((SHIFT_COL_END - SHIFT_COL_START) > 8)
|
||||
# define SIZE_T uint16_t
|
||||
# define UNSELECT_ALL_COL 0xFFFF
|
||||
# else
|
||||
# define SIZE_T uint8_t
|
||||
# define CLEAR_VAL 0x00
|
||||
# define SET_VAL 0xFF
|
||||
# define UNSELECT_ALL_COL 0xFF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -76,11 +73,11 @@ static inline void HC595_delay(uint8_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
static void HC595_output(SIZE_T data, bool bit_flag) {
|
||||
static void HC595_output(SIZE_T data, uint8_t bit) {
|
||||
uint8_t n = 1;
|
||||
|
||||
ATOMIC_BLOCK_FORCEON {
|
||||
for (uint8_t i = 0; i <= (SHIFT_COL_END - SHIFT_COL_START); i++) {
|
||||
for (uint8_t i = 0; i < (SHIFT_COL_END - SHIFT_COL_START + 1); i++) {
|
||||
if (data & 0x1) {
|
||||
writePinHigh(HC595_DS);
|
||||
} else {
|
||||
|
@ -90,7 +87,7 @@ static void HC595_output(SIZE_T data, bool bit_flag) {
|
|||
HC595_delay(n);
|
||||
writePinLow(HC595_SHCP);
|
||||
HC595_delay(n);
|
||||
if (bit_flag) {
|
||||
if (bit) {
|
||||
break;
|
||||
} else {
|
||||
data = data >> 1;
|
||||
|
@ -111,7 +108,7 @@ static bool select_col(uint8_t col) {
|
|||
return true;
|
||||
} else {
|
||||
if (col == SHIFT_COL_START) {
|
||||
HC595_output(0x00, true);
|
||||
HC595_output(0x00, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -128,7 +125,7 @@ static void unselect_col(uint8_t col) {
|
|||
setPinInput_high(pin);
|
||||
#endif
|
||||
} else {
|
||||
HC595_output(0x01, true);
|
||||
HC595_output(0x01, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +139,7 @@ static void unselect_cols(void) {
|
|||
setPinInput_high(pin);
|
||||
#endif
|
||||
} else {
|
||||
if (x == SHIFT_COL_START) HC595_output(SET_VAL, false);
|
||||
if (x == SHIFT_COL_START) HC595_output(UNSELECT_ALL_COL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user