USB HID

Please do not post requests
Collie147
Posts: 2
Joined: Wed May 24, 2017 12:20 pm

Re: USB HID

Post by Collie147 » Thu May 25, 2017 7:14 am

Champ! Thanks, and thanks for the info on the drivers too!

petr
Posts: 32
Joined: Wed Jul 15, 2015 10:33 am

Re: USB HID

Post by petr » Thu May 25, 2017 7:25 am

libarra, could your implementation be extended somehow to provide a generic HID device to user? I used V-USB's HID implementation for transmitting my own data this way. I just wrote the descriptor and send/receive functions and that was it. Even the descriptor was kinda generic actually - it just took me a while to find one that would be accepted by Windows, OSX and Linux. So only the send/receive routines were "custom" (user defined), the rest could have been hardcoded in the library.

Maybe it's not necessary when the serial over USB is working (it wasn't on V-USB, IIRC). But the great advantage of HID based custom communication is that it doesn't need any driver nor configuration/setup on PC side. You just plug it in and it works out of the box.

petr
Posts: 32
Joined: Wed Jul 15, 2015 10:33 am

Re: USB HID

Post by petr » Thu May 25, 2017 1:53 pm

BTW, I've tried the libarra HID Keyboard in Linux (worked perfectly) and Windows 10 (didn't work at all, "driver not installed").
Is it supposed to work in Windows 10 or not?

libarra
Posts: 56
Joined: Tue Sep 15, 2015 2:51 pm

Re: USB HID

Post by libarra » Fri May 26, 2017 5:01 am

Collie147 wrote:Champ! Thanks, and thanks for the info on the drivers too!
You're welcome.
petr wrote:libarra, could your implementation be extended somehow to provide a generic HID device to user? I used V-USB's HID implementation for transmitting my own data this way. I just wrote the descriptor and send/receive functions and that was it. Even the descriptor was kinda generic actually - it just took me a while to find one that would be accepted by Windows, OSX and Linux. So only the send/receive routines were "custom" (user defined), the rest could have been hardcoded in the library.
I think it could be could be posible to extend the implementation to use some other report descriptor, but I don't think the report descriptor should be a compatibility issue. My goal was to make the HID Mouse & Keyboard compatible with the arduino implementation.
petr wrote:Maybe it's not necessary when the serial over USB is working (it wasn't on V-USB, IIRC). But the great advantage of HID based custom communication is that it doesn't need any driver nor configuration/setup on PC side. You just plug it in and it works out of the box.
You mean Raw HID?, I left an unused Raw HID part in the report descriptor, only the interface class is missing.
petr wrote:BTW, I've tried the libarra HID Keyboard in Linux (worked perfectly) and Windows 10 (didn't work at all, "driver not installed").
Is it supposed to work in Windows 10 or not?
I may need to check again the arduino implementation but as far as I know, the HID interface works with Linux, Windows and OS X, I don't know what may be the problem with win10 as I don't use it.

In the case of win10, was the board detected but marked an error in the device or wasn't it even detected?

Lennyz1988
Posts: 20
Joined: Fri Jun 30, 2017 9:11 am

Re: USB HID

Post by Lennyz1988 » Mon Aug 14, 2017 1:18 pm

libarra wrote:
Thu May 25, 2017 5:19 am

If you are using windows you may need to uninstall your board's driver as Serial in the device manager, and check for changes in the hardware. When it is detected it will install 3 usb drivers: Composite, Serial and HID. Once it's done installing the drivers your board should work as a composite device with Serial and HID.
Thanks! This did the trick for me. Working perfectly fine on Windows 10 x64.

douginarug
Posts: 6
Joined: Mon Mar 20, 2017 4:15 pm
Location: Indiana, USA

Re: USB HID

Post by douginarug » Wed Oct 11, 2017 2:45 pm

I'm using Arduino IDE 1.6.9, Windows 7, a Maple Mini r3 (from eBay) (with a STM32F103C8T6). Using the Keyboard + Mouse setting.

I tried to get this to work, but even after uninstalling the serial driver in device manager and resetting it so it reinstalled, it still does not show up as a HID device. It only reinstalls the serial. I also tried connecting it to an old windows XP machine.
I have read through most of this forum thread, skimming past the MIDI stuff, and I am wondering if I have missed something.

Should I be using a different IDE? There is a lot of conflicting info of which one to use with a stm32.
Edit: I just tried IDE 1.6.13 and still no HID device.

Are there some examples specifically for the maple or maple mini? Here is my code...

Code: Select all

const int button0 = PB11;          
const int button1 = PB10;         
void setup() {
  pinMode(PB1, OUTPUT); //for the LED
  pinMode(button0, INPUT_PULLUP);
  pinMode(button1, INPUT_PULLUP);
  //Keyboard.begin();
  //USBDev.begin();
}
void loop() {
 if ((digitalRead(button0)== LOW)) Keyboard.press('a');              else Keyboard.release('a');
 if ((digitalRead(button1)== LOW)) Keyboard.press('b');              else Keyboard.release('b');
 // The next section blinks the LED so I can tell if the sketch is running
 digitalWrite(PB1, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(2);              // wait 
 digitalWrite(PB1, LOW);    // turn the LED off by making the voltage LOW
 delay(498);              // wait 
}

ofnicolson
Posts: 9
Joined: Sat Jan 02, 2016 5:01 pm

Re: USB HID

Post by ofnicolson » Sat Oct 14, 2017 5:42 pm

Hi everyone,

I'm trying to make my Maple Mini act as a USB keyboard. I've installed the code at https://github.com/libarra111/Arduino_STM32 but I can't find the examples mentioned (the original post says they live in a HID folder which I can't find).

Can anyone point me at sample code that acts as a USB keyboard, please?

Many thanks,
Ollie

ofnicolson
Posts: 9
Joined: Sat Jan 02, 2016 5:01 pm

Re: USB HID

Post by ofnicolson » Sun Oct 15, 2017 7:47 am

Ah, OK. I figured it out - I'd been trying to include Keyboard.h and getting "can't find HID.h" errors. But apparently Keyboard.write() works without any includes or initialization.

Thanks libarra!

douginarug
Posts: 6
Joined: Mon Mar 20, 2017 4:15 pm
Location: Indiana, USA

Re: USB HID

Post by douginarug » Thu Oct 19, 2017 1:38 pm

libarra wrote:
Thu May 25, 2017 5:19 am
If you are using windows you may need to uninstall your board's driver as Serial in the device manager, and check for changes in the hardware. When it is detected it will install 3 usb drivers: Composite, Serial and HID. Once it's done installing the drivers your board should work as a composite device with Serial and HID.
Hey I got it!
You may want to add an extra step to this quote from Libarra. At least for Windows 7 users. If you can't get windows to recognize your Maple as a HID device, Uninstall your driver like Libarra says and then, when it asks if you want to "Confirm Device Uninstall",
Put a Check in the checkbox that says "Delete the driver software for this device."
Then press the OK button. Then reset your Maple.

Thank you Libarra (and others) for all your hard work.

Post Reply