TrackIR Workaround v2!
EDIT: Even newer version at the bottom of this post. Now with audio feedback and a restricted look mode!
u/Bribase posted this write-up on how to get TrackIR working again in SC for head tracking. I took his FreePIE script and added the zoom feature and the lean/strafe feature (which strafes the ship and is supposed to lean in FPS, but I don't think that works yet.)
Instructions: (also mostly stolen from Bribase)
-
Run TrackIR.
-
Set it to the default One:One profile
-
Download FreePIE and run it as Administrator. This will allow Star Citizen to detect you toggling the script on and off.
-
Copy and paste the code below into a new FreePIE script
-
Hit save, so you can have it easily available next time
-
Go to Script>Run Script or just Press F5
-
Fire up SC 2.x and when in the cockpit hit LEFT ALT twice to toggle freelook
-
Hit PAGE DOWN to toggle the mouse emulation.
-
Hit END to toggle the zoom feature.
-
Hit DEL to toggle the Lean/Strafe feature.
Et voila! You won't get the same 6DOF as true TrackIR but you'll at least have something close.
#Use one:one profile in TrackIR
#Tweak Head Track sensitivity using "multiply = X" PageDown to toggle on/off
#Tweak Zooming sensitivity using "maxZoom = X" End to toggle on/off
#Tweak Lean/Strafe minimum distance using "minLean = X" Delete to toggle on/off
#__Change these variables to customize your experience__
if starting:
enabledHT = True # Set to True or False depending on if you want the headtracking to begin immediately
enabledZ = True # Same for Zoom
enabledL = False # Same for Lean/Strafe
multiply = 30 # Speed of head tracking
maxZoom = 50 # Larger number means farther head travel needed to zoom all the way in, and visa versa
minLean = 50 # How far you need to lean to trigger the Lean/Strafe buttons
zoomZones = 5 # There are currently only 5 stages of zoom in the game, including unzoomed
#__Change these button to remap the toggle keys__
toggleHT = keyboard.getPressed(Key.PageDown) #Toggle Head Tracking
toggleZ = keyboard.getPressed(Key.End) #Toggle Zoom
toggleL = keyboard.getPressed(Key.Delete) #Toggle Lean/Strafe
#=========================================================#
def update():
yaw = trackIR.yaw
pitch = trackIR.pitch
zoom = -trackIR.z
lean = trackIR.x
global zone
global previousZone
global maxZoom
global zoomZones
deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
deltaLean = filters.delta(lean)
#__Head Look Section__
if (enabledHT):
mouse.deltaX = deltaYaw*multiply
mouse.deltaY = -deltaPitch*multiply
#__Zoom In/Out Section__
if (enabledZ):
i = 0
while i < zoomZones :
zoomInterval = i * ( maxZoom / zoomZones )
i += 1
zoomInterval2 = i * ( maxZoom / zoomZones )
if (zoomInterval <= zoom < zoomInterval2):
previousZone = zone
zone = i
mouse.wheel = zone - previousZone
#__Lean/Strafe Left/Right Section__
if (enabledL):
if (lean < -minLean) and (deltaLean < 0.1):
keyboard.setKey(Key.Q, 1)
keyboard.setKey(Key.E, 0)
elif (lean > minLean) and (deltaLean > -0.1):
keyboard.setKey(Key.Q, 0)
keyboard.setKey(Key.E, 1)
else:
keyboard.setKey(Key.Q, 0)
keyboard.setKey(Key.E, 0)
#__xxx Don't touch xxx__
if starting:
zone = 1
previousZone = 1
trackIR.update += update
if toggleHT:
enabledHT = not enabledHT
if toggleZ:
enabledZ = not enabledZ
if toggleL:
enabledL = not enabledL
.
.
.
EDIT: Now with Audio Feedback and a Restriced Mode!!
I think I fixed the off-center issue! I created a "restricted look mode" that keeps the trackIR data from being passed to the mouse IF trackIR is beyond a certain range. Try out the code below, and see if it fixes the problem.
Note: The default boundaries are set up for a Super Hornet, but each ship is different. So if you want to increase/decrease the boundaries, adjust the variables "maxYaw", "maxPitch" and "minPitch"
Page Down now cycles through off -> freelook -> restricted look
#Use one:one profile in TrackIR
#Tweak Head Track sensitivity using "multiply = X" PageDown to toggle on/off
#Tweak Zooming sensitivity using "maxZoom = X" End to toggle on/off
#Tweak Lean/Strafe minimum distance using "minLean = X" Delete to toggle on/off
#__Change these variables to customize your experience__
if starting:
enabledHT = 0 # Set to True (1) or False (0) depending on if you want the headtracking to begin immediately
enabledZ = 0 # Same for Zoom
enabledL = 0 # Same for Lean/Strafe
multiply = 30 # Speed of head tracking
maxZoom = 120 # Larger number means farther head travel needed to zoom all the way in, and visa versa
zoomZones = 5 # There are currently only 5 stages of zoom in the game, including unzoomed
minLean = 50 # How far you need to lean to trigger the Lean/Strafe buttons
maxYaw = 42 # How far left and right you can look (this'll help keep you cetered after looking around)
maxPitch = 38 # How far up you can look
minPitch = -17 # How far down you can look (in the cockpits you usually cannot look as far down as you can up)
#__Change these button to remap the toggle keys__
toggleHT = keyboard.getPressed(Key.PageDown) #Toggle Head Tracking
toggleZ = keyboard.getPressed(Key.End) #Toggle Zoom
toggleL = keyboard.getPressed(Key.Delete) #Toggle Lean/Strafe
#__xxx Don't touch from here on down xxx__
#__TTS System---Head Tracking Toggle Scripts_____
if toggleHT:
if enabledHT == 0:
enabledHT = 1
speech.say("FreeLook Mode")
elif enabledHT == 1:
enabledHT = 2
speech.say("Restricted Look Mode")
elif enabledHT == 2:
enabledHT = 0
speech.say("Head Tracking off")
#__TTS System---Zoom Toggle Scripts_____
if toggleZ:
enabledZ = not enabledZ
if enabledZ:
speech.say("Zoom on")
else:
speech.say("Zoom off")
#__TTS System---Lean/Strafe Toggle Scripts_____
if toggleL:
enabledL = not enabledL
if enabledL:
speech.say("Lean on")
else:
speech.say("Lean off")
def update():
global zone
global previousZone
global maxZoom
global zoomZones
global maxYaw
global maxPitch
global minPitch
#__Head Look Section__
if (enabledHT > 0):
if enabledHT == 1: #Freelook Mode
yaw = trackIR.yaw
pitch = trackIR.pitch
elif enabledHT == 2: #Restricted Look Mode
if -maxYaw <= trackIR.yaw <= maxYaw: #Within the Yaw limits
yaw = trackIR.yaw
elif trackIR.yaw < -maxYaw: #Too far left
yaw = -maxYaw
else: #Too far Right
yaw = maxYaw
if minPitch <= trackIR.pitch <= maxPitch: #Within the Pitch limits
pitch = trackIR.pitch
elif trackIR.pitch < minPitch: #Too far Down
pitch = minPitch
else: #Too far Up
pitch = maxPitch
deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
mouse.deltaX = deltaYaw*multiply
mouse.deltaY = -deltaPitch*multiply
#__Zoom In/Out Section__
if (enabledZ):
zoom = -trackIR.z
i = 0
while i < zoomZones :
zoomInterval = i * ( maxZoom / zoomZones )
i += 1
zoomInterval2 = i * ( maxZoom / zoomZones )
if (zoomInterval <= zoom < zoomInterval2):
previousZone = zone
zone = i
mouse.wheel = zone - previousZone
#__Lean/Strafe Left/Right Section__
if (enabledL):
lean = trackIR.x
deltaLean = filters.delta(lean)
if (lean < -minLean) and (deltaLean < 0.1):
keyboard.setKey(Key.Q, 1)
keyboard.setKey(Key.E, 0)
elif (lean > minLean) and (deltaLean > -0.1):
keyboard.setKey(Key.Q, 0)
keyboard.setKey(Key.E, 1)
else:
keyboard.setKey(Key.Q, 0)
keyboard.setKey(Key.E, 0)
if starting:
speech.say("booting up")
zone = 1
previousZone = 1
trackIR.update += update
Posted Apr 29, 2016, 3:44 PM UTC · edited
I'll have to give this a try, maybe it'll tide me over until they get a proper deployment working. Thanks for sharing!
No problem. :)
Just as a heads up. if you look too far up/down/left/right while in a ship, you'll loose your center position when you look straight ahead again. It's because your in-game character has restricted movement while in a ship, but you IRL don't. I just use my mouse to recenter me when I do that.