Help with Android to TrackIR script

Official forum for open source FreePIE discussion and development.
Post Reply
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Help with Android to TrackIR script

Post by RescueGamer »

Hi everyone, i'm trying to get headtracking on Dirt 3 with my DIY Rift which uses an android phone as tracker. Normally I use mouse emulation or the shared memory tracker plugin (only in vireio perception) with freepie. Since I don't know how to use the mouse on Dirt 3 I'm trying to use a script Android-TrackIR to get headtracking on the game knowing that Dirt 3 support head tracking with trackIR; but I can get anything functional, all Ii get on the trackIR variables is 0. So there's anyone who knows how to do a script for this?

Thanks!
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Help with Android to TrackIR script

Post by CyberVillain »

Dirt 2 worked with FreePIE with TrackIR fixer

http://naturalpointofview.blogspot.se/p ... fixer.html

Have you tried that?

You can base your script on the android > freetrack sample

http://andersmalmgren.github.io/FreePIE ... -freetrack

edit: Also we have gotten a few tips from the Opentrack team members that we are going to implement soon, we are a bit busy with work etc so it might take some time
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Help with Android to TrackIR script

Post by RescueGamer »

Thanks for the info, I will try trackIR Fixer or basing on the freetrack script. Hope I can get this working :)
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Help with Android to TrackIR script

Post by RescueGamer »

Nothing, i tried with trackirFixer, it catched the games, but don't move anything on cockpit view. Then I tried whit this script:
def update():
global yaw
yaw = android[0].yaw
global pitch
pitch = -android[0].roll
global roll
roll = android[0].pitch

if starting:
centerYaw = 0
centerPitch = 0
centerRoll = 0

yaw = 0
pitch = 0
roll = 0
android[0].update += update

trackIR.yaw = yaw - centerYaw
trackIR.pitch = pitch - centerPitch
trackIR.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll
But I don't see changes on the trackit program, and I can get anything on the gaming, I'm trying now with f1 2011 but nothing. This script is right? and another thing, if the script is right, I have to do something more in the trackir application or the games?
Another thing, with the freetrack script I don't see anything on the freetrack application too, I have to do something to activate freetrack or something?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Help with Android to TrackIR script

Post by CyberVillain »

RescueGamer wrote: ...
Android uses radians and TackIR Degrees so you need to convert to degrees (Radians might be to small to show any output in trackir)

Wrap the output from anroid with math.degrees, i.e

yaw = math.degrees(android[0].yaw)
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Help with Android to TrackIR script

Post by RescueGamer »

OK, so now I used this:

Code: Select all

def update():
    diagnostics.watch(trackIR.yaw)
    global yaw
    yaw = math.degrees(android[0].yaw)
    global pitch
    pitch = math.degrees(-android[0].roll)
    global roll
    roll = math.degrees(android[0].pitch)

if starting:
    centerYaw = 0
    centerPitch = 0
    centerRoll = 0
   
    yaw = 0
    pitch = 0
    roll = 0
    android[0].update += update

trackIR.yaw  = yaw - centerYaw
trackIR.pitch = pitch - centerPitch
trackIR.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
    centerYaw = yaw
    centerPitch = pitch
    centerRoll = roll
And in the wacth I see TrackIR.yaw 0, and doesn't change
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Help with Android to TrackIR script

Post by CyberVillain »

RescueGamer wrote:OK, so now I used this:

Code: Select all

def update():
    diagnostics.watch(trackIR.yaw)
    global yaw
    yaw = math.degrees(android[0].yaw)
    global pitch
    pitch = math.degrees(-android[0].roll)
    global roll
    roll = math.degrees(android[0].pitch)

if starting:
    centerYaw = 0
    centerPitch = 0
    centerRoll = 0
   
    yaw = 0
    pitch = 0
    roll = 0
    android[0].update += update

trackIR.yaw  = yaw - centerYaw
trackIR.pitch = pitch - centerPitch
trackIR.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
    centerYaw = yaw
    centerPitch = pitch
    centerRoll = roll
And in the wacth I see TrackIR.yaw 0, and doesn't change
It does not work like that, for x = trackIR.yaw you need a real trackIR to read from

trackIR.yaw = x is fine since that will emulate trackIR
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Help with Android to TrackIR script

Post by RescueGamer »

You were right, it worked! The final script I'm using is this:
def update():
global yaw
yaw = filters.deadband(math.degrees(filters.continousRotation(android[0].googleYaw)), deadband)
global pitch
pitch = filters.deadband(math.degrees(-android[0].googleRoll), deadband)
global roll
roll = filters.deadband(math.degrees(-android[0].googlePitch), deadband)

if starting:
deadband = 0.01
centerYaw = 0
centerPitch = 0
centerRoll = 0

yaw = 0
pitch = 0
roll = 0
android[0].update += update

trackIR.yaw = yaw - centerYaw
trackIR.pitch = pitch - centerPitch
trackIR.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll
Thanks for all, it works great!
Cercata
One Eyed Hopeful
Posts: 21
Joined: Fri Oct 17, 2014 1:50 am

Re: Help with Android to TrackIR script

Post by Cercata »

RescueGamer wrote:Thanks for all, it works great!
With or Without TrackIR fixer ?

I tryed yesterday with F1 2012 and it didn't work for me, today I'll try Dirt 2/3.

Edit:
It's working now, with F1 2012, Dirt 3 and GTR2. AMAZING !!!!
Yesterday the problem was that I wasn't in the cockpit view, silly me :(
Post Reply

Return to “FreePIE”