Make arduino control windows mouse and keyboard?

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.

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?

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.

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.

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

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 :

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.

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.

I know there's a way to send commands from processing,

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

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?

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.

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.

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

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:

But search the documentation for your favorite programming language for how best to call this.

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.