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 

Wimote Mouse test scripts

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
James20



Joined: 05 Dec 2006
Posts: 3

Digg It
PostPosted: Sat Jul 05, 2008 4:31 pm    Post subject: Wimote Mouse test scripts

I Posted this in the glovepie forum but I noticed theres seems to be more disscusion here on scripts.
James20 wrote:
I searched around a bit but I didn't find recent scripts that filter out jitter and handle acceleration. Most seem to be simple one to one mapping, which on a huge monitor looks bad. I wrote these to filter out jitter and provide more accuracy and control for small movements.

I removed extensive button mapping because I figure most people are smart enough to do that themselves. This is purely a simple mouse.
Code:
//Smooth mouse
//Uses Sensor bar
//by James
if starting {
    Pie.FrameRate   = 100
    var.DeadZone    = 1/10
    var.dCurve      = 1.15  //Adjust Acceleration
}

Mouse.LeftButton    = Wiimote.A
Mouse.MiddleButton  = Wiimote.Home
Mouse.RightButton   = Wiimote.B

if Wiimote.PointerVisible {
    if (var.pX0=="NAN") var.X0 = 0.5
    if (var.pY0=="NAN") var.Y0 = 0.5
    var.pX1     = var.pX0
    var.pY1     = var.pY0
    var.pX0     = EnsureMapRange(Wiimote.PointerX,var.DeadZone,1-var.DeadZone,-0.1,1.1)
    var.pY0     = EnsureMapRange(Wiimote.PointerY,var.DeadZone,1-var.DeadZone,-0.1,1.1)
    var.Dis     = sqrt( (var.pX0-var.pX1)^2 + (var.pY0-var.pY1)^2 )
    var.Frac    = var.Dis-var.dCurve
    var.pX0     = var.pX1 + ( (var.pX0-var.pX1) * var.Frac )
    var.pY0     = var.pY1 + ( (var.pY0-var.pY1) * var.Frac )
    Mouse.X     = EnsureRange(var.pX0,0,1)
    Mouse.Y     = EnsureRange(var.pY0,0,1)
}



This one was designed for Portal. I removed the button mappings again so it can be modified for any FPS. Played the whole game with it. Only part that was tough was the portal trampoline, level 18 I think.
Code:
//Mouse Relative Movement
//Keep near the center of the screen
//Uses Sensor Bar
//By James
if starting {
    var.DeadZone    = 1/10
    var.xSpeed      = 0.64cm    //Max mouse speed on X axis
    var.ySpeed      = 0.40cm    //Max mouse speed on Y axis
    var.rCurve      = 2.75      //Acceleration
    var.WiiCntMax   = 2.5s      //Timeout before Pointer is lost

}

Mouse.LeftButton    = Wiimote.A
Mouse.MiddleButton  = Wiimote.Home
Mouse.RightButton   = Wiimote.B


if Wiimote.PointerVisible {
    var.WiiWas = true
    var.WiiCnt = 0s
    // Convert Wiimote pointer to Cartesian coordinate system [-1,1] while handling deadzone
    var.X = EnsureMapRange(Wiimote.PointerX,var.DeadZone,1-var.DeadZone,-1,1)
    var.Y = EnsureMapRange(Wiimote.PointerY,var.DeadZone,1-var.DeadZone,-1,1)
    // Apply a curve so that moves near the center of the screen aren't as dramatic
    var.X = (abs(var.X)^var.rCurve)*sign(var.X)
    var.Y = (abs(var.Y)^var.rCurve)*sign(var.Y)
    // Convert from Cartesian coordinate system
    Mouse.DirectInputX += (EnsureMapRange(var.X,-1,1,-var.xSpeed,var.xSpeed) in cm)
    Mouse.DirectInputY += (EnsureMapRange(var.Y,-1,1,-var.ySpeed,var.ySpeed) in cm)
    //var.X and var.Y must stay intact at this point
} else {
    if (var.WiiWas) {
        var.WiiCnt += (1/Pie.FrameRate)s
        if (var.WiiCnt<var.WiiCntMax) {
            Mouse.DirectInputX += (EnsureMapRange(var.X,-1,1,-var.xSpeed,var.xSpeed) in cm)
            Mouse.DirectInputY += (EnsureMapRange(var.Y,-1,1,-var.ySpeed,var.ySpeed) in cm)
        } else {
           var.WiiWas = false
        }
    }
}



This last one was just a test, I applied the same logic to see if I could filter the movements using the accelerometers only. Pretty good if you don't have a sensor bar. Pretend you are pointing at a curve screen in front of your hand. This is absolute positioning rather than relative, fairly intuitive.
Code:
//Absolute Mouse without sensor bar
//by James
if starting {
    pie.FrameRate   = 100
    var.aCurve      = 2.0
    var.LeftAng     = -24
    var.RightAng    = 24
    var.TopAng      = 50
    var.BottomAng   = 30
}

Mouse.LeftButton    = Wiimote.A
Mouse.MiddleButton  = Wiimote.Home
Mouse.RightButton   = Wiimote.B

if (var.X0=="NAN") var.X0 = 0.5
if (var.Y0=="NAN") var.Y0 = 0.5
var.X1      = var.X0
var.Y1      = var.Y0
var.X0      = EnsureMapRange(Wiimote.Roll,var.LeftAng,var.RightAng,-0.1,1.1)
var.Y0      = 1-EnsureMapRange(Wiimote.Pitch,var.BottomAng,var.TopAng,-0.1,1.1)
var.Dis     = sqrt( (var.X0-var.X1)^2 + (var.Y0-var.Y1)^2 )
var.Frac    = var.Dis-var.aCurve
var.X0      = var.X1 + ( (var.X0-var.X1) * var.Frac )
var.Y0      = var.Y1 + ( (var.Y0-var.Y1) * var.Frac )
Mouse.X     = EnsureRange(var.X0,0,1)
Mouse.Y     = EnsureRange(var.Y0,0,1)
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
Page 1 of 1

 
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