e056a113a2
- 将发送 HID 按键的逻辑提取到 send_hid_combo_or_warn 函数中 - 更新 on_boot_press 函数以使用新的发送逻辑 - 在按钮点击事件处理函数中调用 send_hid_combo_or_warn,简化代码并增强可读性
53 lines
926 B
C
53 lines
926 B
C
#include "ui_handlers.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "ble_hid.h"
|
|
#include "boot_button.h"
|
|
#include "esp_log.h"
|
|
#include "ui_events.h"
|
|
|
|
static const char *TAG = "ui_handlers";
|
|
|
|
static void send_hid_combo_or_warn(uint8_t modifier, uint8_t keycode)
|
|
{
|
|
if (ble_hid_ready()) {
|
|
ble_hid_send_combo(modifier, keycode);
|
|
} else {
|
|
ESP_LOGW(TAG, "HID not ready");
|
|
}
|
|
}
|
|
|
|
static void on_boot_press(void)
|
|
{
|
|
send_hid_combo_or_warn(0, HID_KEY_C);
|
|
}
|
|
|
|
void ui_handlers_init(void)
|
|
{
|
|
boot_button_init(on_boot_press);
|
|
}
|
|
|
|
void update_year_action(lv_event_t * e)
|
|
{
|
|
(void)e;
|
|
}
|
|
|
|
void click_button_two(lv_event_t * e)
|
|
{
|
|
(void)e;
|
|
send_hid_combo_or_warn(HID_MOD_LCTRL, HID_KEY_C);
|
|
}
|
|
|
|
void click_button_three(lv_event_t * e)
|
|
{
|
|
(void)e;
|
|
send_hid_combo_or_warn(HID_MOD_LCTRL, HID_KEY_V);
|
|
}
|
|
|
|
void click_button_one(lv_event_t * e)
|
|
{
|
|
(void)e;
|
|
send_hid_combo_or_warn(HID_MOD_LCTRL, HID_KEY_X);
|
|
}
|