gaber2008
Joined: 01 Apr 2008 Posts: 2
Digg It |
Posted: Tue Apr 01, 2008 1:50 am Post subject: Custom Mouse Control Script |
|
|
Controls WMP, mouse cursor, some important keys and hotkeys like Alt+F4 (close window/shutdown), F5 (Refresh), Enter, Volume, and the LEDs will show battery life.
Scripts used: Mouse Control Script and WiiBattery Script.
Thanks to vkapadia and J.Coulston for creating those scripts.
Please Leave Feedback
Tell me how to improve the script.
| Code: | //Mouse Control Script
//by vkapadia
//vkapadia@vkapadia(.)com
//WiiBattery Script by J.Coulston Modified by Carl Kenner for GlovePIE 0.25
//Modified by gaber2008
//
//Calibration:
//Change these values until the debug line says all zeros when the wiimote is at rest.
var.trimx = 6
var.trimy = -31
var.trimz = 6
//
//Controls:
//Tilt Wiimote Up and Down = Move Mouse Up and Down
//Rotate Wiimote Left and Right = Move Mouse Left and Right
//D-Pad = Arrow Keys
//B-Button = Left Click
//Home = Refresh (F5)
//A-Button = Right Click
//Plus and Minus = Control Volume
//One = Play/Pause (I have CTRL+P set to do that in Windows Media Player.)
//Two = Next Song (I have CTRL+F set to do that in Windows Media PLayer.)
//One and Two At Same Time for 3 Seconds = Close 1 Window/Shutdown (Alt+F4)
//The LEDs Show Battery Power (Taken From WiiBattery Script)
//
//If the pointer hits the edge of the screen, the Wiimote will rumble a bit.
//
//Alt+F4
if wiimote.1 + wiimote.2
Key.LeftAlt && Key.F4 = false
Wait 3 s
Key.LeftAlt && Key.F4 = true
Key.LeftAlt && Key.F4 = false
endif
//Enter Key
Key.Enter = Wiimote.Down + Wiimote.B
//Refresh (F5)
Key.F5 = Wiimote.Home
//Set the D-Pad to function as the Arrow Keys
if wiimote.Up
Up = true
Wait 200 ms
Up = false
endif
if wiimote.Down
Down = true
Wait 200 ms
Down = false
endif
if wiimote.Left
Left = true
Wait 200 ms
Left = false
endif
if wiimote.Right
Right = true
Wait 200 ms
Right = false
endif
//Mouse Buttons
Mouse.RightButton = Wiimote.A
Mouse.LeftButton = Wiimote.B
//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
//Windows Media Player Hotkeys (CTRL && P = Play/Pause; CTRL && F = Next Song)
CTRL && P = wiimote.One
Control && F = wiimote.Two
//TODO: not satisfied with wiimote.One
//TODO: not satisfied with wiimote.Two
//TODO: not satisfied with wiimote.Plus
//TODO: not satisfied with wiimote.Minus
//TODO: not satisfied with wiimote.Home
//Leds Show Battery Power
//Wiimote Battery Display
//by J.Coulston
// Modified by Carl Kenner for GlovePIE 0.25
//A full battery gives 0xC0 (192)
var.Batt = wiimote.Battery / 48
if true then
wait 5 seconds
//it sends an instruction that tells the Wiimote to actually
//send the report.
Wiimote.Report15 = 0x80 | Int(wiimote.Rumble)
end if
//Display the battery level of your wiimote using the four LEDs on the bottom.
//Battery level is displayed in four levels increasing to the right, like a cell
//phone battery gauge. As the battery gets close to the next level down, the LED
//for the current level will blink.
//Blink rate
var.Blink = 500ms
debug = "Battery level: " + 100*48*var.Batt/192 + "%"
if 0<=var.Batt<=0.25 then
Wiimote.Leds = 1
wait var.Blink
Wiimote.Leds = 0
wait var.Blink
elseif 0.25 < var.Batt<=1 then
Wiimote.Leds = 1
elseif 1 < var.Batt<=1.25 then
Wiimote.Leds = 3
wait var.Blink
Wiimote.Leds = 1
wait var.Blink
elseif 1.25 < var.Batt<=2 then
Wiimote.Leds = 3
elseif 2 < var.Batt<=2.25 then
Wiimote.Leds = 7
wait var.Blink
Wiimote.Leds = 3
wait var.Blink
elseif 2.25 < var.Batt<=3 then
Wiimote.Leds = 7
elseif 3 < var.Batt<=3.25 then
Wiimote.Leds = 15
wait var.Blink
Wiimote.Leds = 7
wait var.Blink
elseif 3.25 < var.Batt<=4 then
Wiimote.Leds = 15
else
Wiimote.Leds = 0
endif
//If the mouse reaches the end, rumble for 200 milliseconds
if 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
//****Everything past here deals with mouse movement*****
// set these to the offsets when the wiimote is at rest
// will be different for each wiimote most likely
var.x = Wiimote.RawForceX + var.trimx //trim to 0
var.y = Wiimote.RawForceY + var.trimy // trim to 0
var.z = Wiimote.RawForceZ + var.trimz //trim to 0
//precision
var.sense0 = 500
var.thresh0x = 5
var.thresh0y = 2
var.sense = 300
var.threshx = 10
var.threshy = 5
var.sense2 = 100
var.thresh2x = 15
var.thresh2y = 8
var.sense3 = 50
var.thresh3x = 20
var.thresh3y = 12
//first sensitivity setting
//xaxis
if var.x > var.thresh0x
mouse.x = mouse.x - 1/var.sense0
endif
if var.x < -var.thresh0x
mouse.x = mouse.x + 1/var.sense0
endif
//yaxis
if var.z > var.thresh0y
mouse.y = mouse.y - 1/var.sense0
endif
if var.z < -var.thresh0y
mouse.y = mouse.y + 1/var.sense0
endif
//second sensitivity setting
//xaxis
if var.x > var.threshx
mouse.x = mouse.x - 1/var.sense
endif
if var.x < -var.threshx
mouse.x = mouse.x + 1/var.sense
endif
//yaxis
if var.z > var.threshy
mouse.y = mouse.y - 1/var.sense
endif
if var.z < -var.threshy
mouse.y = mouse.y + 1/var.sense
endif
//third sensitivity setting
//xaxis
if var.x > var.thresh2x
mouse.x = mouse.x - 1/var.sense2
endif
if var.x < -var.thresh2x
mouse.x = mouse.x + 1/var.sense2
endif
//yaxis
if var.z > var.thresh2y
mouse.y = mouse.y - 1/var.sense2
endif
if var.z < -var.thresh2y
mouse.y = mouse.y + 1/var.sense2
endif
//fourth sensitivity setting
//xaxis
if var.x > var.thresh3x
mouse.x = mouse.x - 1/var.sense3
endif
if var.x < -var.thresh3x
mouse.x = mouse.x + 1/var.sense3
endif
//yaxis
if var.z > var.thresh3y
mouse.y = mouse.y - 1/var.sense3
endif
if var.z < -var.thresh3y
mouse.y = mouse.y + 1/var.sense3
endif
debug = var.x + " " + var.y + " " + var.z |
|
|