diff --git a/app/src/keymap.c b/app/src/keymap.c index 020faf3f2be..4e17fddefe4 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -257,7 +257,11 @@ int zmk_keymap_sensor_event(uint8_t sensor_index, size_t channel_data_size, int64_t timestamp) { bool opaque_response = false; + const struct device *accepted_devices[ZMK_KEYMAP_LAYERS_LEN] = {}; + uint8_t accepted_devices_count = 0; + for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= 0; layer--) { + int ret; struct zmk_behavior_binding *binding = &zmk_sensor_keymap[layer][sensor_index]; LOG_DBG("layer: %d sensor_index: %d, binding name: %s", layer, sensor_index, @@ -275,9 +279,21 @@ int zmk_keymap_sensor_event(uint8_t sensor_index, .timestamp = timestamp, }; - int ret = behavior_sensor_keymap_binding_accept_data( - binding, event, zmk_sensors_get_config_at_index(sensor_index), channel_data_size, - channel_data); + bool already_accepted = false; + for (int j = 0; j < accepted_devices_count; j++) { + if (behavior == accepted_devices[j]) { + already_accepted = true; + break; + } + } + + if (!already_accepted) { + ret = behavior_sensor_keymap_binding_accept_data( + binding, event, zmk_sensors_get_config_at_index(sensor_index), channel_data_size, + channel_data); + + accepted_devices[accepted_devices_count++] = behavior; + } if (ret < 0) { LOG_WRN("behavior data accept for behavior %s returned an error (%d). Processing to "