Head Tracking Hook for XWA

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

Moderator: JeremyaFr

Re: Head Tracking Hook for XWA

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

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

ual002 wrote:
Fri May 31, 2019 2:46 am
Ok, how did you do that?
I should clarify this comment, LOL

All I meant to say was the SCRIPT was working in FreePIE to get the data from the TrackIR software - It was progress lol but I still do not have TrackIR in game.

Still fiddling!
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 3:04 am

Do you have discord? I've got a line with blue_max right now
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 3:13 am

ual002 wrote:
Fri May 31, 2019 3:04 am
Do you have discord? I've got a line with blue_max right now
Yeah, how do we hook up? check PM for my discord name.
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 4:18 am

IT LEGIT WORKS! More info to follow. 2DOF, pitch and yaw, not mouselook. My god its glorious.
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 4:53 am

Yes yes YES! It SOOO works!!!!

I'll post a step by step guide later.

Thank you so much Justagai and blue_Max and anyone else involved who made this happen!

Having perfectly functioning head tracking is the icing on the cake for viewing this glorious XWAUP!!!
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 » Fri May 31, 2019 5:24 am

I'm so glad you guys got it working! Just a few things:

1. For FreePIE you *don't* need openvr_api.dll: if the hook is crashing without this file it's only my fault! Sorry about that. I'll fix that in the next release.
2. I think you need *the* single copy of NPClient.dll that comes with TrackIR. FreePIE comes with its own NPClient.dll, so that DLL has to be renamed to NPClient.dl_ or something so that FreePIE doesn't load it. You may need to add the path where TrackIR's NPClient.dll is located to the PATH environment variable in Windows. NPClient64.dll is probably irrelevant (?)
3. The script doesn't need the lines that begin with "diagnostics*" -- that's just for debugging. So, once you get it running, you can comment those lines out by adding a leading # at the beginning of the line.
4. Justagai is the genius that decompiled the binary and provided a fully-functional hook. I'm just the monkey that connected the dots.
5. Since the script worked, I think I can add support for TrackIR through FreePIE in the next release.
6. It's even better in VR ;)

However, I'll wait for your guide since I'm half-guessing here :P

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

Post by blue_max » Fri May 31, 2019 5:40 am

Also, the game only supports yaw/pitch natively. I think 6dof is technically possible; but it will have to be hacked-in and it may not look great (you'll be able to see around the edges of the cockpit, for instance, if you lean too much).

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

Post by ffaaway » Fri May 31, 2019 5:49 am

blue_max wrote:
Fri May 31, 2019 5:24 am
However, I'll wait for your guide since I'm half-guessing here :P
I was gonna hold off on posting a guide until the next round of releases since things will be changing. Heh
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 » Fri May 31, 2019 6:42 am

ffaaway wrote:
Fri May 31, 2019 5:49 am
blue_max wrote:
Fri May 31, 2019 5:24 am
However, I'll wait for your guide since I'm half-guessing here :P
I was gonna hold off on posting a guide until the next round of releases since things will be changing. Heh
Well, if you post a guide, I think it would actually help *me* figure out what I'm missing -- and it will help others get this working while I'm working on the next release ;)

Also, I've been looking at the code and I don't see why the Hook is forcing you guys to use openvr_api.dll. Can you check what cockpitlook.cfg says? It should have "tracker_type = FreePIE".

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

Post by ffaaway » Fri May 31, 2019 1:44 pm

blue_max wrote:
Fri May 31, 2019 6:42 am
ffaaway wrote:
Fri May 31, 2019 5:49 am
blue_max wrote:
Fri May 31, 2019 5:24 am
However, I'll wait for your guide since I'm half-guessing here :P
I was gonna hold off on posting a guide until the next round of releases since things will be changing. Heh
Well, if you post a guide, I think it would actually help *me* figure out what I'm missing -- and it will help others get this working while I'm working on the next release ;)

Also, I've been looking at the code and I don't see why the Hook is forcing you guys to use openvr_api.dll. Can you check what cockpitlook.cfg says? It should have "tracker_type = FreePIE".
Ok, I'll post exactly the steps to get tIR working, and my cockpitlook.cfg is default - no changes.
X-Wing pilot since 1993 and still kickin'

Justagai
Cadet 1st Class
Posts: 218
Joined: Mon Dec 08, 2014 10:59 pm

Post by Justagai » Fri May 31, 2019 2:25 pm

Very good work folks.

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

Post by ffaaway » Fri May 31, 2019 2:28 pm

*** THIS POST IS DEPRECIATED AS OF RELEASE 0.9.2 FreePIE IS NO LONGER REQUIRED - STAND BY FOR UPDATES ***


Proceedure for TrackIR in XWA as of 5-31-19

1. Download hook xwa_cockpitlook-0.9.1
2. Download and install FreePIE
3. Make sure xwa_hook_main is installed in your XWA folder. The file name is dinput.dll. (This comes pre-installed with XWAUP or DSUCP)
4. Remove or rename Hook_Windowed.dll from XWA folder.
5. Drop cockpitlook.cfg + Hook_XWACockpitLook.dll + openvr_api.dll into XWA folder. (subject to change!)
6. Open cockpitlook.cfg and set "pitch_multiplier = -1" (this inverts the pitch - @blue_max, This should probably be changed in the original download file by default to avoid confusion)
7. Run TrackIR software (make a profile with Pitch and Yaw on Smooth power curves.)
8. Run FreePIE
9. Create a new .txt file and copy/paste this code: (blue_max post)
  • 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
    
10. Save this file and name it trackir.py (This script can be saved anywhere and named anything, I chose to save it in my FreePIE directory.)
11. In FreePIE, click FILE/OPEN and browse to your trackir.py script file.
12. Click SCRIPT/RUN SCRIPT (or press F5) This will grab the TrackIR software data and make it usable in FreePIE. You can click the WATCH tab and verify that FreePIE is recieving data.
13. Run game and enjoy REAL TrackIR headtracking - Thanks guys!!
Last edited by ffaaway on Tue Jun 04, 2019 2:34 pm, 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:29 pm

Justagai wrote:
Fri May 31, 2019 2:25 pm
Very good work folks.
Very good hook Justagai! Thanks, LOVE IT!
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 3:44 pm

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 3:58 pm

ual002 wrote:
Fri May 31, 2019 3:44 pm
https://www.youtube.com/embed/DH7FdI5OWX4

Here is a test video of it
Excellent! I can scratch "make video" off my todo list lol!
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 » Fri May 31, 2019 6:43 pm

Thanks for posting this guide, ffaaway!

* pitch_multiplier = 1 works for me when reading data directly from FreePIE; but I'll take note of this if I manage to get native support for TrackIR.
* I think I understand now why the hook is trying to load openvr_api.dll. As I said previously, this is my fault. I'll fix this.
* The lines that begin with "diagnostics" are not really needed. After you get the script working, you may remove them or comment them out.

I've been looking at how FreePIE supports TrackIR and it looks like I still need to guess what's the right protocol here -- and it doesn't help that I'm working blind. Checking in Natural Point's page, it looks like there's a track clip for less than $10. If I buy this, will I be able to get all the features of TrackIR?

@ual002: Beautiful video! Just watching that makes me want to hack-in support for 6dof. Maybe in the near future...

User avatar
DTM
Fleet Admiral (Administrator)
Posts: 2119
Joined: Tue Apr 22, 2003 11:01 pm
Contact:

Post by DTM » Fri May 31, 2019 7:27 pm

Thank you guys! I've been waiting for something like that for years!

IT WORKS PERFECTLY!!!

I'm happy as a child!!! :D :D :D :D :D

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

Post by ffaaway » Fri May 31, 2019 8:51 pm

blue_max wrote:
Fri May 31, 2019 6:43 pm
Thanks for posting this guide, ffaaway!
My pleasure, but it's really just a listed version of this thread and your instructions. :P Plus a couple tips from ual002!
* pitch_multiplier = 1 works for me when reading data directly from FreePIE; but I'll take note of this if I manage to get native support for TrackIR.
Definately requires -1 for trackIR. I checked the TIR software to see if I had enabled inverted pitch but I could not find any such setting.
* I think I understand now why the hook is trying to load openvr_api.dll. As I said previously, this is my fault. I'll fix this.
Can't wait to see the future developement of this hook!!!
* The lines that begin with "diagnostics" are not really needed. After you get the script working, you may remove them or comment them out.
My final guide will have these removed, it's nice to see the values changing during setup :)
I've been looking at how FreePIE supports TrackIR and it looks like I still need to guess what's the right protocol here -- and it doesn't help that I'm working blind. Checking in Natural Point's page, it looks like there's a track clip for less than $10. If I buy this, will I be able to get all the features of TrackIR?
Getting the trackclip won't help you, you could do the same by sticking reflective tape on a cap or something heh. You would also need an infrared camera, or make your own, plus I really doubt the TIR software/drivers would work without native hardware, but I could be wrong about that.

Do a search for "DIY head tracking" and you may find something that you could build for cheap that you could test with, but all of those tips would probably use opentrack or freetrack and still not bring in the native TIR software data.

To be honest, I'm thrilled to have this working even as is and setup wasn't too hard after ual002 pointed me to drop in the openvr dll.

Basically the difference from my old 2010 guide, we just replace TiRMouse.exe with FreePIE and get MUCH improved headtracking. :) :) :) and a LOT LESS re-centering rofl :D :D :D

THANK YOU for your work and R&D getting us TrackIR user's head-in-the-game !
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 8:54 pm

I need some reflective tape for my TIE bucket for real, anyone have a guide for what patterns I can place them in?
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 8:58 pm

Just think what Track IR and a triple wide monitor with a modified UI would be like. I know triple wide works, but the UI MFDs get moved to the extreme corners. Once we find a way to modify that we can have some serious simming potential. Hell, think of what it would be like if we break that UI code open we very well might be able to render the UI radar and scanner elements onto the elements that make up the various 3D cockpits instead of it being just an overlay.
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 » Sat Jun 01, 2019 12:15 am

ual002 wrote:
Fri May 31, 2019 8:58 pm
think of what it would be like if we break that UI code open we very well might be able to render the UI radar and scanner elements onto the elements that make up the various 3D cockpits instead of it being just an overlay.
This might be possible without breaking the UI code (?), at least partially; but we need a texture that serves as a marker/reference point and a place in the 3D cockpit where said texture is attached.

So, how does this work guys? Do you experience drift? Is it stable? Do you have to keep on re-centering often?

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

Post by ffaaway » Sat Jun 01, 2019 1:01 am

blue_max wrote:
Sat Jun 01, 2019 12:15 am
So, how does this work guys? Do you experience drift? Is it stable? Do you have to keep on re-centering often?
Imho its flawless. No drift, totally stable (so far!) And can easily play entire missions without re-centering.

Total godsend!
X-Wing pilot since 1993 and still kickin'

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

Post by Driftwood » Sat Jun 01, 2019 3:47 pm

blue_max wrote:
Fri May 31, 2019 6:43 pm
Thanks for posting this guide, ffaaway!

* pitch_multiplier = 1 works for me when reading data directly from FreePIE; but I'll take note of this if I manage to get native support for TrackIR.
* I think I understand now why the hook is trying to load openvr_api.dll. As I said previously, this is my fault. I'll fix this.
* The lines that begin with "diagnostics" are not really needed. After you get the script working, you may remove them or comment them out.

I've been looking at how FreePIE supports TrackIR and it looks like I still need to guess what's the right protocol here -- and it doesn't help that I'm working blind. Checking in Natural Point's page, it looks like there's a track clip for less than $10. If I buy this, will I be able to get all the features of TrackIR?

@ual002: Beautiful video! Just watching that makes me want to hack-in support for 6dof. Maybe in the near future...
So does that mean we won't be needing openvr_api.dll?

And, can the hook be written in a way to not require removing the windowed.dll? And if not, why?

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Jun 01, 2019 4:31 pm

Driftwood wrote:
Sat Jun 01, 2019 3:47 pm
And, can the hook be written in a way to not require removing the windowed.dll? And if not, why?
Both hooks hook the function at address 0x4F9A5F that retrieves the keyboard state.
One of the hook must be rewritten to avoid the conflict.

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

Post by ual002 » Sat Jun 01, 2019 4:36 pm

As far as the function its pretty much what you can expect. I noticed a little stuttering, not in the tracking but in the game itself, not sure if its related or if its because I was also recording.
Image Image Image Image Image

Post Reply