feat(events): 添加事件提交函数到各个头文件中
为多个事件头文件添加了静态内联提交函数,包括: - bat_state_event: 添加submit_bat_state_event函数 - ble_serial_rx_event: 添加submit_ble_serial_rx_event函数 - ble_serial_tx_event: 添加submit_ble_serial_tx_event函数 - cdc_proto_tx_event: 添加submit_cdc_proto_tx_event函数 - datetime_event: 添加submit_datetime_event函数 - encoder_event: 添加submit_encoder_event函数 - function_bitmap_update_event: 添加submit_function_bitmap_update_event函数 - hid_led_event: 添加submit_hid_led_event函数 - hid_report_sent_event: 添加submit_hid_report_sent_event函数 - hid_transport_state_event: 添加submit_hid_transport_state_event函数 - hid_tx_report_event: 添加submit_hid_tx_report_event函数 - key_function_event: 添加submit_key_function_event函数 - keyboard_hid_report_event: 添加submit_keyboard_hid_report_event函数 - led_strip_en_event: 添加submit_led_strip_en_event函数 - mode_switch_event: 添加submit_mode_switch_event函数 - set_protocol_event: 添加submit_set_protocol_event函数 - theme_rgb_update_event: 添加submit_theme_rgb_update_event函数 - time_sync_event: 添加submit_time_sync_event函数 - usb_cdc_rx_event: 添加submit_usb_cdc_rx_event函数 - usb_cdc_tx_event: 添加submit_usb_cdc_tx_event函数 - usb_device_state_event: 添加submit_usb_device_state_event函数 - usb_function_ready_event: 添加submit_usb_function_ready_event函数 - usb_prepare_event: 添加submit_usb_prepare_event函数 这些函数提供了一致的事件提交接口,简化了事件创建和提交过程。
This commit is contained in:
@@ -274,32 +274,6 @@ static void build_consumer_report(uint8_t report[KEYBOARD_CONSUMER_REPORT_SIZE])
|
||||
sys_put_le16(active_consumer_usage_get(), report);
|
||||
}
|
||||
|
||||
static void submit_keyboard_report_event(enum keyboard_report_type report_type,
|
||||
enum hid_queue_policy queue_policy,
|
||||
const uint8_t *data, size_t size)
|
||||
{
|
||||
struct keyboard_hid_report_event *event =
|
||||
new_keyboard_hid_report_event(size);
|
||||
enum keyboard_protocol_mode protocol_mode = active_protocol_mode_get();
|
||||
|
||||
event->mode = current_mode;
|
||||
event->report_type = report_type;
|
||||
event->protocol_mode = protocol_mode;
|
||||
event->queue_policy = queue_policy;
|
||||
memcpy(event->dyndata.data, data, size);
|
||||
|
||||
APP_EVENT_SUBMIT(event);
|
||||
}
|
||||
|
||||
static void submit_key_function_event(uint16_t usage_id, uint8_t action)
|
||||
{
|
||||
struct key_function_event *event = new_key_function_event();
|
||||
|
||||
event->usage = usage_id;
|
||||
event->action = action;
|
||||
APP_EVENT_SUBMIT(event);
|
||||
}
|
||||
|
||||
static void submit_consumer_fifo_frame(uint16_t usage_id)
|
||||
{
|
||||
uint8_t report_buf[KEYBOARD_CONSUMER_REPORT_SIZE];
|
||||
@@ -311,10 +285,9 @@ static void submit_consumer_fifo_frame(uint16_t usage_id)
|
||||
}
|
||||
|
||||
sys_put_le16(usage_id, report_buf);
|
||||
submit_keyboard_report_event(KEYBOARD_REPORT_TYPE_CONSUMER,
|
||||
HID_QUEUE_POLICY_FIFO,
|
||||
report_buf,
|
||||
KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
(void)submit_keyboard_hid_report_event(
|
||||
current_mode, KEYBOARD_REPORT_TYPE_CONSUMER, protocol_mode,
|
||||
HID_QUEUE_POLICY_FIFO, report_buf, KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
}
|
||||
|
||||
static void submit_consumer_pulse_frames(enum keyboard_consumer_control control_id,
|
||||
@@ -374,10 +347,9 @@ static void emit_keys_report(bool force)
|
||||
memcpy(cache_buf, report_buf, report_size);
|
||||
*cache_valid = true;
|
||||
|
||||
submit_keyboard_report_event(KEYBOARD_REPORT_TYPE_KEYS,
|
||||
HID_QUEUE_POLICY_LATEST,
|
||||
report_buf,
|
||||
report_size);
|
||||
(void)submit_keyboard_hid_report_event(
|
||||
current_mode, KEYBOARD_REPORT_TYPE_KEYS, protocol_mode,
|
||||
HID_QUEUE_POLICY_LATEST, report_buf, report_size);
|
||||
}
|
||||
|
||||
static void emit_consumer_report(bool force)
|
||||
@@ -399,10 +371,10 @@ static void emit_consumer_report(bool force)
|
||||
memcpy(reports_cache.consumer_report, report_buf, KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
reports_cache.consumer_valid = true;
|
||||
|
||||
submit_keyboard_report_event(KEYBOARD_REPORT_TYPE_CONSUMER,
|
||||
HID_QUEUE_POLICY_LATEST,
|
||||
report_buf,
|
||||
KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
(void)submit_keyboard_hid_report_event(
|
||||
current_mode, KEYBOARD_REPORT_TYPE_CONSUMER, protocol_mode,
|
||||
HID_QUEUE_POLICY_LATEST, report_buf,
|
||||
KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
}
|
||||
|
||||
static void emit_all_reports(bool force)
|
||||
@@ -427,7 +399,6 @@ static void emit_function_release_events(void)
|
||||
|
||||
static void emit_release_reports(enum mode_switch_mode mode)
|
||||
{
|
||||
struct keyboard_hid_report_event *event;
|
||||
uint8_t keys_report[KEYBOARD_NKRO_REPORT_SIZE] = { 0 };
|
||||
uint8_t consumer_report[KEYBOARD_CONSUMER_REPORT_SIZE] = { 0 };
|
||||
enum keyboard_protocol_mode protocol_mode = active_protocol_mode_get();
|
||||
@@ -435,21 +406,15 @@ static void emit_release_reports(enum mode_switch_mode mode)
|
||||
(protocol_mode == KEYBOARD_PROTOCOL_MODE_BOOT) ?
|
||||
KEYBOARD_BOOT_REPORT_SIZE : KEYBOARD_NKRO_REPORT_SIZE;
|
||||
|
||||
event = new_keyboard_hid_report_event(keys_report_size);
|
||||
event->mode = mode;
|
||||
event->report_type = KEYBOARD_REPORT_TYPE_KEYS;
|
||||
event->protocol_mode = protocol_mode;
|
||||
memcpy(event->dyndata.data, keys_report, keys_report_size);
|
||||
APP_EVENT_SUBMIT(event);
|
||||
(void)submit_keyboard_hid_report_event(
|
||||
mode, KEYBOARD_REPORT_TYPE_KEYS, protocol_mode,
|
||||
HID_QUEUE_POLICY_LATEST, keys_report, keys_report_size);
|
||||
|
||||
if (protocol_mode != KEYBOARD_PROTOCOL_MODE_BOOT) {
|
||||
event = new_keyboard_hid_report_event(KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
event->mode = mode;
|
||||
event->report_type = KEYBOARD_REPORT_TYPE_CONSUMER;
|
||||
event->protocol_mode = protocol_mode;
|
||||
memcpy(event->dyndata.data, consumer_report,
|
||||
KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
APP_EVENT_SUBMIT(event);
|
||||
(void)submit_keyboard_hid_report_event(
|
||||
mode, KEYBOARD_REPORT_TYPE_CONSUMER, protocol_mode,
|
||||
HID_QUEUE_POLICY_LATEST, consumer_report,
|
||||
KEYBOARD_CONSUMER_REPORT_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user