Andrew | 4 Jul 2012 19:58
Picon

Re: Arduino as a Mouse/Keyboard interface?

All,

I am not going to claim I am an Arduino expert, but I have been a very 
frequent contributor to the Arduino forums for a few years now, and I 
own a few Arduinos (take it for what it is worth).

First, the Arduino Uno is composed of a couple microcontrollers (uC), 
the prime one being the ATMega328P. Secondary to this uC, is another 
microcontroller which acts as the USB-to-serial interface, an Atmega16U2 
(or an Atmega8U2 up to version R2):

http://arduino.cc/en/Main/ArduinoBoardUno

This 16U2/8U2 took over the functionality of the FTDI USB-to-serial 
driver chip which was used on the earlier Arduino Duemilanove:

http://arduino.cc/en/Main/ArduinoBoardDuemilanove

I don't know what the "official" reason was for the change to the 
16U2/8U2 for USB-to-serial functionality, but I suspect it was two-fold:

1) An attempt to future-proof the device
2) Programmability for customization

Both are basically the same; by using a microcontroller to do the 
USB-to-serial conversion, particularly a uC in the same family as the 
base uC (328P, etc), going forward more functionality could be added as 
needed, or if the uC for the USB-to-serial was dropped by Atmel, another 
could be substituted.

(Continue reading)

Mark McDougall | 5 Jul 2012 00:56
Picon
Picon

Re: Arduino as a Mouse/Keyboard interface?

On 5/07/2012 3:58 AM, Andrew wrote:

> Now - in the past (prior to the UNO), there were successful attempts using a
> custom shield to interface the 328P on the Arduino to USB as a host. I would
> be willing to imagine (not having seen the software in question, of course)
> that somebody out there has reprogrammed the 16U2/8U2 uC on the Uno to act
> in a similar manner - becoming a host interface.

I'm not doubting your claims, but I would be very interested to know how 
this was done, in particular, whether the same method could be used on other 
USB 'device' chips (FTR I've worked on the implementation both of USB hosts 
and devices). Sounds like someone got quite inventive/clever!

> Whether one could do keyboard and mouse at the same time, though, would be a
> different thing; the main issue would be memory (both flash and SRAM, but
> SRAM mainly, I think). Even so, a Mega could solve that issue.

I suspect the 'host' was jury-rigged to just do enough to enumerate the 
keyboard and elicit input reports from it; without knowing exactly how it 
was done it's difficult to say what additional resources are required for a 
2nd device. If the keyboard in question was a HID device (as I suspect it 
was) it may not require a lot more to talk to a HID mouse...

All pure speculation on my part, take with the requisite grain of salt.

Regards,

--

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

Frank Swygert | 5 Jul 2012 01:55

Re: Arduino as a Mouse/Keyboard interface?

Mark, the reason I mentioned the Leonardo board as a keyboard interface 
is because the Arduino site SPECIFICALLY mentions it can be used to 
interface a keyboard. (http://arduino.cc/en/Main/ArduinoBoardLeonardo)
--------------------
"The Arduino Leonardo is a microcontroller board based on the ATmega32u4 
(datasheet 
<http://www.atmel.com/dyn/resources/prod_documents/7766S.pdf>). It has 
20 digital input/output pins (of which 7 can be used as PWM outputs and 
12 as analog inputs), a 16 MHz crystal oscillator, a micro USB 
connection, a power jack, an ICSP header, and a reset button. It 
contains everything needed to support the microcontroller; simply 
connect it to a computer with a USB cable or power it with a AC-to-DC 
adapter or battery to get started.

The Leonardo differs from all preceding boards in that the ATmega32u4 
has built-in USB communication, eliminating the need for a secondary 
processor. This allows the Leonardo to appear to a connected computer as 
a mouse and keyboard, in addition to a virtual (CDC) serial / COM port. 
It also has other implications for the behavior of the board; these are 
detailed on the getting started page 
<http://arduino.cc/en/Guide/ArduinoLeonardo>."
--------------------

I might be misinterpreting the above, but another site specifically 
mentioned that a USB keyboard can be plugged into the USB port and that 
there was software for the Leonardo board that would read the keyboard.

This led me to believe the I/O pins could possibly be connected directly 
to the keyboard connector or the keyboard PIA lines and have the 
Leonardo processor translate the PC keyboard to the data the CoCo needs:
(Continue reading)

Mark McDougall | 5 Jul 2012 03:39
Picon
Picon

Re: Arduino as a Mouse/Keyboard interface?

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.
(Continue reading)

Tony Cappellini | 5 Jul 2012 02:39
Picon

Re: Arduino as a Mouse/Keyboard interface?

Message: 7
Date: Tue, 3 Jul 2012 09:13:48 -0500
From: Allen Huffman <alsplace@...>
Subject: Re: [Coco] Arduino as a Mouse/Keyboard interface?
To: CoCoList for Color Computer Enthusiasts <coco@...>
Message-ID: <B79D8BBD-EE98-4ED3-A205-E50D6590E8CC@...>
Content-Type: text/plain; charset=us-ascii

>>Perhaps I did not even know there was more than just the "One" board at the time.
The Uno R3 is the latest based on the ATMega 328P.

The Leonardo is just a lower cost version based on the Atmel ATmega32u4.

The Arduino Unos and earlier models require "2 chips", thus being more
expensive.
1 chip is the main microcontroller that the user programs to run his app.
The other "chip" is used to emulate a USB-serial protocol, used for
downloading the executeable code
from the host computer.

Now- here comes the Leonardo. It is based on theĀ ATmega32u4. So , it
is the microcontroller that is used
to run the embedded application, and as a bonus it contains a
USB-serial interface for downloading the code.
A 1-chip solution.

I haven't looked at the specs of theĀ ATmega32u4 to see if it has the
same number of I/O lines as the 328, but
I would suspect they are very close.

(Continue reading)

Frank Swygert | 5 Jul 2012 13:53

Re: Arduino as a Mouse/Keyboard interface?

Mark McDougall wrote:
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.
------------------

USB keyboards can be plugged into a simple adapter and plugged into a 
PS/2 port, so they must have some kind of code detecting the type port, 
or the PS/2 port has some differentiating signal it sends to the 
keyboard and the keyboard switches modes. Couldn't this fact be used to 
implement a keyboard? I know USB mice act the same way, so I don't think 
it's in the keyboard circuitry...

--

-- 
Frank Swygert
Editor - American Motors Cars Magazine
www.amc-mag.com

--
Coco mailing list
Coco@...
http://five.pairlist.net/mailman/listinfo/coco

Mark McDougall | 5 Jul 2012 14:22
Picon
Picon

Re: Arduino as a Mouse/Keyboard interface?

On 5/07/2012 9:53 PM, Frank Swygert wrote:

> USB keyboards can be plugged into a simple adapter and plugged into a PS/2
> port, so they must have some kind of code detecting the type port, or the
> PS/2 port has some differentiating signal it sends to the keyboard and the
> keyboard switches modes. Couldn't this fact be used to implement a keyboard?
> I know USB mice act the same way, so I don't think it's in the keyboard
> circuitry...

You can only use the simple passive USB->PS/2 adapters (like those that ship 
with some Logitec keyboards) on keyboards/mice that are able to talk *both* 
USB and PS/2 protocols. These passive adapters pretty much just change the 
plug type.

You can also get active converters that convert USB to PS/2. They're more 
expensive - but still under $10 - and have an IC inside.

Either way, you'd still need to connect the keyboard via PS/2 signalling to 
the Arduino. The USB port on it would still be unused in this case.

Regards,

--

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

--
Coco mailing list
Coco@...
http://five.pairlist.net/mailman/listinfo/coco
(Continue reading)


Gmane