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

@@ -158,7 +158,7 @@ static void replace_params(struct behavior_macro_trigger_state *state,
state->param2_source = PARAM_SOURCE_BINDING;
}
static void queue_macro(uint32_t position, uint8_t source,
static void queue_macro(struct zmk_behavior_binding_event *event,
const struct zmk_behavior_binding bindings[],
struct behavior_macro_trigger_state state,
const struct zmk_behavior_binding *macro_binding) {
@@ -170,14 +170,14 @@ static void queue_macro(uint32_t position, uint8_t source,
switch (state.mode) {
case MACRO_MODE_TAP:
zmk_behavior_queue_add(position, source, binding, true, state.tap_ms);
zmk_behavior_queue_add(position, source, binding, false, state.wait_ms);
zmk_behavior_queue_add(event, binding, true, state.tap_ms);
zmk_behavior_queue_add(event, binding, false, state.wait_ms);
break;
case MACRO_MODE_PRESS:
zmk_behavior_queue_add(position, source, binding, true, state.wait_ms);
zmk_behavior_queue_add(event, binding, true, state.wait_ms);
break;
case MACRO_MODE_RELEASE:
zmk_behavior_queue_add(position, source, binding, false, state.wait_ms);
zmk_behavior_queue_add(event, binding, false, state.wait_ms);
break;
default:
LOG_ERR("Unknown macro mode: %d", state.mode);
@@ -198,7 +198,7 @@ static int on_macro_binding_pressed(struct zmk_behavior_binding *binding,
.start_index = 0,
.count = state->press_bindings_count};
queue_macro(event.position, event.source, cfg->bindings, trigger_state, binding);
queue_macro(&event, cfg->bindings, trigger_state, binding);
return ZMK_BEHAVIOR_OPAQUE;
}
@@ -209,7 +209,7 @@ static int on_macro_binding_released(struct zmk_behavior_binding *binding,
const struct behavior_macro_config *cfg = dev->config;
struct behavior_macro_state *state = dev->data;
queue_macro(event.position, event.source, cfg->bindings, state->release_state, binding);
queue_macro(&event, cfg->bindings, state->release_state, binding);
return ZMK_BEHAVIOR_OPAQUE;
}