How to modify the sample code peripheral_server_hid as a mouse device?

I try to modify the sample code “peripheral_server_hid” as a mouse device.
Current HID descriptor on the sample code seems to include the mouse application,
But it only realizes keyboard application on this sample code.
It would be helpful if there is a instruction to add the mouse application into the sample code.


Hi, @shun.yang could you share your code with me and let me know your test steps to reproduce your issues? Thanks

Hi Snow

I used the original sample code ““peripheral_server_hid” of the SDK without any modification.
Just would like to know how to modify parameters that Host can recognize it as a mouse device.


Hi, @shun.yang you could try to replace the hid_report_map with below
static const uint8_t hid_report_map =
0x05,0x01, /Usage Page (Generic Desktop Controls)/
0x09,0x02, /Usage (Mouse)/
0xa1,0x01, /Collction (Application)/
0x09,0x01, /Usage (pointer)/
0xa1,0x00, /Collction (Physical)/
0x05,0x09, /Usage Page (Button)/
0x19,0x01, /Usage Minimum(1)/
0x29,0x05, /*Usage Maximum(3) */
0x15,0x00, /Logical Minimum(1)/
0x25,0x01, /Logical Maximum(1)/
0x95,0x05, /*Report Count(5) */
0x75,0x01, /Report Size(1)/
0x81,0x02, /Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)/
0x95,0x01, /Report Count(1)/
0x75,0x03, /*Report Size(3) */
0x81,0x01, /*Input (Cnst,Ary,Abs) */
0x05,0x01, /Usage Page (Generic Desktop Controls)/
0x09,0x30, /Usage(x)/
0x09,0x31, /Usage(y)/
0x16,0x00,0xF8, /Logical Minimum (-2048)/
0x26,0xFF,0x07, /Logical Maximum (2047)/
0x75,0x0C, /Report Size(12)/
0x95,0x02, /*Report Count(2) */
0x81,0x06, /Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit)/
0x09,0x38, /Usage(Wheel)/
0x15,0x81, /Logical Minimum(-127)/
0x25,0x7f, /Logical Maximum(127)/
0x75,0x08, /Report Size(8)/
0x95,0x01, /*Report Count(1) */
0x81,0x06, /Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit)/
0x05,0x0C, /*Usage Page (Consumer Devices) */
0x0A,0x38,0x02, /Usage (AC Pan)/
0x95,0x01, /*Report Count (1) */
0x75,0x08, /Report Size (8)/
0x15,0x81, /*Logical Minimum (-127) */
0x25,0x7F, /Logical Maximum (127)/
0x81,0x06, /*Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit) */
0xc0, /End Collection/
0xc0 /End Collection/

and then you can get the windows show it as mouse.