Page 1 of 1

Is it possiable to use hid_mouse and hid_keyboard same time?

Posted: Mon Mar 02, 2020 3:29 am
by shaoziyang
Pyboard can work as a use mouse

Code: Select all

pyb.usb_mode('VCP+HID', hid = pyb.hid_mouse)
or a use keyboard

Code: Select all

pyb.usb_mode('VCP+HID', hid = pyb.hid_keyboard)
But is it possiable to use hid_mouse and hid_keyboard same time?

Re: Is it possiable to use hid_mouse and hid_keyboard same time?

Posted: Mon Mar 02, 2020 10:28 am
by jimmo
shaoziyang wrote:
Mon Mar 02, 2020 3:29 am
But is it possiable to use hid_mouse and hid_keyboard same time?
Not currently, but this could be supported with some code changes.

Note that my understanding of how this works is that one HID interface does one function (rather than a function per endpoint on the interface). i.e. my USB keyboard that I'm typing this on has a trackpoint mouse built in, and it shows up as a single device with two HID interfaces.

So it would require adding something like pyb.usb_mode('VCP+HID+HID') (similar to how e.g. 'VCP+VCP+MSC' is supported on some board).

Re: Is it possiable to use hid_mouse and hid_keyboard same time?

Posted: Mon Mar 02, 2020 12:25 pm
by shaoziyang
In circuitpython, it use usb_hid.devices[0] for keyboard, and usb_hid.devices[1] for mouse.

Re: Is it possiable to use hid_mouse and hid_keyboard same time?

Posted: Mon Mar 02, 2020 1:06 pm
by jimmo
CircuitPython do USB very differently (right down to a different USB stack).

Re: Is it possiable to use hid_mouse and hid_keyboard same time?

Posted: Tue Mar 03, 2020 1:38 am
by shaoziyang
Hope micropython can provide a method use hid_mouse and hid_keyboard together.

Re: Is it possiable to use hid_mouse and hid_keyboard same time?

Posted: Thu Mar 05, 2020 2:06 pm
by danhalbert
CircuitPython uses a composite HID device descriptor that provides mouse, keyboard, "consumer control" (media keys like volume up/down), and a gamepad. Optionally there is a Microsoft XAC-compatible gamepad, a digitizer, "system control" (power buttons), and raw HID.

The advantage of the composite descriptor is that all the these HID descriptors only use up one USB endpoint pair. The disadvantage is that the keyboard and mouse are not "boot devices", and sodon't work with many BIOS'es.

Currently these descriptors are generated at compile-time, and can be selected via compile-time flags. We have long-term plans to allow generating the HID descriptors (and choosing USB devices in general via descriptors) at run-time in boot.py, but we're not there yet.

Further technical discussion is probably best done in a GitHub issue.