emulating joystick USB-HID

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
mikhail
Posts: 3
Joined: Sat Sep 01, 2018 2:22 am

emulating joystick USB-HID

Post by mikhail » Thu Oct 31, 2019 4:59 am

Hello. I would like to make a USB joystick with pyboard. I know there are examples of using pyboard to emulate a keyboard and a mouse, but I have no clue what do I have to change in a mouse example so the connected pyboard will be recognized by the PC as a Joystick. Is it even possible with pyboard? Thank you.

User avatar
jimmo
Posts: 1027
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: emulating joystick USB-HID

Post by jimmo » Tue Nov 05, 2019 1:57 am

Hi,

I think you will need to make some changes to the firmware to support this. At first glance, I think what's needed is:

Add a hid_joystick to the pyb module (alongside hid_mouse and hid_keyboard) which can be passed to pyb.usb_mode(...hid=pyb.hid_joystick). This is defined in stm32/usb.c and added to the pyb module in modpyb.c.

Then you need to define this descriptor, similar to how pyb_usb_hid_mouse_obj and pyb_usb_hid_keyboard_obj are defined.

Then hopefully it's just a matter of figuring out the right byte sequences to send (like in the mouse and keyboard examples).

nekomatic
Posts: 19
Joined: Thu May 08, 2014 9:31 pm

Re: emulating joystick USB-HID

Post by nekomatic » Tue Nov 05, 2019 9:24 am

This page isn't about MicroPython but it seems to have information about how to select or generate the necessary descriptor.

Post Reply