Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
09.02.2010 at 17:38:44
News: Server upgrade went fine, you are now at the new system


Pages: 1
Make arduino control windows mouse and keyboard? (Read 4848 times)
banditmatt
YaBB Newbies
*
Offline

Arduino rocks

Posts: 6

Make arduino control windows mouse and keyboard?
13.06.2008 at 17:52:49
 
Hi.  Is there a way to make the arduino control the mouse and keyboard in windows?  for instance, use a pot to control mouse x movement, and another to control y movement, and a series of buttons for certain keyboard buttons?  The reason I'm asking is I'm trying to make a custom controller to play computer games.  It would be great if the solution could be done in processing.  Thanks in advance.
Back to top
 
 
View Profile   IP Logged
chrome123
YaBB Newbies
*
Offline

Arduino rocks

Posts: 18

Re: Make arduino control windows mouse and keyboar
Reply #1 - 13.06.2008 at 18:14:36
 
I'm pretty sure a mouse just sends a stream of data so i guess it is possible (a mouse has a pic in it) keyboard should have the same basic idea to it no?
Back to top
 
 
View Profile   IP Logged
MikMo
God Member
*****
Offline

Do it !

Posts: 1595

Re: Make arduino control windows mouse and keyboar
Reply #2 - 14.06.2008 at 19:52:05
 
There's an example of interfacing a PS2 mouse in the playground. If thai could be any help.

As for the keyboard, i don't think it's very easy.

You could scavenge the (very small ) circuit board from a USB keyboard and hack into the matrix and have arduino simulate key presses by connecting the proper rows / coloums of the matrix.
Back to top
 
 
View Profile | WWW   IP Logged
lilpunk1302
Full Member
***
Offline

Arduino 4 Prez

Posts: 143
Vancouver, BC, Canada
Gender: male
Re: Make arduino control windows mouse and keyboar
Reply #3 - 14.06.2008 at 19:55:45
 
MikMo wrote on 14.06.2008 at 19:52:05:
There's an example of interfacing a PS2 mouse in the playground. If thai could be any help.

As for the keyboard, i don't think it's very easy.

You could scavenge the (very small ) circuit board from a USB keyboard and hack into the matrix and have arduino simulate key presses by connecting the proper rows / coloums of the matrix.


Yeah, but it's a pain mapping out the matrix.

Depending on what's faster(Ardy or KB), why not plug the PS2 port pins directly into the arduino, push every key then have Ardy send what pins get triggered.

Basically a diy packet scanner.

Check just have it resend those packets as needed.
Back to top
 
 
View Profile | WWW | MSN   IP Logged
MikMo
God Member
*****
Offline

Do it !

Posts: 1595

Re: Make arduino control windows mouse and keyboar
Reply #4 - 14.06.2008 at 20:07:52
 
The ps2 port uses something that resembels a serial protocol, so that would not work.
But you could find a description of the protocol (like someone did with the PS2mouse) and implement it on Arduino
Back to top
 
 
View Profile | WWW   IP Logged
mem
God Member
*****
Online

Have fun!

Posts: 5417
London
Re: Make arduino control windows mouse and keyboar
Reply #5 - 14.06.2008 at 22:34:57
 
One way you can do this is to send serial commands to a pc program and have that program inject mouse or keyboard events using whatever native api is available. In Java, the API is :
http://java.sun.com/j2se/1.3/docs/api/java/awt/Robot.html
Back to top
 
 
View Profile   IP Logged
follower
YaBB Moderator
*****
Offline

Arduino pebbles

Posts: 964
New Zealand
Re: Make arduino control windows mouse and keyboar
Reply #6 - 15.06.2008 at 01:56:45
 
Depending on your preference, needs and skill you could try either a PS/2 or USB based solution.

Do you want a USB or PS/2 device?

--Phil.
Back to top
 
 
View Profile | WWW   IP Logged
banditmatt
YaBB Newbies
*
Offline

Arduino rocks

Posts: 6

Re: Make arduino control windows mouse and keyboar
Reply #7 - 15.06.2008 at 03:43:38
 
mem wrote on 14.06.2008 at 22:34:57:
One way you can do this is to send serial commands to a pc program and have that program inject mouse or keyboard events using whatever native api is available. In Java, the API is :
http://java.sun.com/j2se/1.3/docs/api/java/awt/Robot.html

Yes, this is exactly what I was looking to do.  Is there a way I could use these commands in processing?  I know nothing about java.
Back to top
 
 
View Profile   IP Logged
lilpunk1302
Full Member
***
Offline

Arduino 4 Prez

Posts: 143
Vancouver, BC, Canada
Gender: male
Re: Make arduino control windows mouse and keyboar
Reply #8 - 15.06.2008 at 03:51:56
 
I know there's a way to *send* commands from processing,

http://www.arduino.cc/en/Tutorial/Dimmer

Haven't worked with it at all though so don't know if you can receive.
Back to top
 
 
View Profile | WWW | MSN   IP Logged
banditmatt
YaBB Newbies
*
Offline

Arduino rocks

Posts: 6

Re: Make arduino control windows mouse and keyboar
Reply #9 - 15.06.2008 at 04:11:23
 
lilpunk1302 wrote on 15.06.2008 at 03:51:56:
I know there's a way to *send* commands from processing,

http://www.arduino.cc/en/Tutorial/Dimmer

Haven't worked with it at all though so don't know if you can receive.


There absolutely is a way to send and receive commands in processing via serial.  I have no idea where a command would be sent in a computer to say "press the "A" key" without literally plugging a cord into the keyboard port.  There has to be a way for a computer to internally generate mouse and keyboard commands, right?
Back to top
 
 
View Profile   IP Logged
lilpunk1302
Full Member
***
Offline

Arduino 4 Prez

Posts: 143
Vancouver, BC, Canada
Gender: male
Re: Make arduino control windows mouse and keyboar
Reply #10 - 15.06.2008 at 04:17:33
 
Bleh, sorry, "explained" it wrong(well, didn't at all)

That guide shows you how to have Processing read the mouse coordinates and send them over serial.

Granted, generating them from serial input would be much harder, but you;re already half way there.
Back to top
 
 
View Profile | WWW | MSN   IP Logged
macegr
God Member
*****
Offline

Arduino Ninja

Posts: 689

Re: Make arduino control windows mouse and keyboar
Reply #11 - 15.06.2008 at 10:00:48
 
If you can get the AVR-USB code running on your Arduino (it's been done already, in these forums) you will have a way of sending keyboard or mouse input. Last year I designed a device that sits on a USB port and pretends to be a keyboard, mouse, or joystick. Then you'd send commands to it over I2C. It uses the AVR-USB library. I put it into a model airplane and used an accelerometer to sense roll and pitch to control a joystick in a flight sim game. You plug the device into any computer and it appears as a generic joystick.
Back to top
 
 
View Profile | WWW   IP Logged
bens
Senior Member
****
Offline

Arduino rocks

Posts: 466

Re: Make arduino control windows mouse and keyboar
Reply #12 - 15.06.2008 at 10:53:55
 
macegr wrote on 15.06.2008 at 10:00:48:
If you can get the AVR-USB code running on your Arduino (it's been done already, in these forums) you will have a way of sending keyboard or mouse input. Last year I designed a device that sits on a USB port and pretends to be a keyboard, mouse, or joystick. Then you'd send commands to it over I2C. It uses the AVR-USB library. I put it into a model airplane and used an accelerometer to sense roll and pitch to control a joystick in a flight sim game. You plug the device into any computer and it appears as a generic joystick.

I don't have too much experience with this, but I believe there's a pretty substantial difference between emulating a USB device and emulating a USB host (which is what would be required to connect to a USB device such as a mouse or keyboard).  But I'm not speaking with any authority here; I could be totally wrong.

- Ben
Back to top
 
 
View Profile | WWW   IP Logged
mem
God Member
*****
Online

Have fun!

Posts: 5417
London
Re: Make arduino control windows mouse and keyboar
Reply #13 - 15.06.2008 at 11:05:37
 
If you are familiar with a windows programming language, it really is much easier to write something that receives serial commands from the arduino and injects them using the appropriate programming interface for your language

The low level windows API function to insert keyboard and mouse events into the input stream is called SendInput:
http://msdn.microsoft.com/en-us/library/ms646310(VS.85).aspx

But search the documentation for your favorite programming language for how best to call this.
Back to top
 
 
View Profile   IP Logged
macegr
God Member
*****
Offline

Arduino Ninja

Posts: 689

Re: Make arduino control windows mouse and keyboar
Reply #14 - 15.06.2008 at 21:05:34
 
bens wrote on 15.06.2008 at 10:53:55:
macegr wrote on 15.06.2008 at 10:00:48:
If you can get the AVR-USB code running on your Arduino (it's been done already, in these forums) you will have a way of sending keyboard or mouse input. Last year I designed a device that sits on a USB port and pretends to be a keyboard, mouse, or joystick. Then you'd send commands to it over I2C. It uses the AVR-USB library. I put it into a model airplane and used an accelerometer to sense roll and pitch to control a joystick in a flight sim game. You plug the device into any computer and it appears as a generic joystick.

I don't have too much experience with this, but I believe there's a pretty substantial difference between emulating a USB device and emulating a USB host (which is what would be required to connect to a USB device such as a mouse or keyboard).  But I'm not speaking with any authority here; I could be totally wrong.

- Ben


He wants to connect an Arduino to a PC and allow the Arduino to control the mouse pointer and keyboard input. Not connect a USB keyboard/mouse to the Arduino. Although that is also very possible to do with FTDI's Vinculum chip.
Back to top
 
 
View Profile | WWW   IP Logged
Pages: 1