TrackIR emulation coming soon

Official forum for open source FreePIE discussion and development.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: TrackIR emulation coming soon

Post by CyberVillain »

ITGuy327 wrote:I receive the following error when I run the scripts.
"Error occured while reading from TrackIR dll: 7"
Btw, does Glovepie work?
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

I haven't really used glovepie but I can try if you can get info from it. Just let me know.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: TrackIR emulation coming soon

Post by CyberVillain »

ITGuy327 wrote:I haven't really used glovepie but I can try if you can get info from it. Just let me know.
Would be nice to know if they have managed to read, won't give more info, but ayleast We know its possble :)

@Wired, have you tried the plugin?
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

ITGuy327, I'll try one more thing plus add logging to tell which method fails... The error code unfortunately tells me nothing, since it's an internal error code specific to TrackIR, and the SDK isn't available for non-commercial use.

I'll upload it in a few hours or so.
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Alright, two new DLL's. Please repeat the usual steps. :) There will be two logs file under the root directory of freepie: NPClientLog.txt and TrackIRLog.txt. TrackIRLog.txt will contain any error occured while reading from TrackIR.

ITGuy: Please check this log file to see exactly which functions fail.

Anyone testing writing with freepie to trackir, please post the RequestData and RegisterProgramProfileId entries of NPClientLog.txt... Trying to get more data on what the parameters are.

Thanks everybody. :)
You do not have the required permissions to view the files attached to this post.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Here are my results with latest DLL.

I'm running FreeSpace2 Open Source
TrackIR works in game without FreePIE running
I run FreePIE with a script and then start the game. Game does not detect TrackIR.

My error logs are attached. If the code is committed to git, I can check it out and see if I can dig deeper too.

--just a note, the TrackIR has a left and right led, both are lit when a compatible game and tracking is available.
You do not have the required permissions to view the files attached to this post.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

CyberRascal - I have 3 PM's sitting in my Outbox on this forum, not sure how to get them out, if you can confirm you received them since 5:22pm EST (New York)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: TrackIR emulation coming soon

Post by CyberVillain »

ITGuy327 wrote:CyberRascal - I have 3 PM's sitting in my Outbox on this forum, not sure how to get them out, if you can confirm you received them since 5:22pm EST (New York)
If i know my brother ITGuy he will be a sleep until 12 (GMT +1) :D
I will make sure he reads them, thansk for your help, hope to get this cracked soon :D
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Good for him. Sleep whenever possible. I get very little these days.lol
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Hey, got two new DLL's for ya :)

The logs you posted shows that TrackIR's NPClient.dll seems to reject the ProgramProfileId. This isn't surprising, since what I use is just a random number. I'm reluctant to use the same ID as another game, but let's atleast try it. I don't have TrackIR myself so I can't disassemble the DLL and try to look for a pattern that way / how they validate the id.

The new DLL's read and write from a file called StartupParameters.xml. This is just a temporary dev config file. I tried using .nets XmlSerializer, but it just wouldn't load the type from the Plugin assembly, guessing it has something to do with the fact that the dll is dynamically loaded.

Anyway, when you run a trackir script it will generate a default StartupParameters file, with values taken from how Grid calls the fake dll, I think.

Please try just running a script reading from TrackIR, and hopefully it will work. Anyway, please post the logs here :) If it doesn't work, you can try tweaking the values in the file. They have to fit into a 'short' though.

Cheers :)
You do not have the required permissions to view the files attached to this post.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

The new DLL automatically activates the TrackIR right led (indicating a compatible game is detected), this is consistent with the profile id you have defaulted to, which is FreeSpace2. This file on the linuxtrack-wine project has what appears to be a fairly accurate list of games with profile info http://code.google.com/p/linuxtrack-win ... a/apps.xml

The game id's are validated against a file supplied by np, this file can be downloaded from http://www.naturalpoint.com/trackir/06- ... 111116.zip. I'm not certain if there is any calculations involved.

There is a program called TIRMouse which basically allows mouse control with TrackIR. It has limitations and is basically a dumbed down version of what it used to be since np launched smartnav.

I'll keep tinkering. Thanks
You do not have the required permissions to view the files attached to this post.
Last edited by ITGuy327 on Mon Oct 01, 2012 12:12 pm, edited 1 time in total.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: TrackIR emulation coming soon

Post by CyberVillain »

Nice, but you still cant receive values from TrackIR? For a start try only to read (Not Read write in the same script)

Like diagnostics:watch(tracKIR.Yaw)
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Great info, thanks ITGuy. From the logs it seems you did managed to read data from TrackIR using FreePIE, could you confirm this though? :)
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Able to Read. Able to Write.
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Great ITGuy. Thanks. I've made a few improvements, I'd be happy if anyone can take the time to check them out:

Reading from trackir now occurs in it's own process using shared memory to communicate with freepie.

Try these scripts:

---------------------
if(starting)
then
x = 0
end

x = x + 0.01;

if(x > 90)
then
x = -90
end

trackIR.Yaw = x

------------------------------------

if(starting)
then
trackIR.Update:Add(function()
diagnostics:watch(trackIR.Yaw)
end)
end

------------------------------------

Well, the reading one is the most important. That's where the worker process is involved.

After starting, please verify that you get yaw output in the watch window. If you don't, please check for a process named something like "FreePIE.TrackIRWorker.tmpabc534.exe"

You should also get an error in the console window after 20 seconds if anything weird goes on.

Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

The logs show data being exchanged, but no errors or diagnostic messages appeared at all. The TrackIR software didn't seem to respond in the case of writing. My logs are attached.
You do not have the required permissions to view the files attached to this post.
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Hm... I didn't bother to update the logging for the new independent process model, so I disabled logging altogether. Those logs must be old ones.

All calls should be identical to the in-process method. Obviously, this is not so (it doesn't work). I suspect it might be the window handle which TrackIR requires - the independent process, being windowless and all, probably doesn't have one. It now uses the freepie window handle instead.

I've added rudimentary logging for the TrackIRWorker. Please download the attachment. This time, I've included a complete version of FreePIE, so I can be sure I've not missed attaching anything important. Just extract it anywhere.

Please try the reading script above. Check for trackirworker.txt under the root freepie folder. Also check for a running process in taskmanager called FreePIE.TrackIRWorker.{random}.exe. It should be running as soon as you start the script.

Cheers :) And sorry for the inconvenience.
You do not have the required permissions to view the files attached to this post.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

No problem at all. I'll give it a go tonight and post back.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Here are results from writing.

Sorry about my other logs, thought I had cleared them.
You do not have the required permissions to view the files attached to this post.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Reading worked and output to watch window.
You do not have the required permissions to view the files attached to this post.
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

ITGuy: Writing didn't work, right? What game?

I've made another fix to writing. Also, added logging where writing is concerned. Two files: trackirworker.txt and NPClient.log. The first is for reading, the second is for writing.

Please, try out these new DLLs. Hopefully it will work out. Works in Grid and Future Pinball on my machine.

Thanks for the effort.
You do not have the required permissions to view the files attached to this post.
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Anyone out there tried it out? What about you, ITGuy327?

Getting itchy to release it, but I'd like to know if it works for atleast someone else than me and CyberVillain before releasing it (experimentally).

Made any progress yourself?
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

I Will have it a go and let you know.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

I got writing to work. I used FreeSpace 2 Open Source has my test game. I ran the following script, modified a few times, but all produced results as expected. The only question I now have is getting the tracking to pause and re-center, typically this is done via TrackIR hotkeys f9=pause and f12 = center

Other than that, lookin good.

Any other scripts to test or games to test against.

Jay
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

ITGuy, that is damn good news. Will push to my online repo within an hour or so then (hopefully).

Anyway, do you mean on the writing or the reading side?

For reading, it should still be up to the TrackIR software as usual.

For writing, you'll have to do it manually - and how you do that depends on how you are generating values for writing. This is precisely what the scripting engine is there for.

For example, try using this script. K pauses, F9 centers:

Code: Select all

if(starting)
then
	paused = false
	x = 0
end

if(not paused)
then
	x = x + 0.01;
end
	
if(x > 90)
then
	x = -90
end

trackIR.Yaw = x

	
if(keyboard:getPressed(Key.F9)) then
    x = 0
end

if(keyboard:getPressed(Key.K)) then
    paused = not paused
end
I'm not sure what other games you can try; some of them are encrypted, but should work with the trackir fixer. Would be nice if you could try that out, if you have any compatible games. I'm going to push to github and then make CyberVillain publish another build; that way, perhaps more people are comfortable trying it out.
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Look forward to the code. After I posted I implemented Center and Pause keys. Did notice that when I tried to use F12 it required that I hold Shift + F12, not sure why the combo was required, other than that, woot!
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Great. It's all up at https://github.com/maxmalmgren/FreePIE

Brief explanation of the layout:

TrackIRWorker is where the reading from TrackIR actually happens.
NPClientSpoof is responsible for starting up an instance of TrackIRWorker and injecting the fake NPClient dll.
Freepie\Lib\NPClient contains the compiled DLL and the source for it.

CyberVillain is busy with the Android IMU / AHRS stuff so he'll merge it in when that is done and publish a new build with both components plus a little extra polish.

And that's weird about he shift issue... I'll try it myself...
User avatar
ITGuy327
One Eyed Hopeful
Posts: 27
Joined: Mon Sep 24, 2012 7:39 pm

Re: TrackIR emulation coming soon

Post by ITGuy327 »

Cool. I've also been testing the Android interface using Squidy on my Galaxy S3, so far no luck though, doesn't seem to connect.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: TrackIR emulation coming soon

Post by CyberVillain »

ITGuy327 wrote:Cool. I've also been testing the Android interface using Squidy on my Galaxy S3, so far no luck though, doesn't seem to connect.
Please give me more info in the Android thread and I can help you :D
User avatar
djdevin
Two Eyed Hopeful
Posts: 55
Joined: Wed Oct 17, 2012 1:10 pm
Location: Philadelphia, USA

Re: TrackIR emulation coming soon

Post by djdevin »

Can't get this to work with the latest FreePie, any suggestions? No errors but I can't get anything TrackIR enabled to work, even if I feed it dummy values. I can use glovepie/freetrack and that worked with TrackIR games, but I need FreePie to use the hillcrest tracker.

Thanks!

Edit: checked the log and got:
Function failed: NP_GetSignature with error: 1

Edit: nevermind, seems I was trying one too many DLLs on my system...but now I have in logs:
12/8/2012 10:53:18 PM --|-- Loading trackir dll: C:\Program Files (x86)\FreeTrack\NPClient.dll
12/8/2012 10:53:18 PM --|-- Calling dll with the following values - WindowHandle: 263372 Data: 119 ProfileId: 13302

and

NP_GetSignature
did not find signature in game - using freepie signature

strange that it keeps looking at FreeTrack, that file doesn't exist because I uninstalled it. So I dropped the one that came with Freepie in there, and now no errors but nothing happens.

edit 2: deleted old registry keys and now points to freepie. but, still no trackIR activity
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: TrackIR emulation coming soon

Post by CyberVillain »

I will notify the guy behind this plugin, thanks for feedback!

edit: btw, you must use the npclient that comes with freepie, its FreePIE specific code in it
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

djdevin:

I assume
NP_GetSignature
did not find signature in game - using freepie signature
Is still in the log, even after you cleaned up registry?

NaturalPoint has this funny thing going on where the game asks for a "signature" and the NPClient.dll is supposed to answer with a certain piece of literature containing references to trademarked naturalpoint products. Other projects has had problems with NP lawyers claiming trademark, but we'd rather avoid that, so rather than store the poem in FreePIE it searches for it in the game.

The log entry means it didn't find it, which either means

1) It's a game that has removed the check
2) The signature is not placed in such a way that FreePIE can find it.

Can you tell me what game it is?

If you'd help me further, please download Future Pinball and try using FreePIE to emulate TrackIR. It is a tested game and should work. If it doesn't, at least we know that much more.
User avatar
djdevin
Two Eyed Hopeful
Posts: 55
Joined: Wed Oct 17, 2012 1:10 pm
Location: Philadelphia, USA

Re: TrackIR emulation coming soon

Post by djdevin »

Would this have something to do with TrackIR fixer? I used it on F1 2012 and it patched the exe. Works with glovepie/freetrack.

I'll try Future Pinball and report back, thanks.
User avatar
djdevin
Two Eyed Hopeful
Posts: 55
Joined: Wed Oct 17, 2012 1:10 pm
Location: Philadelphia, USA

Re: TrackIR emulation coming soon

Post by djdevin »

Yep, Future Pinball works, F1 2012 does not. F1 2012 is on the list of games where TrackIR fixer is needed. I've tried with and without.

I understand the concern with IP law but how does Freetrack do it then?

Let me know if I can do anything more to help.

Here's the log, from running pinball, then F1 2012

NP_GetSignature
found signature in game - using it
NP_GetSignature
found signature in game - using it
NP_RegisterWindowHandle, handle: 00050480
NP_QueryVersion
NP_RequestData: data118
NP_RegisterProgramProfileId, id: 13101
NP_StartDataTransmission:
NP_GetSignature
did not find signature in game - using freepie signature
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Seems everything works as expected (i.e everything 'tested' is working).

Freetrack stores the poem in a compiled native binary (but they've had some problems with trademark AFAIK, just not fatal ones). FreePIE wants to provide fully open source software, while avoiding any trademarked material. Perhaps we've got to do it by compiling the poem into the DLL as well though.

Now to get it working.

I'll try to get my hands on F1 2012 and debug the application. I'd also like to send you a modified version of FreePIE that scans more of the game memory, and saves it in the log so that I can see why the poem isn't found.

It's very possible TrackIR fixer modifies the memory in such a way that the current location "algorithm" doesn't work as expected, but we'll see. I'll post again when I have anything to report.

Cheers :)
User avatar
djdevin
Two Eyed Hopeful
Posts: 55
Joined: Wed Oct 17, 2012 1:10 pm
Location: Philadelphia, USA

Re: TrackIR emulation coming soon

Post by djdevin »

After digging into the code this entire weekend I see what you mean :)

I tried recompiling NPClient.dll from Git, but when I dropped the new DLL into a stock Freepie install, no TrackIR emulation worked. Any tips? It ended up being a lot smaller so maybe I'm missing compile flags or something.

Also:
It's very possible TrackIR fixer modifies the memory in such a way that the current location "algorithm" doesn't work as expected, but we'll see.
I did test with the original .exe and got the same result - so I don't think the fixer is to blame. It's probably stored somewhere else like you said.
Perhaps we've got to do it by compiling the poem into the DLL as well though.
Maybe have the end user put the poem into an .ini file, and read from that? To avoid shipping it. Similar to the way Dreamcast (and other) emulators are legal, because they do not ship with, but look for, the copyrighted system BIOSes.

Thanks!
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

djdevin: What does the logs say when you use the NPClient.dll you compiled? I guess it says "signature not found in game" for all games?

I think the algorithm is too naive - it only searches "near" the output buffer, starting at a negative offset from it, but only in one direction. It assumes a very specific memory layout (that the stack grows... downwards?) and is probably fragile to variable reordering that compilers do.

Did you compile using VS? If the logs doesn't say anything (i.e the dll isn't loaded, verify that the .def file is being used to export the correct functions. You can use dependency walker). Also, if you compiled using release flags, try compiling in debug. I had problems with certain flags (range checking I think) causing the algorithm to fail.

Once you get that working, you can try writing the memory near the output buffer to the log. Typically I'd start with writing the same range that the function "search_for_word" does, then if you don't find anything useful, increase it to include both positive and negative offsets.

Once you (in the log) find the poem, we can start to figure out why the algorithm doesn't work, and then improve it.

Thanks for your help, hope you find fiddling around with memory fun :)
User avatar
djdevin
Two Eyed Hopeful
Posts: 55
Joined: Wed Oct 17, 2012 1:10 pm
Location: Philadelphia, USA

Re: TrackIR emulation coming soon

Post by djdevin »

It doesn't say or log anything, just compiles the DLL without complaining (or I don't know where to look), but thanks for the tips. I'm an experienced developer but mostly Linux/web so any Windows specific programming is new to me.

I got FreePie to compile with VS 2012, but it doesn't compile a new NPClient.dll on its own - so I opened the NPClient folder as a DLL project and built the DLL which is maybe something I shouldn't be doing. I'll give it another try tonight and figure out what this so called "dependency walker" and "range checking" is :P
logicalChimp
One Eyed Hopeful
Posts: 43
Joined: Tue Nov 27, 2012 1:48 pm

Re: TrackIR emulation coming soon

Post by logicalChimp »

Can't help with any of the compiling stuff - but dependency walker: http://www.dependencywalker.com/

You point it at a program, and it checks all the DLL dependencies - and then all the dependencies of those DLLs, and so on and so forth all the way down the dependency tree :)
CyberRascal
Two Eyed Hopeful
Posts: 74
Joined: Fri Sep 21, 2012 4:46 am

Re: TrackIR emulation coming soon

Post by CyberRascal »

Indeed, you can use the program logicalChimp linked to to check the dependencies, AND the exported functions.

Not the best interface in my mind, but compare the included NPClient.dll to the one you compiled and it probably doesn't export the functions such as NP_GetSignature etc.

For some reason I excluded the solution and proj files which contains flags and other information - such as which file to use for locating functions to export, the one ending with .def. All the named functions in the .def file doesn't get name mangled.

To set the file, include the files in a solution (create project -> empty c++ -> add existing files) and go to properties. In the section called 'Linker' there is an option "Module definition file", point it towards the .def file.

Hopefully, it should then work as the ordinary NPClient.dll.

Let me know if it works (and if it doesn't, what dependency walker tells you about the exported functions)
Post Reply

Return to “FreePIE”