refactor: Condition source props on CONFIG_ZMK_SPLIT

This commit is contained in:
Cem Aksoylar
2024-08-17 21:03:43 -07:00
committed by Pete Johanson
parent b249135742
commit fb18a4d871
11 changed files with 86 additions and 34 deletions

View File

@@ -15,7 +15,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
struct q_item {
uint32_t position;
#if IS_ENABLED(CONFIG_ZMK_SPLIT)
uint8_t source;
#endif
struct zmk_behavior_binding binding;
bool press : 1;
uint32_t wait : 31;
@@ -34,7 +36,12 @@ static void behavior_queue_process_next(struct k_work *work) {
item.binding.param2);
struct zmk_behavior_binding_event event = {
.position = item.position, .timestamp = k_uptime_get(), .source = item.source};
.position = item.position,
.timestamp = k_uptime_get(),
#if IS_ENABLED(CONFIG_ZMK_SPLIT)
.source = item.source
#endif
};
if (item.press) {
zmk_behavior_invoke_binding(&item.binding, event, true);
@@ -51,10 +58,17 @@ static void behavior_queue_process_next(struct k_work *work) {
}
}
int zmk_behavior_queue_add(uint32_t position, uint8_t source,
int zmk_behavior_queue_add(const struct zmk_behavior_binding_event *event,
const struct zmk_behavior_binding binding, bool press, uint32_t wait) {
struct q_item item = {
.press = press, .binding = binding, .wait = wait, .position = position, .source = source};
.press = press,
.binding = binding,
.wait = wait,
.position = event->position,
#if IS_ENABLED(CONFIG_ZMK_SPLIT)
.source = event->source,
#endif
};
const int ret = k_msgq_put(&zmk_behavior_queue_msgq, &item, K_NO_WAIT);
if (ret < 0) {