Composite keyboard+mouse BLE HID device on Zephyr

Hi guys,

I want to make a composite Bluetooth HID device that functions as a keyboard and mouse with the nRF Connect SDK. I've combined the nrf/samples/bluetooth/peripheral_hids_keyboard and nrf/samples/bluetooth/peripheral_hids_mouse samples, but I can't make them work together.

I use two hids_init_obj objects, one for the keyboard and the other for the mouse. I call bt_hids_init() on both objects, and send the reports using bt_hids_inp_rep_send().

Unfortunately, either the keyboard or the mouse function works, but not both. Precisely, if I call bt_hids_init() on the keyboard hids_obj first and on the mouse hids_obj the second, then only the keyboard works and vice versa.

When calling bt_hids_inp_rep_send() on the hids_obj object that doesn't work, it returns -13 which translates to EACCESS.

Any help would be greatly appreciated.

Parents
  • Hello,

    I understand the question. It is far from straight forward to work with the USB report maps.

    Unfortunately, I am not aware of any good tutorials/descriptions of USB reports provided by Nordic, but I have found a few good blog posts when googling "USB report map".

    Try doing that, and see if you can create a report map that covers both Keyboard and Mouse. I think the trick here is to generate a report map that covers both a keyboard and a map, and then you should be able to use both the mouse and keyboard API from the samples.

    Best regards,

    Edvin

  • Thanks for your help, Edvin!

    That was my guess. So am I correct that the API only supports a single bt_hids_init() call, so I should use not two but a single hids_obj with the reports combined from both the keyboard and mouse objects?

  • That is correct. The HID over BLE is "simply" that the USB report maps is sent over BLE instead of the USB cable. However, there is only one USB report, and it must include all the devices you want to use (mouse and keyboard).

    BR,
    Edvin

Reply Children
Related