[Coco] Arduino as a Mouse/Keyboard interface?

Mark McDougall msmcdoug at iinet.net.au
Wed Jul 4 21:39:01 EDT 2012


On 5/07/2012 9:55 AM, Frank Swygert wrote:

> After a bit of reading I see that I *did* misunderstand. The keyboard and
> mouse libraries for the Leonardo make a PC think the Leonardo is a keyboard
> or mouse, they don't allow you to connect a keyboard or mouse. You can send
> keystrokes to the PC. I don't see why it won't work the other way around,
> but a program would have to be written from scratch to do it. If it can
> emulate a keyboard, it should be able to read a keyboard. Sounds right and
> logical, but reality might be different...

Yes, with a USB device it's quite trivial to emulate a keyboard or mouse (or 
both at once). That's what these devices are meant to be used for.

You can't simply connect another USB device to a USB "device" port. The USB 
bus requires a host controller for devices to even start up. The host 
controller is responsible for enumerating devices and scheduling bus 
transfers; devices know nothing about this sort of thing. As for software, a 
USB host stack is a significant chunk of work; I know having been involved 
in porting the BSD USB host stack onto a NIOS processor running RTEMS.

IMHO the whole USB bus is a bit of a train-wreck - not helped by the fact 
that Microsoft really didn't (and to some degree still can't) get the 
host-side software right. Although USB is designed to support multiple 
devices per bus, it's somewhat telling (IMHO) that PC host devices never 
have more than 2 ports attached. Then again, you could argue that it's done 
to allow multiple USB storage & streaming devices to be attached and run at 
full USB bandwidth. Hmmm...

Of course they attempted to mitigate the whole host/device problem with 
on-the-go (OTG) which, I must admit, I haven't had much experience with.

Anyway, back to the original issue; I still maintain that you cannot attach 
a USB keyboard/mouse to a device that is designed to operate as a USB 
"device". It should be noted, however, that the PS/2 protocol is quite 
trivial, and something that has been bit-bashed on PICs for years. No doubt 
you could use the Arduino to connect PS/2 devices to the Coco. Alas, like 
those before it, PS/2 devices are getting harder to find as most of them 
have been consigned to the IT department junk box, or the dumpster.

Regards,

-- 
|              Mark McDougall                | "Electrical Engineers do it
|  <http://members.iinet.net.au/~msmcdoug>   |   with less resistance!"





More information about the Coco mailing list