diff --git a/src/main/app/app_factory.c b/src/main/app/app_factory.c index 0065bba..1e8a233 100644 --- a/src/main/app/app_factory.c +++ b/src/main/app/app_factory.c @@ -495,6 +495,15 @@ static void app_mode_apply(app_mode_t new_mode, bool save_nvs) break; } + // Fix: reset modifier state and refresh LED on mode switch (avoids leaking Sym/Fn into new mode) + sym_mode = false; + sym_pressed = false; + fn_pressed = false; + caps_one_time = false; + caps_locked = false; + caps_hold = false; + app_update_led_state(); + if (save_nvs) { app_save_mode_to_nvs(g_mode); } @@ -593,7 +602,8 @@ static void app_process_key_event(key_event_t *key_event) bsp_blehid_send_keycode(0, USB_HID_KEY_ESC); } } else if (g_mode == MODE_UART) { - bsp_uart_send(&esc_char, 1); + // Fix: send framed ESC (host parser expects 5-byte KEY_ID + KEY_STATE frame) + app_send_uart_frame(KEY_ESC, true); } return; } @@ -607,6 +617,17 @@ static void app_process_key_event(key_event_t *key_event) } } + // Fix: consume caps one-shot in UART/ESP-NOW modes when an alphabetic key is pressed + // (originally only handled in I2C/BLEHID ASCII paths — see app_clear_caps_one_time call below) + if (is_press && !key_event->is_repeat && !fn_pressed && + (g_mode == MODE_UART || g_mode == MODE_ESPNOW)) { + char c = 0; + if (app_get_key_char(key_event->button_index, &c) && + ((c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A))) { + app_clear_caps_one_time(); + } + } + // 产测模式:通过 UART 上报按键事件 if (g_mode == MODE_PRODTEST && (is_press || is_release)) { bsp_uart_printf("+KEY:%d,%d\r\n", key_event->button_index, key_event->event); diff --git a/src/main/app/app_factory.h b/src/main/app/app_factory.h index 92f432c..6f9cc83 100644 --- a/src/main/app/app_factory.h +++ b/src/main/app/app_factory.h @@ -26,7 +26,7 @@ extern "C" { #endif // 固件版本定义 -#define FIRMWARE_VERSION 0x01 +#define FIRMWARE_VERSION 0x02 // 键盘状态定义 typedef struct {