@@ -71,6 +71,7 @@ struct input_listener_processor_data {
71
71
};
72
72
73
73
struct input_listener_config {
74
+ uint8_t listener_index ;
74
75
struct input_listener_config_entry base ;
75
76
size_t layer_overrides_len ;
76
77
struct input_listener_layer_override layer_overrides [];
@@ -152,9 +153,9 @@ static inline bool is_y_data(const struct input_event *evt) {
152
153
return evt -> type == INPUT_EV_REL && evt -> code == INPUT_REL_Y ;
153
154
}
154
155
155
- static void apply_config (const struct input_listener_config_entry * cfg ,
156
- struct input_listener_processor_data * processor_data ,
157
- struct input_listener_data * data , struct input_event * evt ) {
156
+ static int apply_config (uint8_t listener_index , const struct input_listener_config_entry * cfg ,
157
+ struct input_listener_processor_data * processor_data ,
158
+ struct input_listener_data * data , struct input_event * evt ) {
158
159
size_t remainder_index = 0 ;
159
160
for (size_t p = 0 ; p < cfg -> processors_len ; p ++ ) {
160
161
const struct zmk_input_processor_entry * proc_e = & cfg -> processors [p ];
@@ -183,15 +184,27 @@ static void apply_config(const struct input_listener_config_entry *cfg,
183
184
}
184
185
}
185
186
186
- struct zmk_input_processor_state state = {.remainder = remainder };
187
-
188
- zmk_input_processor_handle_event (proc_e -> dev , evt , proc_e -> param1 , proc_e -> param2 , & state );
187
+ LOG_DBG ("LISTENER INDEX: %d" , listener_index );
188
+ struct zmk_input_processor_state state = {.input_device_index = listener_index ,
189
+ .remainder = remainder };
190
+
191
+ int ret = zmk_input_processor_handle_event (proc_e -> dev , evt , proc_e -> param1 , proc_e -> param2 ,
192
+ & state );
193
+ switch (ret ) {
194
+ case ZMK_INPUT_PROC_CONTINUE :
195
+ continue ;
196
+ default :
197
+ return ret ;
198
+ }
189
199
}
200
+
201
+ return ZMK_INPUT_PROC_CONTINUE ;
190
202
}
191
- static void filter_with_input_config (const struct input_listener_config * cfg ,
192
- struct input_listener_data * data , struct input_event * evt ) {
203
+
204
+ static int filter_with_input_config (const struct input_listener_config * cfg ,
205
+ struct input_listener_data * data , struct input_event * evt ) {
193
206
if (!evt -> dev ) {
194
- return ;
207
+ return - ENODEV ;
195
208
}
196
209
197
210
for (size_t oi = 0 ; oi < cfg -> layer_overrides_len ; oi ++ ) {
@@ -201,9 +214,14 @@ static void filter_with_input_config(const struct input_listener_config *cfg,
201
214
uint8_t layer = 0 ;
202
215
while (mask != 0 ) {
203
216
if (mask & BIT (0 ) && zmk_keymap_layer_active (layer )) {
204
- apply_config (& override -> config , override_data , data , evt );
217
+ int ret =
218
+ apply_config (cfg -> listener_index , & override -> config , override_data , data , evt );
219
+
220
+ if (ret < 0 ) {
221
+ return ret ;
222
+ }
205
223
if (!override -> process_next ) {
206
- return ;
224
+ return 0 ;
207
225
}
208
226
}
209
227
@@ -212,7 +230,7 @@ static void filter_with_input_config(const struct input_listener_config *cfg,
212
230
}
213
231
}
214
232
215
- apply_config (& cfg -> base , & data -> base_processor_data , data , evt );
233
+ return apply_config (cfg -> listener_index , & cfg -> base , & data -> base_processor_data , data , evt );
216
234
}
217
235
218
236
static void clear_xy_data (struct input_listener_xy_data * data ) {
@@ -247,8 +265,15 @@ static void apply_resolution_scaling(struct input_listener_data *data, struct in
247
265
248
266
static void input_handler (const struct input_listener_config * config ,
249
267
struct input_listener_data * data , struct input_event * evt ) {
250
- // First, filter to update the event data as needed.
251
- filter_with_input_config (config , data , evt );
268
+ // First, process to update the event data as needed.
269
+ int ret = filter_with_input_config (config , data , evt );
270
+
271
+ if (ret < 0 ) {
272
+ LOG_ERR ("Error applying input processors: %d" , ret );
273
+ return ;
274
+ } else if (ret == ZMK_INPUT_PROC_STOP ) {
275
+ return ;
276
+ }
252
277
253
278
#if IS_ENABLED (CONFIG_ZMK_POINTING_SMOOTH_SCROLLING )
254
279
apply_resolution_scaling (data , evt );
@@ -355,6 +380,7 @@ static void input_handler(const struct input_listener_config *config,
355
380
DT_INST_FOREACH_CHILD_VARGS(n, CHILD_CONFIG, \
356
381
n) static const struct input_listener_config config_##n = \
357
382
{ \
383
+ .listener_index = n, \
358
384
.base = IL_EXTRACT_CONFIG(DT_DRV_INST(n), n, base), \
359
385
.layer_overrides_len = (0 DT_INST_FOREACH_CHILD(n, IL_ONE)), \
360
386
.layer_overrides = {DT_INST_FOREACH_CHILD_SEP_VARGS(n, IL_OVERRIDE, (, ), n)}, \
0 commit comments