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 

TrackIR 2Dof, 2Leds, Flight- and RaceScript.

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



Joined: 06 Jul 2007
Posts: 127

Digg It
PostPosted: Tue Mar 25, 2008 10:58 am    Post subject: TrackIR 2Dof, 2Leds, Flight- and RaceScript.

Compatible with Yaw/Pitch in TrackIR enhanced games.
Compatible gamelist:
http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-all.html
Code:

/*
PipoXYZ's 2Dof, 2Leds, Flight- and RaceScript.
Keys:
F9 = Less Sensitive
F10 = More Sensitive
F11 = Set CenterView
Compatible with these games:
http://www.naturalpoint.com/trackir/03-enhanced-games/enhanced-games-all.html
Emulates Yaw/Pitch
Setup:
Place your Wiimote near your monitor facing your head.
Wear two IR-leds on your head facing the Wiimote.
The leds can be attached to glasses, headphones, caps or something else.
*/

if starting then
   wait 200 ms
   PIE.FrameRate = 100Hz
   if Wiimote.dot2vis = true then
         var.XOffset = (Wiimote.Dot1x + Wiimote.Dot2x) / 2
         var.YOffset = (Wiimote.Dot1y + Wiimote.Dot2y) / 2
   else
      var.XOffset = Wiimote.Dot1x
      var.YOffset = Wiimote.Dot1y
   endif
   var.Angle = 200
endif

//Sensitivity
if pressed(F9) and var.Angle < 1000 then
   var.Angle = var.Angle + 50
   say (var.Angle)
else
   var.Angle = var.Angle
endif

if pressed(F10) and var.Angle > 50 then
   var.Angle = var.Angle - 50
   say (var.Angle)
else
   var.Angle = var.Angle
endif

//Maprange
var.MinIRX = var.XOffset - var.Angle
var.MaxIRX = var.XOffset + var.Angle
var.MinIRY = var.YOffset - var.Angle
var.MaxIRY = var.YOffset + var.Angle

//Center View
if pressed(F11) then
   if Wiimote.dot2vis = true then
      var.XOffset = (Wiimote.Dot1x + Wiimote.Dot2x) / 2
      var.YOffset = (Wiimote.Dot1y + Wiimote.Dot2y) / 2
   else
      var.XOffset = Wiimote.Dot1x - var.TempX
      var.YOffset = Wiimote.Dot1y - var.TempY
   endif
   say "Center View"
endif

//Mapset
if Wiimote.dot2vis = true then
   var.TempDot2x = Wiimote.Dot2x
   var.TempDot1x = Wiimote.Dot1x
   var.TempDot2y = Wiimote.Dot2y
   var.TempDot1y = Wiimote.Dot1y
   var.X = (Wiimote.Dot1x + Wiimote.Dot2x) / 2
   var.Y = (Wiimote.Dot1y + Wiimote.Dot2y) / 2

   if var.TempDot1x < var.TempDot2x then
      var.TempX = (Wiimote.Dot2x - Wiimote.Dot1x) / 2
   else
      var.TempX = (Wiimote.Dot1x - Wiimote.Dot2x) / 2
   endif
   if var.TempDot1y < var.TempDot2y then
      var.TempY = (Wiimote.Dot2y - Wiimote.Dot1y) / 2
   else
      var.TempY = (Wiimote.Dot1y - Wiimote.Dot2y) / 2
   endif
else
   if var.TempDot1x < var.TempDot2x then
      var.X =  Wiimote.Dot1x + var.TempX
   else
      var.X =  Wiimote.Dot1x - var.TempX
   endif
   if var.TempDot1y < var.TempDot2y then
      var.Y =  Wiimote.Dot1y + var.TempY
   else
      var.Y =  Wiimote.Dot1y - var.TempY
   endif
endif

//smoothing
var.TrackIRYawOld = var.FakeTrackIRYaw
var.TrackIRPitchOld = var.FakeTrackIRPitch
var.FakeTrackIRYaw = ensureMapRange(var.X, var.MaxIRX, var.MinIRX , -360, 360)
var.FakeTrackIRPitch = ensureMapRange(var.Y, var.MinIRY, var.MaxIRY , -360, 360)

if var.TrackIRYawOld < var.FakeTrackIRYaw then
   var.DiffX = var.FakeTrackIRYaw - var.TrackIRYawOld
   else
   var.DiffX = var.TrackIRYawOld - var.FakeTrackIRYaw
endif
if var.DiffX < 10 then
   FakeTrackIR.Yaw = var.FakeTrackIRYaw
endif

if var.TrackIRPitchOld < var.FakeTrackIRPitch then
   var.DiffY = var.FakeTrackIRPitch - var.TrackIRPitchOld
   else
   var.DiffY = var.TrackIRPitchOld - var.FakeTrackIRPitch
endif
if var.DiffY < 10 then
   FakeTrackIR.Pitch = var.FakeTrackIRPitch
endif

debug = ' Yaw=' + FakeTrackIR.Yaw + ' Pitch=' + FakeTrackIR.Pitch + ' Battery=' + Wiimote.Battery
Back to top
View user's profile Send private message
Cyph3r



Joined: 02 Apr 2008
Posts: 2

Digg It
PostPosted: Wed Apr 02, 2008 11:32 am    Post subject:

hey ive been using this in IL2 and its pretty good, except its really jumpy and i have to turn the sensitivy to like a 1000 to remedy it, but its still quite jumpy, is there any way you can add a small deadzone or something? or make it so it smoothes the head movements?
Back to top
View user's profile Send private message
Cyph3r



Joined: 02 Apr 2008
Posts: 2

Digg It
PostPosted: Thu Apr 03, 2008 10:43 pm    Post subject:

does no one reply on these forums??
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