Emulate keyboard over USB ?

Libraries, utilities, bootloaders...

Emulate keyboard over USB ?

Postby mougino » Tue Oct 06, 2015 8:41 pm

Is it possible for the Gamebuino to act like a USB keyboard, sending an array of characters to the PC over USB ? If yes with what protocol ? SPI or I2C ? (I have no idea what they are yet, I am a newbie in serial communication :oops: ).

I am investigating if it's possible to use the Gamebuino + a PN532 NFC shield + a FPM10A fingerprint reader as a way of replacing password-typing to open a secure session (Windows or web).

I would be interested in any code snippet and/or library that would allow to do any of these tasks.

Thanks for any feedback ! ;)
Nicolas
User avatar
mougino
 
Posts: 75
Joined: Sat Jul 25, 2015 8:15 am
Location: Paris, France

Re: Emulate keyboard over USB ?

Postby Sorunome » Tue Oct 06, 2015 11:37 pm

The usb thing of arduinos communicates using the UART protocol, that is that "Serial"-object in the arduino language.
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Emulate keyboard over USB ?

Postby mougino » Wed Oct 07, 2015 6:24 am

Thanks suronome, is there a piece of code I could start studying ?
Should I look directly in the Arduino library ?
User avatar
mougino
 
Posts: 75
Joined: Sat Jul 25, 2015 8:15 am
Location: Paris, France

Re: Emulate keyboard over USB ?

Postby jonnection » Wed Oct 07, 2015 7:16 am

USB is not simply serial communication. USB is a software stack&hw specification. In order for a device to be able to connect to a PC "as a HID" (HID = human interface device, eg mouse and keyboard) the device needs to be able to handle the USB stack (= the collection of code that relates to the protocol).

This functionality can be implemented in software, in which case the USB stack requires significant amount of memory (can't remember offhand how much) or in hardware by putting most of the required functionality into the ROM of the microcontroller. This is exactly what has been done in the ATMega32u4 mcu which is in the Arduboy console.

For a good reference on the subject, check out the LUFA project of Dean Camera.
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Emulate keyboard over USB ?

Postby mougino » Wed Oct 07, 2015 11:21 am

Thanks Jonne ! I'm going to investigate in these directions ;)

Cheers
Nicolas
User avatar
mougino
 
Posts: 75
Joined: Sat Jul 25, 2015 8:15 am
Location: Paris, France

Re: Emulate keyboard over USB ?

Postby jonnection » Thu Oct 08, 2015 10:00 am

Nicolas

I wasn't reading your question properly. So let me continue a bit.

1) if you want to feed information to the PC via serial communication

The Serial class in Arduino lib allows you to connect via serial link to the PC. In this case, the ATMega 328 in the Gamebuino is first in serial connection to the FT232 chip in the Gamebuino. The FT232 chip enumerates as a serial port USB device on the PC.

In this case, what you need is a program on the PC that communicates with the Com port created by the FT232. The problem is, as far as I understand, that you need to get this input into another program. If you want the input from this program to act as a "keyboard-like" device in Windows, I believe you then have to write a Windows device driver for your program. There exist some helpful programs that will allow you to transmit serial communication to a TCP/IP port, if that is of any help. I have used programs called Serproxy and Tinkerproxy to get serial from an Arduino to a Flash program running in Windows.

2) If you want a "real" USB HID device, that allows you to input text no matter where you are (web page, windows program etc), in the same way an USB barcode reader works

In this case the easiest solution is to get for example an Arduino Micro with Atmega32u4 chip which has built-in USB support. You can then program that chip to communicate with the Gamebuino through I2C and communicate towards the PC as a real HID device. However, in this scenario the question becomes whether there is any point in using the Gamebuino at all, as the Arduino Micro can probably handle the interface to your fingerprint reader or whatever you had in mind directly.

3) a Funky option, if you want to try something out just for kudos

There exists a cool program called GlovePie that can be used to bridge between different types of devices. There's too much to go into detail here but for example Wiimote to PC to Arduino, or for example IR head position sensor to PC mouse is completely doable.

As it happens, the Nunchuck connector in the Wiimote is a standard I2C connection. You could make the Gamebuino emulate Nunchuck (libraries exist but can bother to dig them out) connect it to a wiimote, and use BT over Glovepie to control the PC :lol:
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Emulate keyboard over USB ?

Postby mougino » Thu Oct 08, 2015 10:45 am

Many thanks Jonne.

Yes what I want to achieve is your option 2. Because I want to be able to log in on a Windows session so no program can be launched and do the interface there.

It's true the simplest way would be to use a Leonardo, Micro or Due. But I'm interested in using the Gamebuino (for simplicity, to get feedback on screen for example) and I read there's a lib allowing to act as an HID: V-USB. So I'm investigating this lib now.

EDIT: link to V-USB demo http://blog.petrockblock.com/2012/05/19 ... n-example/

Nicolas
User avatar
mougino
 
Posts: 75
Joined: Sat Jul 25, 2015 8:15 am
Location: Paris, France

Re: Emulate keyboard over USB ?

Postby jonnection » Thu Oct 08, 2015 6:13 pm

Wow !

So someone has actually managed to put the USB stack on atmega328

... one thing I've learned with Arduinos is that any time you say something is not possible on Arduino, some joker comes and does it :lol: :lol:

Thanks for the link, I will check it out also !

UPDATE:

I can't believe it. V-USB runs on a 2k ATTiny.

When I was checking out the LUFA code, I came to the impression that you need at least several kb's to handle the complicated USB communication packets.

Since its clear that I do not have a clue about this topic so I will shut up now.
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Emulate keyboard over USB ?

Postby mougino » Thu Oct 08, 2015 6:51 pm

On the contrary :D feel free to share your experience with the V-USB lib.
I wanted to start studying it today, but I pushed some improvements for my gamebook engine instead.
Your help is greatly appreciated ;)

Nicolas
User avatar
mougino
 
Posts: 75
Joined: Sat Jul 25, 2015 8:15 am
Location: Paris, France

Re: Emulate keyboard over USB ?

Postby Sutchig » Mon Oct 12, 2015 7:36 pm

Hi, hat Sounds great :)
As far as I understand v-usb is something like a soft-usb, which "misuses" some of the atmega ports. The only ports that are accessible should be the i2c-ports - rendering them unusable for real i2c communication. I hope, I am wrong ;)

Additionally: if you manage to connect a fingerprint reader to send a password using a emulated keyboard via v-usb, you should avoid sending a return - you don't know, what window will have the keyboard focus :)
Sutchig
 
Posts: 67
Joined: Sat May 23, 2015 3:48 pm

Next

Return to Software Development

Who is online

Users browsing this forum: No registered users and 3 guests

cron