From WiiLi
//Exy's Extended Classic Controller Mouse
//from Excel-2008
//http://whatistheexcel.com
//26 April 2008 for GlovePIE 0.30
//The latest version of this script will always be found at
//http://www.wiili.org/index.php/GlovePIE:Extended_Classic_Controller_Mouse
//
//This script is licensed under a Creative Commons Attribution-Noncommercial 3.0
//United States License. You are free to distribute and modify this script at
//will, provided that you give attribution to me, Excel-2008, and that it is not
//used for any commercial purpose or profit. A link to either this page or
//http://whatistheexcel.com will suffice as attribution. For more information,
//see http://creativecommons.org/licenses/by-nc/3.0/us/
//
//I made this mapping with the goal to use every single button on the Classic
//Controller for mouse movement and keyboard keys. Do not use the scroll wheel
//on your mouse while this script is running or your scroll wheel may get stuck
//until you disable the script.
//
//The D-pad can operate in three modes. In the default mouse mode, the D-pad
//will control the mouse the same way the left analog stick does. In the
//keyboard mode, the D-pad is mapped to arrow keys. In the wheel mode, the
//D-pad acts like the scroll wheel (see the note below). When you change the
//D-pad mode with the a button, the cursor will change to indicate the new mode.
//The mouse mode is represented with a hand, the keyboard mode with the four-way
//arrow and the wheel mode with an upward arrow. The cursor will revert to
//normal when the mouse moves or if a button is pressed. The last three LEDs on
//the remote will also indicate the current mode: the second light for the
//mouse, third for keyboard and fourth for wheel.
//
//When using the D-pad as the scroll wheel, you will need to press a direction
//twice to start scrolling in that direction. Hold a direction down for
//one-half second to continuously scroll in that direction. As per the
//documentation, though there are mappings for the horizontal scroll wheel, all
//such functions do not yet work.
//
//For maximum effect, set the D-pad mode to mouse movement and play music from the
//SNES version of SimCity in the background while using this script. If you're
//really adventurous, try using this with an on-screen keyboard! One such
//program is the built-in on-screen keyboard found in C:\Windows\system32\osk.exe
//in Windows 2000 and later.
//
//Default Mappings:
//Left stick = mouse movement
//Right stick = scroll wheel
//L = speed up mouse and wheel movement
//R = slow down mouse and wheel movement
//y = Left button
//b = Right button
//x = Middle button
//a = Change D-pad control (cycles between mouse, arrow keys and scroll wheel)
//ZL = Mouse button 4 (Browser back button by default I think)
//ZR = Mouse button 5 (Browser forward button I think)
//Minus = Escape
//Plus = Enter
//Home = Start menu (same as Windows key)
//the first led is always on to show that the thing is active
Wiimote1.Led1 = true
//mouse movement
Mouse1.DirectInputX = Mouse1.DirectInputX + var.slow*deadzone(Wiimote1.Classic.Joy1X)
Mouse1.DirectInputY = Mouse1.DirectInputY + var.slow*deadzone(Wiimote1.Classic.Joy1y)
//adjust speed if L or R is held down
var.slow = 10
if (Wiimote1.Classic.LFull) {
var.slow = 50
} elseif (Wiimote1.Classic.L) {
var.slow = 30
}
endif
if (Wiimote1.Classic.RFull) {
var.slow = 2.5
} elseif (Wiimote1.Classic.R) {
var.slow = 5
}
endif
//wheel
Mouse1.DirectInputZ = Mouse1.DirectInputZ + deadzone(Wiimote1.Classic.Joy2Y)*-120*(var.slow/10)
Mouse1.DirectInputH = Mouse1.DirectInputH + deadzone(Wiimote1.Classic.Joy2X)*-120*(var.slow/10) //doesn't seem to work yet
//buttons
Mouse1.LeftButton = Wiimote1.Classic.y
Mouse1.RightButton = Wiimote1.Classic.b
Mouse1.MiddleButton = Wiimote1.Classic.x
Mouse1.XButton1 = Wiimote1.Classic.ZL
Mouse1.XButton2 = Wiimote1.Classic.ZR
Keyboard.LeftWindows = Wiimote1.Classic.Home
Keyboard.Escape = Wiimote1.Classic.Minus
Keyboard.Enter = Wiimote1.Classic.Plus
//dpad
//press a to change modes
if (Pressed(Wiimote1.Classic.a)) {
if (var.dpadmouse < 2) var.dpadmouse += 1 else var.dpadmouse = 0
//unset bindings when mode changes
if (var.dpadmouse == 0) {
Mouse1.Cursor = 16
} elseif (var.dpadmouse == 1) {
Keyboard.Left = false
Keyboard.Right = false
Keyboard.Up = false
Keyboard.Down = false
Mouse1.Cursor = 15
} elseif (var.dpadmouse == 2) {
Mouse1.Cursor = 10
}
}
//mode settings
//one of the last three leds will be on to show which mode the dpad is on
if (var.dpadmouse = 0) { //mouse
Mouse1.DirectInputX = Mouse1.DirectInputX - var.slow*(Wiimote1.Classic.Left)
Mouse1.DirectInputX = Mouse1.DirectInputX + var.slow*(Wiimote1.Classic.Right)
Mouse1.DirectInputY = Mouse1.DirectInputY - var.slow*(Wiimote1.Classic.Up)
Mouse1.DirectInputY = Mouse1.DirectInputY + var.slow*(Wiimote1.Classic.Down)
Wiimote1.Led2 = true
Wiimote1.Led3 = false
Wiimote1.Led4 = false
} elseif (var.dpadmouse = 1) { //arrows
Keyboard.Left = Wiimote1.Classic.Left
Keyboard.Right = Wiimote1.Classic.Right
Keyboard.Up = Wiimote1.Classic.Up
Keyboard.Down = Wiimote1.Classic.Down
Wiimote1.Led2 = false
Wiimote1.Led3 = true
Wiimote1.Led4 = false
} elseif (var.dpadmouse = 2) { //wheel
Mouse1.WheelUp = Pressed(Wiimote1.Classic.Up)
Mouse1.WheelDown = Pressed(Wiimote1.Classic.Down)
Mouse1.WheelLeft = Pressed(Wiimote1.Classic.Left)
Mouse1.WheelRight = Pressed(Wiimote1.Classic.Right)
if (HeldDown(Wiimote1.Classic.Up,0.5s)) Mouse1.DirectInputZ = Mouse1.DirectInputZ + 60*var.slow/10*(Wiimote1.Classic.Up)
if (HeldDown(Wiimote1.Classic.Down,0.5s)) Mouse1.DirectInputZ = Mouse1.DirectInputZ - 60*var.slow/10*(Wiimote1.Classic.Down)
if (HeldDown(Wiimote1.Classic.Left,0.5s)) Mouse1.DirectInputH = Mouse1.DirectInputH - 60*var.slow/10*(Wiimote1.Classic.Left)
if (HeldDown(Wiimote1.Classic.Right,0.5s)) Mouse1.DirectInputH = Mouse1.DirectInputH + 60*var.slow/10*(Wiimote1.Classic.Right)
Wiimote1.Led2 = false
Wiimote1.Led3 = false
Wiimote1.Led4 = true
}