This probably isn't the most exciting or original project, but it's my first try at putting the Arduino to a practical purpose... well if playing games is in any way practical
I've created an interface using the Arduino and some Python to use a Wii Nunchuck to control the mouse position and mouse buttons, which works fine under Windows. The intention was to then use this to control a game, but for whatever reason it won't work in the game. I'd be interested if anyone can offer any suggestions of a fix. I've documented it all and included source code on a page I'll link to from a reply as this is my first post!
I've done something similar, just without any Arduino. You can get the same, or better results using GlovePIE with the Wiimote, and it will work with games. Or OpenPIE, but I haven't tried that one.
Maybe you can also use GlovePIE for the serial stream from the Arduino as well. Not that I know, I havent really coded much in GlovePIE. Just to test the PC with the Wiimote, which I haven't done in a while.
I too found it a bit cumbersome for a mouse replacement (with my simple code at least).
Here is the code I made for the game Mass Effect. I never really got used to it, nothing really beats ye olde keyboard+mouse combination! But its fun to try nevertheless. No code for nunchuck here, as I only have the Wiimote.
// raron's simple wiimouse 0.06
// 2007.06.07 raron
// 2008.07.18 Quick rewrite for Mass Effect PC
// Usage:
// home singleclicked = recenter the wiimote, use in combination with:
// home held down > 250 ms = set deadzone to equal the movement of the wiimote
// Up = D
// Down = A
// Left = W
// Right = S
// Wiimote 1 = Q
// Wiimote 2 = E
// Wiimote A = Right mouse button
// Wiimote B = left mouse button
// A +Minus = Volume down
// A + Plus = Volume up
var.wiix = wiimote.gx
var.wiiy = wiimote.gy
var.wiiz = wiimote.gz
wiimote.leds = 0
// recenter it
if singleclicked(wiimote.Home) = true then
var.xMin = var.wiix
var.xMax = var.wiix
var.yMin = var.wiiy
var.yMax = var.wiiy
var.zMin = var.wiiz
var.zMax = var.wiiz
wiimote.leds = 6
wait 250 ms
wiimote.leds = 0
end if
// define deadzone
if helddown(wiimote.home, 250 ms)= true then
var.xd = wiimote.gx
var.yd = wiimote.gy
var.zd = wiimote.gz
if var.xd < var.xMin then var.xMin = var.xd
if var.xd > var.xMax then var.xMax = var.xd
if var.yd < var.yMin then var.yMin = var.yd
if var.yd > var.yMax then var.yMax = var.yd
if var.zd < var.zMin then var.zMin = var.zd
if var.zd > var.zMax then var.zMax = var.zd
wiimote.leds = 9
endif
// Horizontal movement - PS! Swithced X-Y because of holding wiimote wheel-ish
var.wiiRight = var.wiiz - var.zMin
var.wiiLeft = var.wiiz - var.zMax
if var.wiiRight < 0 then mouse.DirectInputX = 0 - smooth(var.wiiRight)
if var.wiiLeft > 0 then mouse.DirectInputX = 0 - smooth(var.wiiLeft)
// Vertical movement
var.wiiDown = var.wiix - var.xMin
var.wiiUp = var.wiix - var.xMax
if var.wiiDown < 0 then mouse.DirectInputY = smooth(var.wiiDown)
if var.wiiUp > 0 then mouse.DirectInputY = smooth(var.wiiUp)
// Buttons
mouse.LeftButton = wiimote.B
mouse.RightButton = wiimote.A
if not wiimote.A then
key.ctrl= wiimote.Plus
key.Z=wiimote.Minus
endif
key.w = wiimote.Left
key.s = wiimote.Right
key.a = wiimote.Down
key.d = wiimote.Up
key.Q = wiimote.Two
key.E = wiimote.One
// Media stuff
if wiimote.A then
volumeup = wiimote.Plus
volumedown = wiimote.Minus
endif
Guess you didn't read my description in full... I've already completed a project with the Wiimote (though I used the wrj4P5 library in Processing) and wanted to try something different... specifically using Arduino. This was more of a learning exercise, so GlovePIE and a Wiimote would be missing the point. Also the Nunchuck is more appropriate for Lander - at least if I can get it working - and I'd rather avoid having to connect it via a remote...
Still - I hadn't considered looking at some of the Wiimote solutions out there (missing the obvious as usual : ). If I can find one that works with Lander then, assuming it's open source, I can see how they dealt with mouse control...