Dual-Role HID Architecture on nRF5340: BT Central Input with Selectable USB or BT HID Output

Hi,

I'm working on a customized version of the nRF Desktop App running on an nRF5340. In my use case, I want to connect Bluetooth HID devices (mouse and keyboard) as input sources in Central role, process or modify the incoming HID reports, and then forward the data either via USB HID (as a composite mouse + keyboard device) or via Bluetooth HID (Peripheral role) to a host.

I do not want both output channels to be active simultaneously — the output should be selectable, i.e., either USB or BT HID, depending on a runtime setting.

I’ve already explored parts of the nrf Desktop App, including modules like hid_state, hid_forward, ble_scan, bt_hids, etc. However, I want to avoid using the built-in HID forwarder, which connects BT input to USB output directly. Instead, I plan to build a custom data flow where:

  • BT HID input devices (keyboard and mouse) connect as Central,

  • Their input is processed and optionally transformed,

  • The resulting reports are sent either to a USB host (via USB HID composite) or to a BT host (via HID Peripheral role), depending on a user-controlled setting.

My questions:

  1. Best practice for switchable HID output:
    What is the recommended way to cleanly implement switchable HID output between USB and BT HID, while ensuring proper init/cleanup and avoiding conflicts?

  2. Combining BT Central and BT Peripheral roles:
    Are there known limitations or pitfalls when combining Central (for input) and Peripheral (for output) roles on the nRF5340?

  3. Reusing parts of the Desktop App:
    Would you suggest reusing existing modules like hid_report, usb_hid, bt_hids, etc. and building a new glue layer for input/output control?
    Or would it be more maintainable to design a custom lightweight HID processing pipeline from scratch?

  4. Multiple BT HID input devices:
    What is the best strategy to connect and handle multiple BT HID input devices (e.g., mouse + keyboard) in parallel in Central role? Do I need to extend or modify the bt_hid_client module to support that?

I’d really appreciate your guidance and suggestions on how to get started with this Dual Role HID architecture on the nRF5340. Thank you for your support!

Best regards,

Related