Bulk commit for changes to K5 Max:

- Introduced new keymap "infraviolet"
  - Basic keymap with only two layers
	- No support for VIA
	- RGB set to purple, no facilities for changing it
	  - TODO: RGB not working currently, never turns on
	  - Mac/Windows switch repurposed as backlight switch
- Removed keyboard-level handling of Mac/Windows switch
  - Was not implemented properly, ignored return value of user function
- Autoformatter went a bit silly on common/factory_test.c
This commit is contained in:
Ezri Brimhall 2025-11-05 09:54:49 -07:00
parent 0a529031e6
commit 8233b6ede1
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
6 changed files with 168 additions and 64 deletions

View File

@ -70,17 +70,7 @@ enum {
KEY_PRESS_BACKLIGTH_TEST = KEY_PRESS_FN | KEY_PRESS_BL_KEY1 | KEY_PRESS_BL_KEY2,
};
enum {
FACTORY_TEST_CMD_BACKLIGHT = 0x01,
FACTORY_TEST_CMD_OS_SWITCH,
FACTORY_TEST_CMD_JUMP_TO_BL,
FACTORY_TEST_CMD_INT_PIN,
FACTORY_TEST_CMD_GET_TRANSPORT,
FACTORY_TEST_CMD_CHARGING_ADC,
FACTORY_TEST_CMD_RADIO_CARRIER,
FACTORY_TEST_CMD_GET_BUILD_TIME,
FACTORY_TEST_CMD_GET_DEVICE_ID
};
enum { FACTORY_TEST_CMD_BACKLIGHT = 0x01, FACTORY_TEST_CMD_OS_SWITCH, FACTORY_TEST_CMD_JUMP_TO_BL, FACTORY_TEST_CMD_INT_PIN, FACTORY_TEST_CMD_GET_TRANSPORT, FACTORY_TEST_CMD_CHARGING_ADC, FACTORY_TEST_CMD_RADIO_CARRIER, FACTORY_TEST_CMD_GET_BUILD_TIME, FACTORY_TEST_CMD_GET_DEVICE_ID };
enum {
P2P4G_CLEAR_PAIRING_TYPE_A = 0x01 << 0,
@ -133,14 +123,14 @@ static inline void factory_timer_check(void) {
#ifdef RGB_MATRIX_ENABLE
if (!rgb_matrix_is_enabled()) rgb_matrix_enable();
rgb_matrix_init();
#if defined(KEYCHRON_RGB_ENABLE) && defined(EECONFIG_SIZE_CUSTOM_RGB)
# if defined(KEYCHRON_RGB_ENABLE) && defined(EECONFIG_SIZE_CUSTOM_RGB)
eeconfig_reset_custom_rgb();
#endif
# endif
#endif
#ifdef LK_WIRELESS_ENABLE
#ifdef EECONFIG_SIZE_WIRELESS_CONFIG
# ifdef EECONFIG_SIZE_WIRELESS_CONFIG
wireless_config_reset();
#endif
# endif
wait_ms(50);
lkbt51_factory_reset(P2P4G_CELAR_MASK);
#endif
@ -450,10 +440,10 @@ void factory_test_rx(uint8_t *data, uint8_t length) {
case FACTORY_TEST_CMD_GET_DEVICE_ID:
payload[len++] = FACTORY_TEST_CMD_GET_DEVICE_ID;
payload[len++] = 12; // UUID length
payload[len++] = 12; // UUID length
memcpy(&payload[len], (uint32_t *)UID_BASE, 4);
memcpy(&payload[len+4], (uint32_t *)UID_BASE+4, 4);
memcpy(&payload[len+8], (uint32_t *)UID_BASE+8, 4);
memcpy(&payload[len + 4], (uint32_t *)UID_BASE + 4, 4);
memcpy(&payload[len + 8], (uint32_t *)UID_BASE + 8, 4);
len += 12;
factory_test_send(payload, len);
@ -462,14 +452,14 @@ void factory_test_rx(uint8_t *data, uint8_t length) {
}
}
bool dip_switch_update_user(uint8_t index, bool active) {
if (report_os_sw_state) {
#ifdef INVERT_OS_SWITCH_STATE
active = !active;
#endif
uint8_t payload[3] = {FACTORY_TEST_CMD_OS_SWITCH, OS_SWITCH, active};
factory_test_send(payload, 3);
}
/* bool dip_switch_update_user(uint8_t index, bool active) { */
/* if (report_os_sw_state) { */
/* #ifdef INVERT_OS_SWITCH_STATE */
/* active = !active; */
/* #endif */
/* uint8_t payload[3] = {FACTORY_TEST_CMD_OS_SWITCH, OS_SWITCH, active}; */
/* factory_test_send(payload, 3); */
/* } */
return true;
}
/* return true; */
/* } */

View File

@ -1,36 +1,36 @@
{
"usb": {
"pid": "0x0A50",
"device_version": "1.0.0"
},
"features": {
"rgb_matrix": true
},
"rgb_matrix": {
"driver": "snled27351_spi",
"sleep": true,
"animations": {
"band_spiral_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,
"jellybean_raindrops": true,
"pixel_rain": true,
"rainbow_beacon": true,
"rainbow_moving_chevron": true,
"solid_reactive_multinexus": true,
"solid_reactive_multiwide": true,
"solid_reactive_simple": true,
"solid_splash": true,
"splash": true,
"typing_heatmap": true
}
"usb": {
"pid": "0x0A50",
"device_version": "1.0.0"
},
"features": {
"rgb_matrix": true
},
"rgb_matrix": {
"driver": "snled27351_spi",
"sleep": true,
"animations": {
"band_spiral_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,
"jellybean_raindrops": true,
"pixel_rain": true,
"rainbow_beacon": true,
"rainbow_moving_chevron": true,
"solid_reactive_multinexus": true,
"solid_reactive_multiwide": true,
"solid_reactive_simple": true,
"solid_splash": true,
"splash": true,
"typing_heatmap": true
}
}
}

View File

@ -0,0 +1,23 @@
/* Copyright 2025 infraviolet
*
* 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
#define RGB_MATRIX_SLEEP
#undef RGB_MATRIX_TIMEOUT
#define RGB_MATRIX_TIMEOUT 300000
#define USER_LAYER_COUNT 3

View File

@ -0,0 +1,93 @@
/* Copyright 2025 infraviolet
*
* 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"
#include "os_detection.h"
enum layers {
LAYER_BASE,
LAYER_FN,
};
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_BASE] = LAYOUT_108_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_F13, KC_F18, KC_F14, KC_F15, KC_F16, KC_F17,
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_NUM, KC_PSLS, KC_PAST, KC_PMNS,
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_P7, KC_P8, KC_P9,
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_PPLS,
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_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI,MO(LAYER_FN),KC_RCTL,KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT, KC_PENT),
[LAYER_FN] = LAYOUT_108_ansi(
_______, KC_BRID, KC_BRIU, KC_TASK, KC_FILE, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, _______, _______, _______, _______,
_______, BT_HST1, BT_HST2, BT_HST3, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, BAT_LVL, NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
};
// clang-format on
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t mod_state = get_mods();
switch (keycode) {
case KC_SPC:
// If the keypress is space and we only have shift pressed, send KC_MINS (which when shifted gives underscore) instead of KC_SPC.
// This will allow us to still use key combos that include space _and_ shift _and_ some other modifier.
if (mod_state & MOD_MASK_SHIFT && !(mod_state & MOD_MASK_CAG)) {
if (record->event.pressed) {
register_code(KC_MINS);
} else {
unregister_code(KC_MINS);
}
return false;
}
return true;
default:
return true;
}
}
void keyboard_post_init_user(void) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING);
rgb_matrix_sethsv_noeeprom(HSV_PURPLE);
rgb_matrix_set_speed_noeeprom(32);
}
bool dip_switch_update_user(uint8_t index, bool active) {
// reuse the macos/windows toggle that we don't want to use as a keyboard backlight toggle.
if (index == 0) {
if (active) {
rgb_matrix_disable_noeeprom();
} else {
rgb_matrix_enable_noeeprom();
}
return false;
}
return true;
}
void eeconfig_init_user(void) {
// configure RGB
rgb_matrix_enable();
rgb_matrix_mode(RGB_MATRIX_BREATHING);
rgb_matrix_sethsv(HSV_PURPLE);
rgb_matrix_set_speed(32);
}

View File

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

View File

@ -37,9 +37,6 @@ pin_t p24g_led_pins[] = P24G_HOST_LED_PIN_LIST;
#endif
bool dip_switch_update_kb(uint8_t index, bool active) {
if (index == 0) {
default_layer_set(1UL << (active ? 0 : 2));
}
dip_switch_update_user(index, active);
return true;