diff --git a/app/include/zmk/split/bluetooth/central.h b/app/include/zmk/split/bluetooth/central.h index 07240860..f5500b05 100644 --- a/app/include/zmk/split/bluetooth/central.h +++ b/app/include/zmk/split/bluetooth/central.h @@ -5,4 +5,6 @@ #include int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *binding, - struct zmk_behavior_binding_event event, bool state); \ No newline at end of file + struct zmk_behavior_binding_event event, bool state); + +int zmk_run_behavior(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event,bool pressed); \ No newline at end of file diff --git a/app/src/behavior_queue.c b/app/src/behavior_queue.c index ab6a219b..5eb5541c 100644 --- a/app/src/behavior_queue.c +++ b/app/src/behavior_queue.c @@ -37,13 +37,11 @@ static void behavior_queue_process_next(struct k_work *work) { .timestamp = k_uptime_get()}; if (item.press) { - if(strncmp(item.binding.behavior_dev,"RGB_UG",6)==0){ - LOG_DBG("RGB_COLOR_HSB_CMD sending binding to peripheral"); - zmk_split_bt_invoke_behavior(0, &item.binding, event, true); - } - behavior_keymap_binding_pressed(&item.binding, event); + zmk_run_behavior(&item.binding, event,true) +// behavior_keymap_binding_pressed(&item.binding, event); } else { - behavior_keymap_binding_released(&item.binding, event); + zmk_run_behavior(&item.binding, event,false) + // behavior_keymap_binding_released(&item.binding, event); } LOG_DBG("Processing next queued behavior in %dms", item.wait); diff --git a/app/src/keymap.c b/app/src/keymap.c index 439e5652..75c88b9c 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -182,7 +182,10 @@ int zmk_keymap_apply_position_state(uint8_t source, int layer, uint32_t position LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding.behavior_dev)); + return zmk_run_behavior(&binding,event,pressed); +} +int zmk_run_behavior(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event,bool pressed){ behavior = device_get_binding(binding.behavior_dev); @@ -198,29 +201,16 @@ int zmk_keymap_apply_position_state(uint8_t source, int layer, uint32_t position } enum behavior_locality locality = BEHAVIOR_LOCALITY_CENTRAL; - - - err = behavior_get_locality(behavior, &locality); if (err) { LOG_ERR("Failed to get behavior locality %d", err); return err; - }else{ - LOG_DBG("got locality: BEHAVIOR_LOCALITY_CENTRAL from behavior"); } - if (strncmp(binding.behavior_dev, "layer", 5) == 0) { - locality = BEHAVIOR_LOCALITY_GLOBAL; - LOG_DBG("force locality: BEHAVIOR_LOCALITY_GLOBAL because of a 'layer' behavior"); - } - - switch (locality) { case BEHAVIOR_LOCALITY_CENTRAL: - LOG_DBG("locality is: BEHAVIOR_LOCALITY_CENTRAL"); return invoke_locally(&binding, event, pressed); case BEHAVIOR_LOCALITY_EVENT_SOURCE: - LOG_DBG("locality is: BEHAVIOR_LOCALITY_EVENT_SOURCE"); #if ZMK_BLE_IS_CENTRAL if (source == ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL) { return invoke_locally(&binding, event, pressed); @@ -231,14 +221,10 @@ int zmk_keymap_apply_position_state(uint8_t source, int layer, uint32_t position return invoke_locally(&binding, event, pressed); #endif case BEHAVIOR_LOCALITY_GLOBAL: - LOG_DBG("locality is: BEHAVIOR_LOCALITY_GLOBAL - Invoking %s", log_strdup(binding.behavior_dev)); #if ZMK_BLE_IS_CENTRAL - LOG_DBG("BEHAVIOR_LOCALITY_GLOBAL is central, calling binding on the peripheral..."); for (int i = 0; i < ZMK_BLE_SPLIT_PERIPHERAL_COUNT; i++) { zmk_split_bt_invoke_behavior(i, &binding, event, pressed); } -#else - LOG_DBG("BEHAVIOR_LOCALITY_GLOBAL is peripheral"); #endif return invoke_locally(&binding, event, pressed); }