Particle Photon HID Mouse

Hello Everyone !!

I used Mouse.begin() to try out the HID mouse functionality on photon. It successfully enumerates. It registers a IN endpoint address of 0x85. Can I know where this endpoint address are mentioned in the source code ?

I tried searching for it but couldn’t find it. I would like to tweak the value so as to create a custom HID device.

You should look for the descriptors in here

and other files in that connection

I went through the file but it seems like the photon is not using these descriptors to enumerate.
For eg. the HID_IN_EP address is 0x86 but it registers as 0x85 in my system. Moreover changing values in these descriptors doesn’t seems to have any effect on the enumeration part.

If someone can replicate what i am seeing, then we may come to a conclusion.

Maybe @rickkas7 can jump in on that.
There also were other threads that asked for more USB HID support (e.g. joystick)

This is is not currently supported unless building custom system firmware and diving deep into the source code.

A design is being worked on for a new API to allow custom HID devices in user firmware, but I don’t have a schedule for which system firmware release it will be in. I think this is the issue to follow for updates:

Rick

Well, my confusion is that why the change in descriptors in ubsd_hid_core.c is not reflected on USB enumeration even though i am compiling the whole source code ?

I think it’s because platform/MCU/STM32F2xx/STM32_USB_Device_Driver/src/usbd_hid_core.c is not built. In sources.mk in that directory:

CSRC += $(TARGET_USB_FS_SRC_PATH)/usbd_core.c
CSRC += $(TARGET_USB_FS_SRC_PATH)/usbd_req.c
CSRC += $(TARGET_USB_FS_SRC_PATH)/usbd_ioreq.c

I also don’t see it in the objects directory of a build.

That is interesting !!
So, how does mouse/keyboard API get their descriptors and other configurations from ?

Hey,
Finally found the source file, they are :
platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/usbd_conf.h
platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/usbd_mhid.h
platform/MCU/STM32F2xx/SPARK_Firmware_Driver/src/usbd_mhid.c

Changing the descriptors in these files and compiling from scratch works !

2 Likes