This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr HID mouse and keyboard sample

I need to implement a mouse and keyboard (combo) HOG device.

There are mouse and keyboard samples, but may I integrate them in just one?

Is there any samplecode?

I have already write the reports data describing mouse and keyboard, each one with its REPORT ID, but it is not working...

Thanks in advance!

Aleks

  • Hi Aleks

    It should be possible to combine the peripheral_hids_mouse and peripheral_hids_keyboard samples into one, but it requires a bit of manual cut and paste to make it work. 

    Essentially you need to define both the mouse and keyboard in one large report map, and setup the rest of the hids init accordingly. 

    Alternatively it should be possible to configure the nrf_desktop application to run mouse and keyboard on the same device. For more information about the nrf_desktop reference design, please have a look here

    Best regards
    Torbjørn

  • Hi  Thank you for your answer! 

    I have already created a unique report map, and i  am sending the reports with different "report id" (as i defined in the map) in the first byte, but it still not works. 

    It seems the report id is being ignored.

    Do i need to do something else when i define multiple devices?

    Regards, Aleks

    ps: I am using Zephyr framework

  • Hi Aleks

    Have you made sure that all the report ID's in the report map are unique, and that the values correspond to the ones you send in the payload?

    Also, I believe the report ID has to start at 1 and increment from there, not from 0. 

    Maybe you can share the HIDS init function with me so I can have a look at it?

    Best regards
    Torbjørn

  • Hi Torbjørn

    I am working in a project a little complex and we are trying to "materialize" all the proof of concepts to be sure that the project is really feasible.  

    So, one of them, is get the composite device working. 

    I got the hog (samples/bluetooth/peripheral_hids) sample in the zephyr repository and I already had success to make it work with keyboard and mouse report maps, but only in separate. 

    The report id starts in 1.

    I am not sure if the ATT must be changed when I use both devices at the same time.

    BT_GATT_SERVICE_DEFINE(
        hog_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_HIDS),
        BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_INFO, BT_GATT_CHRC_READ,
                               BT_GATT_PERM_READ, read_info, NULL, &info),
        BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT_MAP, BT_GATT_CHRC_READ,
                               BT_GATT_PERM_READ, read_report_map, NULL, NULL),
        BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT,
                               BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY,
                               BT_GATT_PERM_READ, read_input_report, NULL, //AUTHEN
                               NULL),
        BT_GATT_CCC(input_ccc_changed,
                    BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), //AUTHEN read e write
        BT_GATT_DESCRIPTOR(BT_UUID_HIDS_REPORT_REF, BT_GATT_PERM_READ, read_report,
                           NULL, &input),
        BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_CTRL_POINT,
                               BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_WRITE,
                               NULL, write_ctrl_point, &ctrl_point),
    
    
    );

    Thank you!

  • Hi Aleks

    It shouldn't be necessary to make any changes to the way the service is put together, no. 

    Either you have to setup a single HoG service that implements both mouse and keyboard as one (using different report ID's and a combined report map), or you would need to configure two independent HoG services that implement mouse and keyboard separately. 

    Have you tried to combine the hid_init() function from the two examples into one?

    Best regards
    Torbjørn

Related