Pages: [1]   Go Down
Author Topic: Make arduino control windows mouse and keyboard?  (Read 5010 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Vancouver, BC, Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 164
Arduino 4 Prez
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6252
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Vancouver, BC, Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 164
Arduino 4 Prez
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Vancouver, BC, Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 164
Arduino 4 Prez
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: June 15, 2008, 05:08:05 am by bens » Logged


London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6252
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote
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.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Pages: [1]   Go Up
Jump to: