Native HID support?

Posted on
  • SO, I've been playing around with my Espruino for a few days now, and I finally came up with a cool idea for a project. Without going into detail about it (it would bore you to tears), I need a programmable HID (human interface device) board to drive, well, a human interface.

    I was going to buy an Arduino Micro since I know for a fact that it supports being a HID natively, with no extraneous boards or wiring. However, I then realized that it can also function as a COM device and. . .well, so can the Espruino!

    So I've done a bit of Googling, but I can't seem to find a direct answer. So, here it goes:

    Can the Espruino in particular (or, more generally, any device that can function as a COM USB device) act as a native HID, like the Arduino Micro can?

    I should mention that though I am a fairly advanced programmer, I am still pretty new to microcontrollers, particularly when interfacing more than one device.

  • Hi,

    USB HID devices actually enumerate themselves differently to a USB VCP (COM) device - but there's no physical hardware difference, it's all software.

    There's a feature request on GitHub for adding this, and I'd definitely like to get it done at some point -­ues/221

    For Espruino it would actually require modifications to the firmware though - it's not something you could do in pure JavaScript...

    For now, I wonder whether there is any possibility of making the VCP device pretend it was a PS/2 keyboard. I guess that might be more easily done on Linux than other operating systems though...

  • Also interested in this.

  • The issue is what do people want? Keyboard, Mouse, Joystick? I guess all 3, but that's not possible all at once.

    The best solution would probably be to allow people to specify their own USB device IDs and then we could just have some pre-made modules that did the main devices - but it'd also be possible to do all kinds of different peripherals.

  • I just commented on an old thread about this (woops!), but yes, I'm also very interested in this.

    Like I said in the other thread, the Teensy lets you use Raw HID to communicate directly with your custom app, and also has easy functionality for interfacing as a keyboard, mouse and joystick, as well as (only on the Teensyduino?) MIDI and flight sim controller(!).

    I'd be happy with Keyboard and Raw HID..

  • Yes, it would be a cool addition. It is complicated a bit by the way we've got to do it at runtime while also supporting the different processor types though.

    If anyone has any experience with USB and could help contribute to this, it'd really be appreciated.

  • I appreciate the replies! I'll take a look at the git to see if there's anything I can contribute, but I'm certainly not the best at writing driver software.

  • The Espruino having USB HID support could be spot on for an idea I have. There are so many reasons to have MIDI pedals to control page turning of music or audio effects on tablets and laptops. The problem is that the pedal boards you can buy cost so much and still need a MIDI to USB adaptor. If the Espruino could support a MIDI USB HID then all I would have to add is a few switches, LEDs and a maybe a small screen and I could have something that would fit the bill.

    I can see that the Espruino Pico kickstarter project hit its USB HID Support stretch goal and I assume that this feature will also be rolled back into the original Espruino too. Can I ask if USB MIDI support will be added and how any development might be going? (I'm happy to wait for a feature like this, I was just wondering if it was going to be possible or not).


  • Development is still going, I can't give you an end date for when it'll happen because getting the actual Pico hardware manufacturing underway is my priority right now.

    It's looking a bit more difficult to support multiple USB devices at once in the F103 (original Espruino) board due to lack of USB endpoints, so it probably won't have the support initially until things die down a bit and I get more time.

    In terms of MIDI, the way I'm implementing the USB HID should allow the device to enumerate as many different types of HID device. I'll be providing example JavaScript libraries for basic stuff like keyboards and mice, but for MIDI you may have to do some reading and copy/paste to get it working - although hopefully others will contribute libraries that pretend to be other types of device.

  • In terms of examples of how to implement USB support you could have a look at this project called LUFA­p its for AVR micros but it might give some idea's

  • Thanks!

  • Hi Gordon, thanks for the update, timescales as expected (more than happy to wait).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Native HID support?

Posted by Avatar for b4ux1t3 @b4ux1t3