GlovePIE:Dead Zone (Script)

From WiiLi

Jump to: navigation, search

In some cases it might be necessary to apply a dead zone to a device in your GlovePIE script. Here is some code to do just that. It assumes the input is mapped from -1 to 1 and set to the variables Var.JoyX and Var.JoyY. The output is stored in Var.JoyX and Var.JoyY.

// constants
Var.DeadZone = 0.15;
Var.LiveZone = 1.0 - Var.DeadZone;

// apply deadzone to X axis
if Var.JoyX < -Var.DeadZone
   Var.JoyX = (Var.JoyX + Var.DeadZone) / Var.LiveZone;
else if Var.JoyX > Var.DeadZone
   Var.JoyX = (Var.JoyX - Var.DeadZone) / Var.LiveZone;
else
   Var.JoyX = 0
end

// apply deadzone to Y axis
if Var.JoyY < -Var.DeadZone
   Var.JoyY = (Var.JoyY + Var.DeadZone) / Var.LiveZone;
else if Var.JoyY > Var.DeadZone
   Var.JoyY = (Var.JoyY - Var.DeadZone) / Var.LiveZone;
else
   Var.JoyY = 0
end
Personal tools
Online Casino - best online casino reviews.
Facebook Developers - facebook applications, facebook developers, facebook development, social network application development and viral widget social media strategy