| View previous topic :: View next topic |
| Author |
Message |
Frivolous Sam
Joined: 18 May 2008 Posts: 16
Digg It |
Posted: Sun May 18, 2008 12:38 pm Post subject: Easier IR Mouse (doesn't lose the cursor at the edges) |
|
|
This is an update to the IR Mouse script included with GlovePIE 0.30.
There is now a configurable dead zone on all the edges because I was having trouble scrolling, hitting the start button and hitting close buttons when the wiimote's position was close to the edge. The variable EdgeDeadZone is a fraction of the wiimote's positional axes to use as a dead zone on each side. The default setting of 0.1 means that only 80% of each axis is used for the cursor and allows 10% margin of error on each edge.
| Code: | // Wiimote mouse script for Windows desktop
// Requires a sensor bar
var.EdgeDeadZone = 0.1
var.ButtonFreezeTime = 250ms
var.PointerBump = KeepDown(Pressed(wiimote.A),var.ButtonFreezeTime) or KeepDown(Pressed(wiimote.B),var.ButtonFreezeTime)
Wiimote.Led1 = true
// Mouse movement
if wiimote.PointerVisible but not var.PointerBump then
if wiimote.PointerX > 1 - var.EdgeDeadZone then
mouse.x = 1
elseif wiimote.PointerX < var.EdgeDeadZone then
mouse.x = 0
else
mouse.x = (wiimote.PointerX - var.EdgeDeadZone) / (1 - (var.EdgeDeadZone * 2))
end if
if wiimote.PointerY > 1 - var.EdgeDeadZone then
mouse.y = 1
elseif wiimote.PointerY < var.EdgeDeadZone then
mouse.y = 0
else
mouse.y = (wiimote.PointerY - var.EdgeDeadZone) / (1 - (var.EdgeDeadZone * 2))
end if
end if
// Mouse Buttons
mouse.LeftButton = Wiimote.A and KeepDown(Wiimote.PointerVisible,0.5s)
mouse.RightButton = Wiimote.B and KeepDown(Wiimote.PointerVisible,0.5s)
mouse.MiddleButton = Wiimote.Home and KeepDown(Wiimote.PointerVisible,0.5s)
mouse.XButton1 = Wiimote.Minus
mouse.XButton2 = Wiimote.Plus
// Mouse Wheel
if wiimote.Up then
mouse.WheelUp = true
wait 30ms
mouse.WheelUp = false
wait 30ms
end if
if wiimote.Down then
mouse.WheelDown = true
wait 30ms
mouse.WheelDown = false
wait 30ms
end if |
|
|
| Back to top |
|
 |
Frivolous Sam
Joined: 18 May 2008 Posts: 16
Digg It |
Posted: Sun May 18, 2008 12:39 pm Post subject: |
|
|
| I have no idea how to put this on the wiki, so if someone could do it on my behalf that would be great. |
|
| Back to top |
|
 |
xaanaax

Joined: 07 May 2008 Posts: 12
Digg It |
Posted: Mon May 19, 2008 7:33 pm Post subject: |
|
|
| Is it the whole script? |
|
| Back to top |
|
 |
Frivolous Sam
Joined: 18 May 2008 Posts: 16
Digg It |
Posted: Wed May 21, 2008 7:15 pm Post subject: |
|
|
| Yeah, that's it. |
|
| Back to top |
|
 |
xaanaax

Joined: 07 May 2008 Posts: 12
Digg It |
Posted: Fri May 23, 2008 4:38 am Post subject: |
|
|
Good job Frivolous Sam It works quite well and the script is short Nice  |
|
| Back to top |
|
 |
Frivolous Sam
Joined: 18 May 2008 Posts: 16
Digg It |
|
| Back to top |
|
 |
flashcat
Joined: 22 May 2008 Posts: 4
Digg It |
Posted: Sat May 24, 2008 12:31 am Post subject: Very cool! |
|
|
| I'm waiting for my IR-LEDs... I ordered them yesterday. When they arrive - then I'll build my own sensor bar and test your script! I'm really looking forward for using my wiimote as a mouse! |
|
| Back to top |
|
 |
|