USBMouse Example

22 Oct 2009 . Edited: 22 Oct 2009

Hi,

Here is a first cut library for emulating a usb mouse. Connect up the D- and D+ and GND of the mbed to a USB connector/lead, plug it in to a PC, and you should be able to pretend to be a mouse.

Here is an example that pulls in the library and demos it:

We'll write up a proper cookbook page soon, but thought i'd post it as I am just about to use it in a demo!

Simon

23 Oct 2009

Simon,

Nice work. It would be more interesting to do other more practical HIDs like buttons, LED, Analog Inputs and PWM outputs. Looking forward to them ...

Regards,

Paul

29 Jan 2010

Hello Simon,

I came back to check this USB mouse demo again. After importing the project, I found both the mbed library and the USBMouse library were both old versions.

The compiler has no problem with updating the USBMouse driver from 601 to 656. However, updating the mbed library from V14 to V19 failed the compilation with

"Cannot open source input file "nvic_api.h": No such file or directory (E5)" in file "USBMouseOld/lib/USBMouse/usbdc.cpp".

Re-import again and it compiled OK with the old V14 library. Would you like to check it out?

By the way, do you have any progress on mbed for HID devices?

Best regards,

Paul



 

29 Jan 2010 . Edited: 29 Jan 2010

I'm cutting up a spare USB cable to test this out now, Any chance a USB keyboard emulator is on the way too?

 

Program works here! I am tempted to plug this into the back of a workmates computer and see how long it takes him to notice.

29 Jan 2010 . Edited: 29 Jan 2010

I had a play and it seems like middle click and right click are swapped in the buttons method, as in the way it works here is           
mouse.buttons(left, right, middle( havent tested) ); tested using XP, drawing lines with paint

Also I found you need to wait a while for the mouse to be active after the first click, like with normal USB mouses where you have to plug them in and then spaz out for a bit until they actually get going.USBMouse

09 Feb 2010

Where is the source code for the USBMouse USB driver?  I'd like to modify the descriptor and code to support other HID devices.

It would also be useful as an example for developing code for other USB classes like audio, midi, serial directly from the main processor (i.e. with flow control), etc.

02 Dec 2010

I connect the USB spare cable to the PC, and WinXP does not recognize the USB device? What is error ?
I appreciate your help

20 Jun 2011

I know some of these threads are a bit old, but has anyone managed to get BASIC HID DEVICE INTERFACE to work.

Ceri

20 Jun 2011

I've been looking at it, but in all honesty so far it is over my head. I need this now for my current project. Even if it was just as basic as fixed 32 or 64 byte packets being passed in both directions with call backs to notify the main loop that data is available. From reading the forum it seems like many people would benefit from this.

Best regards,

Mike