Author Topic: TrackIR Monitoring  (Read 3383 times)

LinuxDevice

  • Newbie
  • *
  • Posts: 42
TrackIR Monitoring
« on: July 13, 2023, 03:34:20 PM »
Sometimes I'd like to use VoiceAttack to to "press buttons" in a game. If those buttons were always in the same place, it would be easy. However, sometimes I've using TrackIR, and my view point changes. The buttons become relative to where I am looking. I'd like to be able to see the TrackIR parameters being sent to the game so that I can offset any mouse coordinates by the proper amount.

I do understand it might not be easy, because there are both angular and depth content to that data. Additionally, properly tracking a point relative to this could involve some trigonometry. I am curious though what the thoughts are on this topic since TrackIR is a USB device?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4647
  • RTFM
Re: TrackIR Monitoring
« Reply #1 on: July 13, 2023, 03:43:15 PM »
As far as I'm aware, TrackIR is a closed system, to the point that their API is encrypted.


Not sure what the significance of it being a USB device would be. USB is an extremely broad standard.

LinuxDevice

  • Newbie
  • *
  • Posts: 42
Re: TrackIR Monitoring
« Reply #2 on: July 14, 2023, 09:16:33 AM »
Ok, thanks. Figures they'd do that. Sounds like making an application compatible to use TrackIR requires the company producing the game to pay money. I'd hoped it was something like a mouse, where anyone wanting to make something compatible with TrackIR was free.

The USB part is because at least the data pipe side is standard, though I guess that doesn't matter since the device driver itself encrypts.

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 264
  • Upstanding Lunatic
    • My AVCS Homepage
Re: TrackIR Monitoring
« Reply #3 on: July 14, 2023, 12:39:26 PM »
Ok, thanks. Figures they'd do that. Sounds like making an application compatible to use TrackIR requires the company producing the game to pay money. I'd hoped it was something like a mouse, where anyone wanting to make something compatible with TrackIR was free.

The USB part is because at least the data pipe side is standard, though I guess that doesn't matter since the device driver itself encrypts.

The TrackIR device driver does not encrypt the data that gets sent over the USB.  That being said, it does send raw positional data to the PC which is processed by the TrackIR software.  This process is known as serialization, where the data is serialized before being sent over the USB to the PC, where it is then deserialized by the TrackIR software.

This would of course require programming skills, regardless.

To use TrackIR in any application you develop, you would need to obtain a license from NaturalPoint (the company that produces TrackIR), which would allow you to use their software development kit (SDK) to integrate TrackIR support in your application.  It includes the necessary tools and documentation as well as sample code and libraries required to use the SDK effectively.  The cost of the license depends on the scope and scale of your project, as well as the number of units you plan to sell.  Additionally, NaturalPoint has specific guidelines and requirements for using TrackIR in commercial products, and you would need to contact them directly to discuss your project and licensing options if this is truly something you are interested in.

EDIT:  For added reference, the Falcon BMS combat flight simulator is a free standalone sim based on the leaked codebase of Falcon 4 (by Microprose, c.1999), and includes TrackIR support.  This means that they were able to obtain a license from NaturalPoint.
« Last Edit: July 14, 2023, 02:01:01 PM by SemlerPDX »

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: TrackIR Monitoring
« Reply #4 on: August 02, 2023, 08:56:12 PM »
Ok, thanks. Figures they'd do that. Sounds like making an application compatible to use TrackIR requires the company producing the game to pay money. I'd hoped it was something like a mouse, where anyone wanting to make something compatible with TrackIR was free.

The USB part is because at least the data pipe side is standard, though I guess that doesn't matter since the device driver itself encrypts.

There's a number if open source items on Github that may get you started.  Things that come to mind are FreePIE or FreeTracker.

There is a software still around that I've downloaded and can confirm it will work with latest TrackIR software.
This software would support at least mapping keypresses to various quadrants depending on where you're looking with TrackIR.

That software is here:
TrackMapper
http://kaf.tri6.net/trackmapper/

This won't support Roll, but looks like the pitch/yaw works ok.  I haven't fully tried it except to confirm it does read the TrackIR coordinates.  Keep in mind it hasn't been developed since the mid 2000's and it's not open source as far as I can tell.

Personally, I'd like to create a TrackIR plugin for Voice Attack that will allow me to piggy off what FreePIE does and then integrate that somehow in the code I develop within VA.  But I've honestly just started to ponder that type of stuff just today. 

In the meantime, if you're adventurous, you could try FreePIE and here is a script created that works to detect when you roll your head with TrackIR and it will output a Q or E keypress:

Code: [Select]
# FreePIE TrackIR AxisToKey
#
# Author: loenze (https://github.com/loenze)
# Bind axis value beyond given threshold to key.
#
# I wrote this for leaning in Squad,
# but the script should work in any game with any action.
#
# SQUAD forums discussion: http://goo.gl/mVh6E7
#
# To configure your key binds simply add config lists with the according parameters
# to the AxisToKeyConfig list at line 31. You may add as many as you wish there.
#
# AxisToKeyConfig = [
#     [trackIR.roll, Key.Q, -50],
#     [trackIR.roll, Key.E, 50]
# ]
#
# This example consists of two bindings for the TrackIR roll axis.
# If the head is tilted to the left beyond a value of -50, the Q key will be pressed.
# Likewise for tilting to the right beyond a value of 50 and the E key.
#
# Possible axis values are: trackIR.x, trackIR.y, trackIR.z, trackIR.pitch, trackIR.roll, trackIR.yaw
# Available keys can be found here: https://github.com/AndersMalmgren/FreePIE/wiki/Reference
#
# To find the right threshold values for you, you might want to turn on debugging for
# FreePIE's Watch window by uncommenting line 77.

# CONFIGURATION
# Add lists consisting of [axis, key, threshold]

AxisToKeyConfig = [
    [trackIR.roll, Key.Q, -10],
    [trackIR.roll, Key.E, 10]
]

class AxisToKey:
    def __init__(self, axis, key, threshold):
        self.axis      = axis
        self.key       = key
        self.threshold = threshold
        self.type      = 'pos' if threshold > 0 else 'neg'
       
    def press(self):
        keyboard.setKeyDown(self.key)
   
    def release(self):
        keyboard.setKeyUp(self.key)
       
    def over_threshold(self):
        if self.type == 'pos':
            return False if self.axis < self.threshold else True
        else:
            return False if self.axis > self.threshold else True
   
    def update(self):
        self.press() if self.over_threshold() else self.release()
       
AxisToKeyBindings = [AxisToKey(*c) for c in AxisToKeyConfig]

class Debug:
    info = ''
   
    @staticmethod
    def read(binding):
        Debug.info += """
Axis\t""" + str(binding.axis) + """
Thres\t""" + str(binding.threshold) + """
Key\t""" + str(binding.key) + """
Status\t""" + ('PRESSED' if keyboard.getKeyDown(binding.key) else '') + """
        """
#        diagnostics.watch(Debug.info)

def update():
    for binding in AxisToKeyBindings:
        binding.update()
        # UNCOMMENT FOLLOWING LINE FOR DEBUGGING
        #Debug.read(binding)

if starting:
    trackIR.update += update