From 747353348ecda25fd50ab47b802d1428f307fd1b Mon Sep 17 00:00:00 2001 From: lalalademaxiya1 <2831039915@qq.com> Date: Wed, 13 Sep 2023 15:42:01 +0800 Subject: Added K10_Pro and K15_Pro --- keyboards/keychron/k10_pro/k10_pro.c | 45 ++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'keyboards/keychron/k10_pro/k10_pro.c') diff --git a/keyboards/keychron/k10_pro/k10_pro.c b/keyboards/keychron/k10_pro/k10_pro.c index 8273a299cd..7f06a423c6 100644 --- a/keyboards/keychron/k10_pro/k10_pro.c +++ b/keyboards/keychron/k10_pro/k10_pro.c @@ -36,9 +36,10 @@ typedef struct PACKED { uint8_t keycode[3]; } key_combination_t; -static uint32_t power_on_indicator_timer_buffer; -static uint32_t siri_timer_buffer = 0; -static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD}; +static uint32_t factory_timer_buffer = 0; +static uint32_t power_on_indicator_timer_buffer = 0; +static uint32_t siri_timer_buffer = 0; +static uint8_t mac_keycode[4] = {KC_LOPT, KC_ROPT, KC_LCMD, KC_RCMD}; key_combination_t key_comb_list[4] = { {2, {KC_LWIN, KC_TAB}}, // Task (win) @@ -75,6 +76,20 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { static uint8_t host_idx = 0; switch (keycode) { + case KC_MICT: + if (record->event.pressed) { + register_code(KC_MISSION_CONTROL); + } else { + unregister_code(KC_MISSION_CONTROL); + } + return false; // Skip all further processing of this key + case KC_LAPA: + if (record->event.pressed) { + register_code(KC_LAUNCHPAD); + } else { + unregister_code(KC_LAUNCHPAD); + } + return false; // Skip all further processing of this key case KC_LOPTN: case KC_ROPTN: case KC_LCMMD: @@ -137,7 +152,8 @@ void keyboard_post_init_kb(void) { #ifdef KC_BLUETOOTH_ENABLE /* Currently we don't use this reset pin */ - palSetLineMode(CKBT51_RESET_PIN, PAL_MODE_UNCONNECTED); + palSetLineMode(CKBT51_RESET_PIN, PAL_MODE_OUTPUT_PUSHPULL); + palWriteLine(CKBT51_RESET_PIN, PAL_HIGH); /* IMPORTANT: DO NOT enable internal pull-up resistor * as there is an external pull-down resistor. @@ -146,19 +162,29 @@ void keyboard_post_init_kb(void) { ckbt51_init(false); bluetooth_init(); -# endif +#endif power_on_indicator_timer_buffer = sync_timer_read32() | 1; writePin(BAT_LOW_LED_PIN, BAT_LOW_LED_PIN_ON_STATE); writePin(LED_CAPS_LOCK_PIN, LED_PIN_ON_STATE); -# ifdef KC_BLUETOOTH_ENABLE +#ifdef KC_BLUETOOTH_ENABLE writePin(H3, HOST_LED_PIN_ON_STATE); -# endif +#endif keyboard_post_init_user(); } void matrix_scan_kb(void) { + if (factory_timer_buffer && timer_elapsed32(factory_timer_buffer) > 2000) { + factory_timer_buffer = 0; + if (bt_factory_reset) { + bt_factory_reset = false; + palWriteLine(CKBT51_RESET_PIN, PAL_LOW); + wait_ms(5); + palWriteLine(CKBT51_RESET_PIN, PAL_HIGH); + } + } + if (power_on_indicator_timer_buffer) { if (sync_timer_elapsed32(power_on_indicator_timer_buffer) > POWER_ON_LED_DURATION) { power_on_indicator_timer_buffer = 0; @@ -181,14 +207,13 @@ void matrix_scan_kb(void) { #ifdef FACTORY_RESET_TASK FACTORY_RESET_TASK(); -# endif +#endif matrix_scan_user(); } #ifdef KC_BLUETOOTH_ENABLE static void ckbt51_param_init(void) { /* Set bluetooth device name */ - // ckbt51_set_local_name(STR(PRODUCT)); ckbt51_set_local_name(PRODUCT); /* Set bluetooth parameters */ module_param_t param = {.event_mode = 0x02, @@ -205,8 +230,8 @@ static void ckbt51_param_init(void) { void bluetooth_enter_disconnected_kb(uint8_t host_idx) { if (bt_factory_reset) { - bt_factory_reset = false; ckbt51_param_init(); + factory_timer_buffer = timer_read32(); } /* CKBT51 bluetooth module boot time is slower, it enters disconnected after boot, so we place initialization here. */ -- cgit v1.2.3