WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Easier IR Mouse (doesn't lose the cursor at the edges)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
Frivolous Sam



Joined: 18 May 2008
Posts: 16

Digg It
PostPosted: 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
View user's profile Send private message
Frivolous Sam



Joined: 18 May 2008
Posts: 16

Digg It
PostPosted: 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
View user's profile Send private message
xaanaax



Joined: 07 May 2008
Posts: 12

Digg It
PostPosted: Mon May 19, 2008 7:33 pm    Post subject:

Is it the whole script?
Back to top
View user's profile Send private message
Frivolous Sam



Joined: 18 May 2008
Posts: 16

Digg It
PostPosted: Wed May 21, 2008 7:15 pm    Post subject:

Yeah, that's it.
Back to top
View user's profile Send private message
xaanaax



Joined: 07 May 2008
Posts: 12

Digg It
PostPosted: Fri May 23, 2008 4:38 am    Post subject:

Good job Frivolous Sam Smile It works quite well and the script is short Smile Nice Smile
Back to top
View user's profile Send private message
Frivolous Sam



Joined: 18 May 2008
Posts: 16

Digg It
PostPosted: Fri May 23, 2008 2:41 pm    Post subject:

xaanaax wrote:
Good job Frivolous Sam Smile It works quite well and the script is short Smile Nice Smile

Thanks.

I've also been modding the stock sensor bar to run off USB
Back to top
View user's profile Send private message
flashcat



Joined: 22 May 2008
Posts: 4

Digg It
PostPosted: 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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group