Head Tracking Hook for XWA

A Forum dedicated to the Suggestion, Creation and Editing of XWA Dynamic Link Library Files

Moderator: JeremyaFr

Head Tracking Hook for XWA

User avatar
blue_max
XWAU Member
Posts: 2293
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue May 28, 2019 11:29 pm

A few days ago, Justagai was kind enough to send me the source code for his cockpit look hook. I extended it to add support for FreePIE and SteamVR (so, this is 90% Justagai's work).

The new hook can be downloaded from this location:

https://www.dropbox.com/s/svjq1lerwkg57 ... 1.zip?dl=0

This is *not* a mouse look hook. Mouse look doesn't have to be enabled for this hook to work -- in fact, if you enable mouse look and then move the mouse it probably won't work.

In other words, the absolute position of the head tracker is directly applied to the in-game's camera. All you need to do is display the cockpit. I've tested this hook for a while and I usually only have to calibrate the position once at the beginning. I haven't noticed any significant drift yet (or at all, actually).

This hook currently supports FreePIE and SteamVR. SteamVR requires a VR headset; but FreePIE can be used with a number of solutions that don't require VR at all. I'll add support for other trackers (like OpenTrack) later.

NOTE: This hook conflicts with "Hook_Windowed.dll". So just move that DLL out of the installation directory or rename the extension for ".dl_".

Enjoy!

User avatar
Driftwood
Admiral (Moderator)
Posts: 2174
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Wed May 29, 2019 1:38 am

Track IR please.

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Wed May 29, 2019 3:05 am

Amazing work!

I am also hopeful for future TrackIR compatibility!
X-Wing pilot since 1993 and still kickin'

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Wed May 29, 2019 4:22 am

Same, I have track IR, but I think free track is useable with the track IR hardware. Guess I need to start putting IR reflector strips on my TIE pilot helmet. ;)
Image Image Image Image Image

User avatar
blue_max
XWAU Member
Posts: 2293
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Wed May 29, 2019 4:58 am

Alright, I hear you guys: TrackIR support is coming next. However, since I don't have TrackIR, I'm going to need your help here. From what I understand, TrackIR is not open source and the devs behind it are very careful about who they share it with. On the other hand, I believe OpenTrack supports TrackIR.

So, here's my question for you guys: if I add support for OpenTrack, will that be enough to support TrackIR as well?

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Wed May 29, 2019 11:26 am

If you get that far, I think we can start finding out for you. I swear i used freetrack for something with my track IR hardware before.
Image Image Image Image Image

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Wed May 29, 2019 2:22 pm

FreeTrack 2.2.0.279 - Maintenance Release ( on 11.20.2008 at 11:20 )

This is a maintenance release.

Natural Point™ requested us to remove Track-IR™ cameras support from FreeTrack.
X-Wing pilot since 1993 and still kickin'

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Wed May 29, 2019 3:02 pm

Good grief. It must have been after 2008 when I did it so that means I had some hack or workaround I think.

That or at the time they announced that they asked to remove support, and then never addressed if they did actually remove support, and then when you actually tried it still worked. It was some janky word-jitsu-fu designed to be a big middle finger to NaturalPoint.

Either way, I remember that was the reason I stopped recommending Track IR.

I think the project i tried it on was a 64bit linux build of Kerbal space program and that would have had to have been post 2011.

EDIT: I think it may have been an older version of freetrack that still had ingrained TrackIR camera support. According to the forums it was removed in later versions. If we can still download older versions of freetrack it might work. So DL FreeTrack V2.2 instead of the 2.2.0.279 Maintenance release that removed support. When bluemax gets Freetrack support sorted, I'm going to test with 2.2
Image Image Image Image Image

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Wed May 29, 2019 4:11 pm

Looking at FreePIE on the Script Examples page it looks like there is already a way to import TrackIR data, but I know nothing of Python scripting. :(

Code: Select all

def update():
    yaw = trackIR.yaw
    pitch = trackIR.pitch
X-Wing pilot since 1993 and still kickin'

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Wed May 29, 2019 4:53 pm

blue_max wrote:
Wed May 29, 2019 4:58 am
So, here's my question for you guys: if I add support for OpenTrack, will that be enough to support TrackIR as well?

I installed OpenTrack but I could not get the software to recognize the TrackIR camera. I googled around and others found the same thing.
X-Wing pilot since 1993 and still kickin'

User avatar
blue_max
XWAU Member
Posts: 2293
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Wed May 29, 2019 5:19 pm

ffaaway wrote:
Wed May 29, 2019 4:11 pm
Looking at FreePIE on the Script Examples page it looks like there is already a way to import TrackIR data, but I know nothing of Python scripting. :(
This is interesting. I'm coding "blind" here; but I think the script needs to look like this:

Code: Select all

def update():
    freePieIO[0].yaw = trackIR.yaw
    freePieIO[0].pitch = trackIR.pitch
    diagnostics.watch(freePieIO[0].yaw)
    diagnostics.watch(freePieIO[0].pitch)

if starting:
    trackIR.update += update
Save this to a file, say "trackir.py", run FreePIE and load the script. Then go to Script -> Run Script (or press F5) and check the lower tab named "Watch". Let me know if that works...

User avatar
blue_max
XWAU Member
Posts: 2293
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Thu May 30, 2019 5:11 am

You can also try the following script just to check if FreePIE supports TrackIR:

Code: Select all

diagnostics.watch(trackIR.yaw)
diagnostics.watch(trackIR.pitch)
Again, you guys should see some values in the Watch tab after running this script. Also, the XWA cockpit look hook expects values in degrees in the following ranges:

yaw:
right: 90
back: 180
left: 270
front: 0/360

pitch:
up: 90
front: 0/360
down: -90
back: 0/360

User avatar
blue_max
XWAU Member
Posts: 2293
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Thu May 30, 2019 6:34 am

Alright guys. I wrote a small console application that attempts to read from TrackIR. You can download it here:

https://www.dropbox.com/s/u1yp20rijk0uh ... r.exe?dl=0

It should be placed on the same path as TrackIR -- or more specifically, it should be placed right next to NPClient.dll.

I don't have TrackIR hardware, so I tested it with a simulator of sorts. Can any of you test this for me?

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Thu May 30, 2019 12:34 pm

Give me about 10 hours.
Image Image Image Image Image

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Thu May 30, 2019 3:37 pm

Trying to test the TrackIR-tester but getting vcruntime140d.dll and ucrtbased.dll not found errors.

Tried installing Microsoft Visual C++ 2015 Redistributable Update 3 RC but it says I already have a newer version installed, and now I have to go to work.

lol

Will try and sort this out later.
X-Wing pilot since 1993 and still kickin'

User avatar
blue_max
XWAU Member
Posts: 2293
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Thu May 30, 2019 5:57 pm

Ugh, sorry about that, Try this version instead (I removed the dependencies to the VC runtime):

https://www.dropbox.com/s/04783ql2rjkzv ... r.exe?dl=0

In my case, I have to place this file under "C:\Program Files (x86)\NaturalPoint\TrackIR5". Thanks for your help and patience!

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Fri May 31, 2019 1:04 am

1. Ok, got my Track IR camera out and track clip pro on my headset.

2. Installed Track IR Software 5.4.2

3. Moved Hook_Windowed.dll to its own UNUSED HOOKS FOLDER

4. Installed TrackIR-Tester.exe @ my C:\Program Files (x86)\NaturalPoint\TrackIR5

5. Installed your file below in
Hook_XWACockpitLook.dll
openvr_api.dll
cockpitlook.cfg

6. Ran Track IR Software and your TrackIR-Tester.exe
-I see a windo pop up continuously outputting
[DBG] [Cockpitlook] yaw: 0.000, pitch 0.000
Doesn't seem to change with motion of track IR camera.

7. Ran game, loaded a mission. Loads to hangar, after hitting space to leave hangar and the animation leaving the hangar finishes, the game crashes to desktop.
Image Image Image Image Image

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Fri May 31, 2019 1:04 am

1. Ok, got my Track IR camera out and track clip pro on my headset.

2. Installed Track IR Software 5.4.2

3. Moved Hook_Windowed.dll to its own UNUSED HOOKS FOLDER

4. Installed TrackIR-Tester.exe @ my C:\Program Files (x86)\NaturalPoint\TrackIR5

5. Installed your file below in
Hook_XWACockpitLook.dll
openvr_api.dll
cockpitlook.cfg

6. Ran Track IR Software and your TrackIR-Tester.exe
-I see a windo pop up continuously outputting
[DBG] [Cockpitlook] yaw: 0.000, pitch 0.000
Doesn't seem to change with motion of track IR camera.

7. Ran game, loaded a mission. Loads to hangar, after hitting space to leave hangar and the animation leaving the hangar finishes, the game crashes to desktop.

I feel like I'm missing an obvious step here. I also wonder if it is conflicting with one of Justagai's hooks. Point is I'm not sure I have a control experiment setup here.
Image Image Image Image Image

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Fri May 31, 2019 1:39 am

I̶'̶m̶ ̶n̶o̶t̶ ̶t̶h̶e̶ ̶e̶x̶p̶e̶r̶t̶ ̶h̶e̶r̶e̶ ̶b̶u̶t̶ ̶I̶ ̶d̶o̶n̶'̶t̶ ̶t̶h̶i̶n̶k̶ ̶y̶o̶u̶ ̶n̶e̶e̶d̶ ̶o̶p̶e̶n̶v̶r̶_̶a̶p̶i̶.̶d̶l̶l̶ ̶w̶i̶t̶h̶ ̶t̶r̶a̶c̶k̶i̶r̶.̶

This .dll is needed! See below.
Last edited by ffaaway on Fri May 31, 2019 4:49 am, edited 1 time in total.
X-Wing pilot since 1993 and still kickin'

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Fri May 31, 2019 2:01 am

blue_max wrote:
Thu May 30, 2019 6:34 am
It should be placed on the same path as TrackIR -- or more specifically, it should be placed right next to NPClient.dll.

I don't have TrackIR hardware, so I tested it with a simulator of sorts. Can any of you test this for me?
Here are my results.

Image

Full size image:
https://drive.google.com/file/d/1LsHJ3u ... sp=sharing

Tester doesn't seem to be polling the TrackIR software. I do have NPClient64.dll, maybe it needs to look for the 64 bit version??
X-Wing pilot since 1993 and still kickin'

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Fri May 31, 2019 2:08 am

I also have NPClient64.dll
Image Image Image Image Image

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Fri May 31, 2019 2:19 am

blue_max wrote:
Thu May 30, 2019 5:11 am
You can also try the following script just to check if FreePIE supports TrackIR:

Code: Select all

diagnostics.watch(trackIR.yaw)
diagnostics.watch(trackIR.pitch)
Again, you guys should see some values in the Watch tab after running this script. Also, the XWA cockpit look hook expects values in degrees in the following ranges:

yaw:
right: 90
back: 180
left: 270
front: 0/360

pitch:
up: 90
front: 0/360
down: -90
back: 0/360
This script is WORKING! FreePIE is getting data from TrackIR and the values match with your given ranges.
X-Wing pilot since 1993 and still kickin'

User avatar
ual002
XWAU Member
Posts: 983
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Fri May 31, 2019 2:46 am

Ok, how did you do that?
Image Image Image Image Image

User avatar
Driftwood
Admiral (Moderator)
Posts: 2174
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Fri May 31, 2019 2:48 am

Well, if this winds up functional then this may make me happier with the game in a big way lol.

User avatar
ffaaway
Rebel Alliance
Posts: 92
Joined: Mon May 05, 2003 11:01 pm

Post by ffaaway » Fri May 31, 2019 3:02 am

blue_max wrote:
Wed May 29, 2019 5:19 pm
ffaaway wrote:
Wed May 29, 2019 4:11 pm
Looking at FreePIE on the Script Examples page it looks like there is already a way to import TrackIR data, but I know nothing of Python scripting. :(
This is interesting. I'm coding "blind" here; but I think the script needs to look like this:

Code: Select all

def update():
    freePieIO[0].yaw = trackIR.yaw
    freePieIO[0].pitch = trackIR.pitch
    diagnostics.watch(freePieIO[0].yaw)
    diagnostics.watch(freePieIO[0].pitch)

if starting:
    trackIR.update += update
Save this to a file, say "trackir.py", run FreePIE and load the script. Then go to Script -> Run Script (or press F5) and check the lower tab named "Watch". Let me know if that works...
Ok, I loaded the script above in FreePIE and it does appear to be getting tracking data from trackIR.

Image

ran the game
mouselook works normally in the hangar, but is disabled once in flight - as per the readme
but FreePIE doesn't seem to be communicating with the game

I made no changes to the cockpitlook.cfg

Code: Select all

tracker_type = FreePIE

yaw_multiplier = 1
pitch_multiplier = 1
The Hook_XWACockpitLook.dll is correctly placed.

What else could I be missing? This SEEMS SO CLOSE!!!!

Oh, and Hook_Windowed.dll is moved out of XWA folder.

Edit 2 -
FIXED AND WORKING!! Thanks to ual002 for correcting me needing the openvr_api.dll :)
Last edited by ffaaway on Fri May 31, 2019 4:47 am, edited 2 times in total.
X-Wing pilot since 1993 and still kickin'

Post Reply