USB HID / MIDI / Mass Storage as libraries

Please do not post requests
arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Wed Jan 03, 2018 6:06 pm

I added a no-wait option for output/feature host-to-device, so that the USB HID handler silently updates the output/feature buffers in the background without polling being needed to ensure that the sketch doesn't miss data.

And added a keyboardwithleds example that echoes keyboard LED status to serial.

anv
Posts: 10
Joined: Mon Dec 11, 2017 1:52 pm

Re: USB HID / USB MIDI as libraries

Post by anv » Thu Jan 04, 2018 8:40 am

arpruss wrote:
Wed Jan 03, 2018 6:06 pm
I added a no-wait option for output/feature host-to-device, so that the USB HID handler silently updates the output/feature buffers in the background without polling being needed to ensure that the sketch doesn't miss data.

And added a keyboardwithleds example that echoes keyboard LED status to serial.
Great job!

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sun Jan 07, 2018 4:17 pm

I've changed the main class from USBDevice to USBHIDDevice and its instance from USB to USBHID. I am going to try to make this the last change that breaks existing code that depends on the high level functions in the library, but it's needed to future compatibility with some non-HID devices.

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sun Jan 07, 2018 5:22 pm

I've integrated a simple xbox360 controller emulator. See the x360 example.

It's not composited with serial support, unlike the standard USBHID stuff.

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sun Jan 07, 2018 5:43 pm

I've also dumped USB MIDI into the USBHID library (which is somewhat poorly named now). See the mididemo example.

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sun Jan 07, 2018 6:47 pm

And I just tried serial/HID composite on a Win 8.1 machine. With the Maple serial driver installed, HID doesn't work. Without the Maple serial driver, serial doesn't work. :-(

I also added a setSerial() method that lets you turn off the CompositeSerial support, which might be useful for OSes like Win 8.1. Just call USBHID.setSerial(0) before USBHID.begin().

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sat Jan 20, 2018 3:31 am

Added boot keyboard support. See the BootKeyboard example.

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sun Jan 21, 2018 3:12 pm

I've made the OUTPUT and FEATURE report APIs a bit nicer to use. As a result, I was able to make both Keyboard and BootKeyboard support LEDs more simply. You can now do:

Code: Select all

USBHID.begin(HID_KEYBOARD);
Keyboard.begin();
...
ledState = Keyboard.getLEDs();
(You do need the Keyboard.begin(), though.) And if you want the keyboard to work with the BIOS, do HID_BOOT_KEYBOARD/BootKeyboard instead of HID_KEYBOARD/Keyboard.

Everything is backwards compatible except:
1. If you make a HID RAW device named raw, you now need to explicitly call raw.begin() in your setup code. (This is actually due to a bug fix in the HIDRAW interface.)
2. There is a limit of 12 (=MAX_HID_BUFFERS, in usb_composite.h) OUTPUT/FEATURE reports per device. This shouldn't really limit anybody.

arpruss
Posts: 155
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Thu Feb 01, 2018 4:05 am

RogerClark wrote:
Wed Dec 13, 2017 10:45 pm
Just a thought, but I noticed someone asking about USB Mass storage...

I recall there was some old code from the leaflabs forum, which I tried a long time ago.

I presume that in theory we could add USB mass storage as a library ???
In the "generalizable" branch of the library, I now have working mass storage code. I created a 12K RAM disk hosted on the stm32f1 and successfully formatted it with a hacked version mkdosfs. The API for the mass storage code will change, however.

The "generalizable" branch is meant to allow one to mix and match different "parts" of a composite USB device, e.g., mass storage + hid + serial, or midi + serial, etc. Not all combinations can be expected to work. (E.g., xbox360 + serial doesn't work.)

User avatar
RogerClark
Posts: 7691
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB HID / USB MIDI as libraries

Post by RogerClark » Thu Feb 01, 2018 9:38 am

very cool

Post Reply