refactor: Move to zmk_hid_indicators_t
type.
This commit is contained in:
parent
d9bb0d7d0e
commit
817ce8764f
7 changed files with 18 additions and 18 deletions
|
@ -10,7 +10,7 @@
|
|||
#include <zmk/event_manager.h>
|
||||
|
||||
struct zmk_hid_indicators_changed {
|
||||
zmk_hid_indicators indicators;
|
||||
zmk_hid_indicators_t indicators;
|
||||
};
|
||||
|
||||
ZMK_EVENT_DECLARE(zmk_hid_indicators_changed);
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include <zmk/hid.h>
|
||||
#include <zmk/hid_indicators_types.h>
|
||||
|
||||
zmk_hid_indicators zmk_hid_indicators_get_current_profile(void);
|
||||
zmk_hid_indicators zmk_hid_indicators_get_profile(struct zmk_endpoint_instance endpoint);
|
||||
void zmk_hid_indicators_set_profile(zmk_hid_indicators indicators,
|
||||
zmk_hid_indicators_t zmk_hid_indicators_get_current_profile(void);
|
||||
zmk_hid_indicators_t zmk_hid_indicators_get_profile(struct zmk_endpoint_instance endpoint);
|
||||
void zmk_hid_indicators_set_profile(zmk_hid_indicators_t indicators,
|
||||
struct zmk_endpoint_instance endpoint);
|
||||
|
||||
void zmk_hid_indicators_process_report(struct zmk_hid_led_report_body *report,
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
typedef uint8_t zmk_hid_indicators;
|
||||
typedef uint8_t zmk_hid_indicators_t;
|
||||
|
|
|
@ -13,6 +13,6 @@ int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *bi
|
|||
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
|
||||
int zmk_split_bt_update_hid_indicator(zmk_hid_indicators indicators);
|
||||
int zmk_split_bt_update_hid_indicator(zmk_hid_indicators_t indicators);
|
||||
|
||||
#endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
static zmk_hid_indicators hid_indicators[ZMK_ENDPOINT_COUNT];
|
||||
static zmk_hid_indicators_t hid_indicators[ZMK_ENDPOINT_COUNT];
|
||||
|
||||
zmk_hid_indicators zmk_hid_indicators_get_current_profile(void) {
|
||||
zmk_hid_indicators_t zmk_hid_indicators_get_current_profile(void) {
|
||||
return zmk_hid_indicators_get_profile(zmk_endpoints_selected());
|
||||
}
|
||||
|
||||
zmk_hid_indicators zmk_hid_indicators_get_profile(struct zmk_endpoint_instance endpoint) {
|
||||
int profile = zmk_endpoint_instance_to_index(endpoint);
|
||||
zmk_hid_indicators_t zmk_hid_indicators_get_profile(struct zmk_endpoint_instance endpoint) {
|
||||
const int profile = zmk_endpoint_instance_to_index(endpoint);
|
||||
return hid_indicators[profile];
|
||||
}
|
||||
|
||||
static void raise_led_changed_event(struct k_work *_work) {
|
||||
zmk_hid_indicators indicators = zmk_hid_indicators_get_current_profile();
|
||||
const zmk_hid_indicators_t indicators = zmk_hid_indicators_get_current_profile();
|
||||
|
||||
ZMK_EVENT_RAISE(new_zmk_hid_indicators_changed(
|
||||
(struct zmk_hid_indicators_changed){.indicators = indicators}));
|
||||
|
@ -40,7 +40,7 @@ static void raise_led_changed_event(struct k_work *_work) {
|
|||
|
||||
static K_WORK_DEFINE(led_changed_work, raise_led_changed_event);
|
||||
|
||||
void zmk_hid_indicators_set_profile(zmk_hid_indicators indicators,
|
||||
void zmk_hid_indicators_set_profile(zmk_hid_indicators_t indicators,
|
||||
struct zmk_endpoint_instance endpoint) {
|
||||
int profile = zmk_endpoint_instance_to_index(endpoint);
|
||||
|
||||
|
@ -54,7 +54,7 @@ void zmk_hid_indicators_set_profile(zmk_hid_indicators indicators,
|
|||
|
||||
void zmk_hid_indicators_process_report(struct zmk_hid_led_report_body *report,
|
||||
struct zmk_endpoint_instance endpoint) {
|
||||
uint8_t indicators = report->leds;
|
||||
const zmk_hid_indicators_t indicators = (zmk_hid_indicators_t)report->leds;
|
||||
zmk_hid_indicators_set_profile(indicators, endpoint);
|
||||
|
||||
LOG_DBG("Update HID indicators: endpoint=%d, indicators=%x", endpoint.transport, indicators);
|
||||
|
|
|
@ -704,10 +704,10 @@ int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *bi
|
|||
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
|
||||
static zmk_hid_indicators hid_indicators = 0;
|
||||
static zmk_hid_indicators_t hid_indicators = 0;
|
||||
|
||||
static void split_central_update_indicators_callback(struct k_work *work) {
|
||||
zmk_hid_indicators indicators = hid_indicators;
|
||||
zmk_hid_indicators_t indicators = hid_indicators;
|
||||
for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) {
|
||||
if (peripherals[i].state != PERIPHERAL_SLOT_STATE_CONNECTED) {
|
||||
continue;
|
||||
|
@ -732,7 +732,7 @@ static void split_central_update_indicators_callback(struct k_work *work) {
|
|||
|
||||
static K_WORK_DEFINE(split_central_update_indicators, split_central_update_indicators_callback);
|
||||
|
||||
int zmk_split_bt_update_hid_indicator(zmk_hid_indicators indicators) {
|
||||
int zmk_split_bt_update_hid_indicator(zmk_hid_indicators_t indicators) {
|
||||
hid_indicators = indicators;
|
||||
return k_work_submit_to_queue(&split_central_split_run_q, &split_central_update_indicators);
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, uint16_t va
|
|||
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
|
||||
static zmk_hid_indicators hid_indicators = 0;
|
||||
static zmk_hid_indicators_t hid_indicators = 0;
|
||||
|
||||
static void split_svc_update_indicators_callback(struct k_work *work) {
|
||||
LOG_DBG("Raising HID indicators changed event: %x", hid_indicators);
|
||||
|
@ -125,7 +125,7 @@ static K_WORK_DEFINE(split_svc_update_indicators_work, split_svc_update_indicato
|
|||
static ssize_t split_svc_update_indicators(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
const void *buf, uint16_t len, uint16_t offset,
|
||||
uint8_t flags) {
|
||||
if (offset + len > sizeof(zmk_hid_indicators)) {
|
||||
if (offset + len > sizeof(zmk_hid_indicators_t)) {
|
||||
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue