How to use Wii controller (Wiimote) as a mouse in Windows

31 10 2007

This tutorial will show you how to use your Wiimote as a mouse on your Windows PC with IR functionality.

Hardware you will need:

  • Bluetooth adapter
  • Wiimote
  • Wii Sensor Bar
  • Windows PC
  • Wii

Software you will need:

In order to use your Wiimote as a mouse on your PC, you will have to connect it to the PC via Bluetooth, then run a script in the GlovePIE application that will translate the Wiimote actions to mouse actions. For this tutorial I will be using the Anycom 200 Bluetooth adapter which I got for $7.28 shipped from Buy.com using Google Checkout. NOTE: Microsoft’s Bluetooth stack will not.

Connect Wiimote to PC:

  1. Download, extract, and install Kensington WIDCOMM Bluetooth stack. (Run Setup.exe)
    NOTE: DO NOT plug in adapter during installation when asked
  2. Plug in adapter
  3. When asked to install drivers, insert CD that came with adapter and continue installation
  4. Open My Bluetooth Places to start the Initial Bluetooth Configuration Wizard
  5. Press the Next button until you ge to the Bluetooth Device Selection screen
  6. Press the red SYNC button under the battery cover on the Wiimote (LEDs on the Wiimote should blink)
  7. Press Search Again in the wizard
  8. Nintendo RVL-CNT-01 should appear
  9. Select it and press Next
  10. Skip Pairing
  11. Make sure the LEDs on the Wiimote are blinking (press the red SYNC button again if you have to)
  12. Press Refresh in the wizard if necessary
  13. Check the box next to Nintendo RVL-CNT-01 and press Next
  14. Press Skip the Next
  15. Reopen My Bluetooth Places
  16. Select Bluetooth Setup Wizard from left panel
  17. Select I want to find a specific Bluetooth device… and press Next
  18. Select Nintendo RVL-CNT-01 and press Next, if it is not there repeat steps 6-8
  19. Repeat steps 10-13
  20. The icon shown for Nintendo RVL-CNT-01 when View devices in range is selected should now have a green connection symbol on it, if not repeat until it does

Use Wiimote as mouse:

  1. Download and extract GlovePIE
  2. Run GlovePIE.exe
  3. Select File->Open
  4. Open file named TestWiimote.PIE
  5. Press Run
    NOTE: if numbers do not change, you Wiimote is not connected to your PC properly
  6. Press Stop
  7. Turn your Wii on and make sure the sensor bar is over or under your monitor
  8. Select File->New
  9. Cut and Paste the following script into the window and press Run:

    //Mouse Control Script using IR
    //by vkapadia with much assistance from inio
    //vkapadia@vkapadia.com
    //
    //Calibration:
    //To calibrate, run this program and put the Wiimote on a flat surface face-up.
    //Then read the values in the debug line (next to the run button).
    //Change these values until the debug line reads approx. all zeros.
    var.xtrim = 6
    var.ytrim = -31
    var.ztrim = 6
    //
    //Options:
    var.deadzone = 5 //distance in pixels that you have to move the wiimote in
    //order for it to register movement. Creates a "dead zone" around the pointer
    //to make it easier to click. Higher = smoother but less accurate.
    var.KITTspeed = 100 ms //delay speed for flashing LEDs. higher = slower
    var.rumble = false //makes the wiimote rumble if you hit the edge of the screen
    //more options to be added later
    //Controls:
    //Point Wiimote = Move Mouse
    //D-Pad = Arrow Keys
    //B-Button = Left Click
    //Home = Middle Click
    //A-Button = Right Click
    //Plus and Minus = Control Volume
    //One = Unmapped
    //Two = Unmapped
    //
    //If the pointer hits the edge of the screen, the Wiimote will rumble a bit.
    //
    //The LEDs attempt to emulate KITT's grill from Knight Rider
    //***Do not edit anything below this line unless you know what you are doing.***
    //Set the D-Pad to function as the Arrow Keys
    if wiimote.Up
    Up = true
    else
    Up = false
    endif
    if wiimote.Down
    Down = true
    else
    Down = false
    endif
    if wiimote.Left
    Left = true
    else
    Left = false
    endif
    if wiimote.Right
    Right = true
    else
    Right = false
    endif
    //Mouse Buttons
    Mouse.RightButton = Wiimote.A
    Mouse.LeftButton = Wiimote.B
    Mouse.MiddleButton = Wiimote.Home
    //Plus and Minus handle Volume
    if wiimote.plus then
    volumeup = true
    wait 60 ms
    volumeup = false
    endif
    if wiimote.minus then
    volumedown = true
    wait 60 ms
    volumedown = false
    endif
    //wiimote.One
    //wiimote.Two
    //LEDs look somewhat like KITT's grill from Knight Rider
    if 0 = 0 then
    if var.kitt = 0 then
    wiimote.Leds = 1
    endif
    if var.kitt = 1 then
    wiimote.Leds = 3
    endif
    if var.kitt = 2 then
    wiimote.Leds = 6
    endif
    if var.kitt = 3 then
    wiimote.Leds = 12
    endif
    if var.kitt = 4 then
    wiimote.Leds = 8
    endif
    if var.kitt = 5 then
    wiimote.Leds = 12
    endif
    if var.kitt = 6 then
    wiimote.Leds = 6
    endif
    if var.kitt = 7 then
    wiimote.Leds = 3
    endif
    wait var.KITTspeed
    var.kitt = (var.kitt + 1) % 8
    endif
    //If the mouse reaches the end, rumble for 200 milliseconds
    if var.rumble and (mouse.x = 0 or mouse.x = 1 or mouse.y = 0 or mouse.y = 1) then
    if var.rmbl = false
    wiimote.Rumble = 1
    wait 200 ms
    wiimote.Rumble = 0
    endif
    var.rmbl = true
    else
    var.rmbl = false
    endif
    var.accx = wiimote.RawForceX + var.xtrim
    var.accy = wiimote.RawForceY + var.ytrim
    var.accz = wiimote.RawForceZ + var.ztrim
    if wiimote.dot1vis and wiimote.dot2vis then
    if var.accy > -7 then
    var.orientation = 0
    elseif var.accy > -45 then
    if var.accx < 0 then
    var.orientation = 3
    else
    var.orientation = 1
    endif
    else
    var.orientation = 2
    endif
    if var.leftpoint = 0 then
    if var.orientation = 0 then
    if wiimote.dot1x wiimote.dot2y then
    var.leftpoint = 1
    else
    var.leftpoint = 2
    endif
    endif
    if var.orientation = 2 then
    if wiimote.dot1x > wiimote.dot2x then
    var.leftpoint = 1
    else
    var.leftpoint = 2
    endif
    endif
    if var.orientation = 3 then
    if wiimote.dot1y < wiimote.dot2y then
    var.leftpoint = 1
    else
    var.leftpoint = 2
    endif
    endif
    endif
    if var.leftpoint = 1 then
    var.fix1x = wiimote.dot1x
    var.fix1y = wiimote.dot1y
    var.fix2x = wiimote.dot2x
    var.fix2y = wiimote.dot2y
    else
    var.fix1x = wiimote.dot2x
    var.fix1y = wiimote.dot2y
    var.fix2x = wiimote.dot1x
    var.fix2y = wiimote.dot1y
    endif
    var.dx = var.fix2x - var.fix1x
    var.dy = var.fix2y - var.fix1y
    var.cx = (var.fix1x+var.fix2x)/1024.0 - 1
    var.cy = (var.fix1y+var.fix2y)/1024.0 - .75
    var.d = sqrt(var.dx*var.dx+var.dy*var.dy)
    var.dx = var.dx / var.d
    var.dy = var.dy / var.d
    var.ox = -var.dy*var.cy-var.dx*var.cx;
    var.oy = -var.dx*var.cy+var.dy*var.cx;
    var.ax = (var.ox * screen.desktopwidth) + (screen.desktopwidth / 2)
    var.ay = (-var.oy * screen.desktopwidth) + (screen.desktopheight / 2)
    var.dx = var.ax - mouse.cursorposx
    var.dy = var.ay - mouse.cursorposy
    var.d = sqrt((var.dx*var.dx)+(var.dy*var.dy))
    var.a = 180 / (200 + var.d * var.d * var.d * .001)
    if var.d <= var.deadzone then var.a = 1
    debug = var.d + " " + var.a
    var.finalx = mouse.cursorposx * var.a + var.ax * (1 - var.a)
    var.finaly = mouse.cursorposy * var.a + var.ay * (1 - var.a)
    mouse.cursorposx = var.finalx
    mouse.cursorposy = var.finaly
    else
    var.leftpoint = 0
    endif
    //debug = var.accx + " " + var.accy + " " + var.accz

Script provided by vkapadia.

You should now be able to successfully point and click on your PC just as you would with a mouse.

You will have to repeat steps 15-20 of Connect Wiimote to PC above, each time you want to reconnect to the Wiimote.

The script provided requires a sensor bar. You can create your own or modify the one provided with the Wii to be powered from batteries, eliminating the need for the Wii to be powered on. Also, you can use 2 lit candles placed near the bottom of your monitor but I don’t recommend this.


Actions

Information

13 responses

20 04 2008
Mårten

HI!
I have tried this.
Everything works fine til the last step.

I can press A/trigger and it works but I can’t make it work with the pointing.
The mouse just gets stuck in the upper left corner.
It would be awesome to get it to work.

16 10 2008
WII Remote

[…] Hooking up a WII remote with a bluetooth device […]

24 01 2009
Plauderstübchen - Seite 174 - Diablo-3.net Foren

[…] von Mendeln RUDERN junge RUNDERN rofl klick btw __________________ Fri>Frey Join Liberators Of Doom […]

6 02 2009
Ben

Line 129:
if wiimote.dot1x wiimote.dot2y then

…has an error, you’re missing a comparison operator.

Otherwise, great job!
Thanks!

29 09 2009
Spasysheep

Works brilliantly, but it’s a bit over-sensitive

28 10 2009
jrmedia

coding corrected

if var.leftpoint = 0 then
if var.orientation = 0 then
if wiimote.dot1x wiimote.dot2y then
var.leftpoint = 1
else
var.leftpoint = 2
endif
endif
if var.orientation = 2 then
if wiimote.dot1x > wiimote.dot2x then
var.leftpoint = 1
else
var.leftpoint = 2
endif
endif
if var.orientation = 3 then
if wiimote.dot1y < wiimote.dot2y then var.leftpoint = 1
else
var.leftpoint = 2
endif
endif
endif

28 10 2009
jrmedia

some how part of script got dumped remove // infront of coding
//if var.leftpoint = 0 then
//if var.orientation = 0 then
//if wiimote.dot1x wiimote.dot2y then
//var.leftpoint = 1
//else
//var.leftpoint = 2
//endif
//endif
//if var.orientation = 2 then
//if wiimote.dot1x > wiimote.dot2x then
//var.leftpoint = 1
//else
//var.leftpoint = 2
//endif
//endif
//if var.orientation = 3 then
//if wiimote.dot1y < wiimote.dot2y then var.leftpoint = 1
//else
//var.leftpoint = 2
//endif
//endif
//endif

28 10 2009
jrmedia

1 more try this is code missing in script
if var.orientation = 1 then
if wiimote.dot1y > wiimote.dot2y then
var.leftpoint = 1
else
var.leftpoint = 2
endif
endif

15 02 2010
Winko

After having used GlovePie several times, I thought it would be handy to have a function that would auto calibrate my Wii remote. I couldn’t find a script or routine that did this, so I decided to give it a shot myself.

(article: http://www.winko-erades.nl/index.php?option=com_content&view=article&id=6:glovepie-wiimote-auto-calibration&catid=4:windows-xp&Itemid=3)
(website: http://www.winko-erades.nl/)

Regards,

Winko

23 04 2010
Ibtisam Ali

I’m using the GlovePie to emulate my wiiMote as a Mouse. I’m using the wiiMouse IR script, but the curser seems to be stuck on the upper left corner of the screen. I did what ever changes that were suggested by jrmedia, but it did not help. do I need to download certain derivers or use certain bluetooth device?
Can someone help me resolve the problem? Thank you.

27 04 2010
yazeed

change these values and try

var.xtrim = 6
var.ytrim = -31
var.ztrim = 6

12 05 2010
Amanda

This is awesome! Got anything for doing this in Linux?

(I know, I know.. the answer is, I gotta do it myself.) Worth asking, though! This is a good starting point.

22 09 2010
Winko

Yes it’s also possible in linux check http://www.ink-erades.nl for a how to!

Leave a comment