mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-27 11:06:37 +06:00
Update q9
This commit is contained in:
parent
70eceff30c
commit
8c5b31a68c
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* USB Device descriptor parameter */
|
||||
#define PRODUCT_ID 0x0190
|
||||
#define DEVICE_VER 0x0101
|
||||
#define DEVICE_VER 0x0102
|
||||
|
||||
/* RGB Matrix Configuration */
|
||||
#define DRIVER_1_LED_TOTAL 52
|
||||
|
|
|
@ -85,11 +85,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||
};
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
/* Set timers for factory reset and backlight test */
|
||||
timer_task_start();
|
||||
}
|
||||
|
||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||
/* Send default layer state to host */
|
||||
system_switch_state_report(index, active);
|
||||
|
@ -97,7 +92,6 @@ bool dip_switch_update_user(uint8_t index, bool active) {
|
|||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
process_other_record(keycode, record);
|
||||
switch (keycode) {
|
||||
case KC_MCTL:
|
||||
if (record->event.pressed) {
|
||||
|
|
|
@ -85,11 +85,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||
};
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
/* Set timers for factory reset and backlight test */
|
||||
timer_task_start();
|
||||
}
|
||||
|
||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||
/* Send default layer state to host */
|
||||
system_switch_state_report(index, active);
|
||||
|
@ -97,7 +92,6 @@ bool dip_switch_update_user(uint8_t index, bool active) {
|
|||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
process_other_record(keycode, record);
|
||||
switch (keycode) {
|
||||
case KC_MCTL:
|
||||
if (record->event.pressed) {
|
||||
|
|
|
@ -102,7 +102,7 @@ led_config_t g_led_config = {
|
|||
{
|
||||
// RGB LED Index to Flag
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
|
||||
9, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 1, 1, 4, 1, 1, 1, 1, 1, 1,
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* USB Device descriptor parameter */
|
||||
#define PRODUCT_ID 0x0191
|
||||
#define DEVICE_VER 0x0101
|
||||
#define DEVICE_VER 0x0102
|
||||
|
||||
/* RGB Matrix Configuration */
|
||||
#define DRIVER_1_LED_TOTAL 52
|
||||
|
|
|
@ -85,11 +85,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||
};
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
/* Set timers for factory reset and backlight test */
|
||||
timer_task_start();
|
||||
}
|
||||
|
||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||
/* Send default layer state to host */
|
||||
system_switch_state_report(index, active);
|
||||
|
@ -97,7 +92,6 @@ bool dip_switch_update_user(uint8_t index, bool active) {
|
|||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
process_other_record(keycode, record);
|
||||
switch (keycode) {
|
||||
case KC_MCTL:
|
||||
if (record->event.pressed) {
|
||||
|
|
|
@ -52,7 +52,7 @@ key_combination_t key_comb_list[2] = {
|
|||
};
|
||||
|
||||
static uint8_t mac_keycode[4] = { KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD };
|
||||
|
||||
// clang-format off
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[MAC_BASE] = LAYOUT_all(
|
||||
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_VOLD, KC_MUTE, KC_VOLU,
|
||||
|
@ -84,7 +84,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||
};
|
||||
|
||||
//clang-format on
|
||||
#if defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
|
||||
|
||||
#define ENCODERS 1
|
||||
|
@ -108,6 +108,10 @@ void encoder_action_register(uint8_t index, bool clockwise) {
|
|||
action_exec(encoder_event);
|
||||
}
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
encoder_action_unregister();
|
||||
}
|
||||
|
||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||
encoder_action_register(index, clockwise);
|
||||
return false;
|
||||
|
@ -115,14 +119,6 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
|||
|
||||
#endif
|
||||
|
||||
void matrix_scan_user(void) {
|
||||
#if defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
|
||||
encoder_action_unregister();
|
||||
#endif
|
||||
/* Set timers for factory reset and backlight test */
|
||||
timer_task_start();
|
||||
}
|
||||
|
||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||
/* Send default layer state to host */
|
||||
system_switch_state_report(index, active);
|
||||
|
@ -130,7 +126,6 @@ bool dip_switch_update_user(uint8_t index, bool active) {
|
|||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
process_other_record(keycode, record);
|
||||
switch (keycode) {
|
||||
case KC_MCTL:
|
||||
if (record->event.pressed) {
|
||||
|
|
|
@ -102,7 +102,7 @@ led_config_t g_led_config = {
|
|||
{
|
||||
// RGB LED Index to Flag
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
|
||||
9, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
}
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
#define MAC_FN 2
|
||||
#define WIN_FN 3
|
||||
|
||||
static void timer_3000ms_task(void);
|
||||
static void timer_250ms_task(void);
|
||||
static void factory_test_send(uint8_t *payload, uint8_t length);
|
||||
static void timer_3s_task(void);
|
||||
static void timer_300ms_task(void);
|
||||
|
||||
#define KEY_PRESS_FN (0x1<<0)
|
||||
#define KEY_PRESS_J (0x1<<1)
|
||||
|
@ -51,12 +50,12 @@ enum {
|
|||
};
|
||||
|
||||
uint16_t key_press_status = 0;
|
||||
uint32_t timer_3000ms_buffer = 0;
|
||||
uint32_t timer_250ms_buffer = 0;
|
||||
uint32_t timer_3s_buffer = 0;
|
||||
uint32_t timer_300ms_buffer = 0;
|
||||
uint8_t factory_reset_count = 0;
|
||||
bool report_os_sw_state = false;
|
||||
|
||||
void process_other_record(uint16_t keycode, keyrecord_t *record) {
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case MO(MAC_FN):
|
||||
case MO(WIN_FN):
|
||||
|
@ -64,31 +63,31 @@ void process_other_record(uint16_t keycode, keyrecord_t *record) {
|
|||
key_press_status |= KEY_PRESS_FN;
|
||||
} else {
|
||||
key_press_status &= ~KEY_PRESS_FN;
|
||||
timer_3000ms_buffer = 0;
|
||||
timer_3s_buffer = 0;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
case KC_J:
|
||||
if (record->event.pressed) {
|
||||
key_press_status |= KEY_PRESS_J;
|
||||
if (key_press_status == KEY_PRESS_FACTORY_RESET) {
|
||||
timer_3000ms_buffer = sync_timer_read32() | 1;
|
||||
timer_3s_buffer = sync_timer_read32() | 1;
|
||||
}
|
||||
} else {
|
||||
key_press_status &= ~KEY_PRESS_J;
|
||||
timer_3000ms_buffer = 0;
|
||||
timer_3s_buffer = 0;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
case RGB_RMOD:
|
||||
if (record->event.pressed) {
|
||||
key_press_status |= KEY_PRESS_Z;
|
||||
if (key_press_status == KEY_PRESS_FACTORY_RESET) {
|
||||
timer_3000ms_buffer = sync_timer_read32() | 1;
|
||||
timer_3s_buffer = sync_timer_read32() | 1;
|
||||
}
|
||||
} else {
|
||||
key_press_status &= ~KEY_PRESS_Z;
|
||||
timer_3000ms_buffer = 0;
|
||||
timer_3s_buffer = 0;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
case KC_RGHT:
|
||||
if (record->event.pressed) {
|
||||
key_press_status |= KEY_PRESS_RIGHT;
|
||||
|
@ -97,46 +96,52 @@ void process_other_record(uint16_t keycode, keyrecord_t *record) {
|
|||
led_test_mode = LED_TEST_MODE_WHITE;
|
||||
}
|
||||
} else if (key_press_status == KEY_PRESS_LED_TEST) {
|
||||
timer_3000ms_buffer = sync_timer_read32() | 1;
|
||||
timer_3s_buffer = sync_timer_read32() | 1;
|
||||
}
|
||||
} else {
|
||||
key_press_status &= ~KEY_PRESS_RIGHT;
|
||||
timer_3000ms_buffer = 0;
|
||||
timer_3s_buffer = 0;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
case KC_HOME:
|
||||
if (record->event.pressed) {
|
||||
key_press_status |= KEY_PRESS_HOME;
|
||||
if (led_test_mode) {
|
||||
led_test_mode = LED_TEST_MODE_OFF;
|
||||
} else if (key_press_status == KEY_PRESS_LED_TEST) {
|
||||
timer_3000ms_buffer = sync_timer_read32() | 1;
|
||||
timer_3s_buffer = sync_timer_read32() | 1;
|
||||
}
|
||||
} else {
|
||||
key_press_status &= ~KEY_PRESS_HOME;
|
||||
timer_3000ms_buffer = 0;
|
||||
timer_3s_buffer = 0;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
default:
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
}
|
||||
|
||||
void timer_task_start(void) {
|
||||
if (timer_3000ms_buffer) {
|
||||
timer_3000ms_task();
|
||||
} else if (timer_250ms_buffer) {
|
||||
timer_250ms_task();
|
||||
void matrix_scan_kb(void) {
|
||||
if (timer_3s_buffer) {
|
||||
timer_3s_task();
|
||||
}
|
||||
if (timer_300ms_buffer) {
|
||||
timer_300ms_task();
|
||||
}
|
||||
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
static void timer_3000ms_task(void) {
|
||||
if (sync_timer_elapsed32(timer_3000ms_buffer) > 3000) {
|
||||
timer_3000ms_buffer = 0;
|
||||
static void timer_3s_task(void) {
|
||||
if (sync_timer_elapsed32(timer_3s_buffer) > 3000) {
|
||||
timer_3s_buffer = 0;
|
||||
if (key_press_status == KEY_PRESS_FACTORY_RESET) {
|
||||
timer_250ms_buffer = sync_timer_read32() | 1;
|
||||
timer_300ms_buffer = sync_timer_read32() | 1;
|
||||
factory_reset_count++;
|
||||
layer_state_t default_layer_tmp = default_layer_state;
|
||||
eeconfig_init();
|
||||
default_layer_set(default_layer_tmp);
|
||||
led_test_mode = LED_TEST_MODE_OFF;
|
||||
#ifdef LED_MATRIX_ENABLE
|
||||
if (!led_matrix_is_enabled()) led_matrix_enable();
|
||||
led_matrix_init();
|
||||
|
@ -159,13 +164,13 @@ static void timer_3000ms_task(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void timer_250ms_task(void) {
|
||||
if (timer_250ms_buffer && sync_timer_elapsed32(timer_250ms_buffer) > 250) {
|
||||
static void timer_300ms_task(void) {
|
||||
if (timer_300ms_buffer && sync_timer_elapsed32(timer_300ms_buffer) > 300) {
|
||||
if (factory_reset_count++ > 6) {
|
||||
timer_250ms_buffer = 0;
|
||||
timer_300ms_buffer = 0;
|
||||
factory_reset_count = 0;
|
||||
} else {
|
||||
timer_250ms_buffer = sync_timer_read32() | 1;
|
||||
timer_300ms_buffer = sync_timer_read32() | 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,13 +237,13 @@ void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
|
|||
switch (data[1]) {
|
||||
case FACTORY_TEST_CMD_BACKLIGHT:
|
||||
led_test_mode = data[2];
|
||||
timer_3000ms_buffer = 0;
|
||||
timer_3s_buffer = 0;
|
||||
break;
|
||||
case FACTORY_TEST_CMD_OS_SWITCH:
|
||||
report_os_sw_state = data[2];
|
||||
if (report_os_sw_state) {
|
||||
// dip_switch_read(true);
|
||||
}
|
||||
// if (report_os_sw_state) {
|
||||
// dip_switch_read(true);
|
||||
// }
|
||||
break;
|
||||
case FACTORY_TEST_CMD_JUMP_TO_BL:
|
||||
if (memcmp(&data[2], "JumpToBootloader", strlen("JumpToBootloader")) == 0)
|
||||
|
@ -248,25 +253,23 @@ void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
|
|||
}
|
||||
}
|
||||
|
||||
static void factory_test_send(uint8_t *payload, uint8_t length) {
|
||||
void system_switch_state_report(uint8_t index, bool active) {
|
||||
uint16_t checksum = 0;
|
||||
uint8_t data[RAW_EPSIZE] = {0};
|
||||
uint8_t i = 0;
|
||||
data[i++] = 0xAB;
|
||||
memcpy(&data[i], payload, length);
|
||||
i += length;
|
||||
for (uint8_t i=1; i<RAW_EPSIZE-3; i++ ) {
|
||||
checksum += data[i];
|
||||
}
|
||||
data[RAW_EPSIZE-2] = checksum & 0xFF;
|
||||
data[RAW_EPSIZE-1] = (checksum >> 8) & 0xFF;
|
||||
raw_hid_send(data, RAW_EPSIZE);
|
||||
}
|
||||
uint8_t payload[3] = { 0 };
|
||||
|
||||
void system_switch_state_report(uint8_t index, bool active) {
|
||||
if (report_os_sw_state) {
|
||||
uint8_t payload[3] = {FACTORY_TEST_CMD_OS_SWITCH, OS_SWITCH, active};
|
||||
factory_test_send(payload, 3);
|
||||
payload[0] = FACTORY_TEST_CMD_OS_SWITCH;
|
||||
payload[1] = OS_SWITCH;
|
||||
payload[2] = active;
|
||||
data[0] = 0xAB;
|
||||
memcpy(&data[1], payload, 3);
|
||||
for (uint8_t i=1; i<RAW_EPSIZE-3; i++ ) {
|
||||
checksum += data[i];
|
||||
}
|
||||
data[RAW_EPSIZE-2] = checksum & 0xFF;
|
||||
data[RAW_EPSIZE-1] = (checksum >> 8) & 0xFF;
|
||||
raw_hid_send(data, RAW_EPSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#include "quantum.h"
|
||||
#include "raw_hid.h"
|
||||
|
||||
void process_other_record(uint16_t keycode, keyrecord_t *record);
|
||||
void timer_task_start(void);
|
||||
void system_switch_state_report(uint8_t index, bool active);
|
||||
|
||||
#endif /* _TEST_H_ */
|
||||
|
|
Loading…
Reference in New Issue
Block a user