STAR WARS™: Squadrons

STAR WARS™: Squadrons

Not enough ratings
Fully implemented Oculus Touch with AutoHotKey vJoy and my .ahk config
By Redwolf
Hello all,

After several hours of surfing and coding, I finally complete my configuration for Star Wars Squadrons for fully implement the Oculus Touch, that means with also yaw, pitch and roll of the left and right Touch themselves (I'm using an Oculus Rift, but I hope for you that it works also on other "Touch" device).

Obviously, at the first run, you will have to configure all the axes/button in game. take your time and make some test. I personally use the right hand for the spatial moving (yaw, pitch and roll of the ship) and left pitch for accelerate/decelerate.

A part that is extremely cool, it gives you the possibility to use the two thumbsticks to whatever you want, and the left hand roll and left hand yaw for some extra commands.

I configured it, maintaining the default deadzone and sensibility of the game.

Hope you enjoy this!

Cya!

Redwolf.
   
Award
Favorite
Favorited
Unfavorite
Oculus Touch fully implemented for Star Wars Squadrons
1. Installation:

a. auto-oculus-touch: First of all, you need to download auto_oculus_touch from https://github.com/rajetic/auto_oculus_touch/files/5792865/auto_oculus_touch_v0.1.7.zip . Unzip it where you want, no need to be in a specific folder or place.

b. vJoy: In second, install vJoy, download the installer from https://sourceforge.net/projects/vjoystick/files/latest/download

c. Star Wars Squadrons.ahk: Open Notepad, copy and paste this script. Then save it in the folder where you unzipped the auto_oculus_touch files, with extension .ahk (ex. Star Wars Squadrons.ahk):


#include auto_oculus_touch.ahk
; vJoy Example
; Set up Touch controllers as a gamepad using vJoy.

; Start the Oculus sdk.
InitOculus()
InitvJoy(1)

;file := FileOpen( "d:\test.txt", "a" )

; Main polling loop.

MsgBox, 0, Yaw - Pitch - Roll Calibration, "Sit comfortably and hold the controller still, keeping in mind that the value taken by clicking OK will be the zero of your axes"
Poll()
leftcalibYaw := GetYaw(0)
rightcalibYaw := GetYaw(1)
leftcalibPitch := GetPitch(0)
rightcalibPitch := GetPitch(1)
leftcalibRoll := GetRoll(0)
rightcalibRoll := GetRoll(1)

;file.Write("Calibration Yaw L: " . leftcalibYaw . "`r`n")
;file.Write("Calibration Yaw R: " . rightcalibYaw . "`r`n")
;file.Write("Calibration Pitch L: " . leftcalibPitch . "`r`n")
;file.Write("Calibration Pitch R: " . rightcalibPitch . "`r`n")
;file.Write("Calibration Roll L: " . leftcalibRoll . "`r`n")
;file.Write("Calibration Roll R: " . rightcalibRoll . "`r`n")

;file.Close()

Loop {
; Grab the latest Oculus input state (Touch, Remote and Xbox One).
Poll()

;leftYaw := (GetYaw(0)+180)/3.6
;leftPitch := (GetPitch(0)+90)/1.8
;leftRoll := (GetRoll(0)+180)/3.6
;rightYaw := (GetYaw(1)+180)/3.6
;rightPitch := (GetPitch(1)+90)/1.8
;rightRoll := (GetRoll(1)+180)/3.6

leftYaw := (GetYaw(0)-leftcalibYaw+18)/36
leftPitch := (GetPitch(0)-leftcalibPitch)/9
leftRoll := (GetRoll(0)-leftcalibRoll)/9
rightYaw := (GetYaw(1)-rightcalibYaw+18)/36
rightPitch := (GetPitch(1)-rightcalibPitch)/9
rightRoll := (GetRoll(1)-rightcalibRoll)/9

;leftYaw := (GetPositionX(0) - leftcalibPosX)*140
;rightYaw := (GetPositionX(1) - rightcalibPosX)*140

;file.Write(rightYaw . "`r`n")

if (abs(leftRoll) > 0.1)
SetvJoyAxis(HID_USAGE_X, leftRoll)
else
SetvJoyAxis(HID_USAGE_X, 0)

if (abs(leftPitch) > 0.1)
SetvJoyAxis(HID_USAGE_Y, leftPitch)
else
SetvJoyAxis(HID_USAGE_Y, 0)

if (abs(rightRoll) > 0.1)
SetvJoyAxis(HID_USAGE_RX, rightRoll)
else
SetvJoyAxis(HID_USAGE_RX, 0)

if (abs(rightPitch) > 0.1)
SetvJoyAxis(HID_USAGE_RY, rightPitch)
else
SetvJoyAxis(HID_USAGE_RY, 0)

if ((leftYaw < 0.49) or (leftYaw > 0.51))
SetvJoyAxisU(HID_USAGE_Z, leftYaw)
else
SetvJoyAxisU(HID_USAGE_Z, 0.5)

if ((rightYaw < 0.49) or (rightYaw > 0.51)) {
SetvJoyAxisU(HID_USAGE_RZ, rightYaw)
;file.Write(rightYaw . "`r`n")
}
else {
SetvJoyAxisU(HID_USAGE_RZ, 0.5)
;file.Write(rightYaw . "`r`n")
}

;SetvJoyAxis(HID_USAGE_X, GetAxis(AxisXLeft))
;SetvJoyAxis(HID_USAGE_Y, -GetAxis(AxisYLeft))
;SetvJoyAxis(HID_USAGE_RX, GetAxis(AxisXRight))
;SetvJoyAxis(HID_USAGE_RY, -GetAxis(AxisYRight))
;SetvJoyAxisU(HID_USAGE_Z, GetAxis(AxisHandTriggerLeft))
;SetvJoyAxisU(HID_USAGE_RZ, GetAxis(AxisHandTriggerRight))

if GetAxis(AxisXLeft) < -0.1
SetvJoyButton(11,1)
else
SetvJoyButton(11,0)

if GetAxis(AxisXLeft) > 0.1
SetvJoyButton(12,1)
else
SetvJoyButton(12,0)

if GetAxis(AxisYLeft) < -0.1
SetvJoyButton(13,1)
else
SetvJoyButton(13,0)

if GetAxis(AxisYLeft) > 0.1
SetvJoyButton(14,1)
else
SetvJoyButton(14,0)

if GetAxis(AxisXRight) < -0.1
SetvJoyButton(15,1)
else
SetvJoyButton(15,0)

if GetAxis(AxisXRight) > 0.1
SetvJoyButton(16,1)
else
SetvJoyButton(16,0)

if GetAxis(AxisYRight) < -0.1
SetvJoyButton(17,1)
else
SetvJoyButton(17,0)

if GetAxis(AxisYRight) > 0.1
SetvJoyButton(8,1)
else
SetvJoyButton(8,0)

if GetAxis(AxisHandTriggerLeft) > 0.5
SetvJoyButton(18,1)
else
SetvJoyButton(18,0)

if GetAxis(AxisHandTriggerRight) > 0.5
SetvJoyButton(19,1)
else
SetvJoyButton(19,0)

if IsPressed(ovrA)
SetvJoyButton(1,1)
if IsReleased(ovrA)
SetvJoyButton(1,0)
if IsPressed(ovrB)
SetvJoyButton(2,1)
if IsReleased(ovrB)
SetvJoyButton(2,0)
if IsPressed(ovrX)
SetvJoyButton(3,1)
if IsReleased(ovrX)
SetvJoyButton(3,0)
if IsPressed(ovrY)
SetvJoyButton(4,1)
if IsReleased(ovrY)
SetvJoyButton(4,0)
if IsPressed(ovrEnter)
SetvJoyButton(7,1)
if IsReleased(ovrEnter)
SetvJoyButton(7,0)

if IsPressed(ovrLThumb)
SetvJoyButton(9,1)
if IsReleased(ovrLThumb)
SetvJoyButton(9,0)
if IsPressed(ovrRThumb)
SetvJoyButton(10,1)
if IsReleased(ovrRThumb)
SetvJoyButton(10,0)

if GetAxis(AxisIndexTriggerLeft) > 0.7
SetvJoyButton(5,1)
else
SetvJoyButton(5,0)
if GetAxis(AxisIndexTriggerRight) > 0.7
SetvJoyButton(6,1)
else
SetvJoyButton(6,0)

Sleep, 10
}



2. Configurations:

a. vJoy: after installed vJoy, you can found it writing "vJoy" in the Windows search bar. Set the first tab with 4 POV and at least 20 buttons (ignore the other tabs).

b. Steam: Be sure that the Steam Input of the game is DISABLED. Otherwise Steam will try to re-emulate what are you already emulating. For disable, open Steam, go in your Library, select Star Wars Squadrons, and you will see a gamepad icon on the left top of the game tab.

c. The game: If you have another gamepad/joystick already configured in the game, before of start the emulation, be sure to have removed all joistick menu commands, or you will risks to found yourself in a no more controllable menu (ex. continuosly changing tab / make impossible return from commands configuration)

d. Create a link on the desktop of the Star Wars Squadrons.ahk, so is more confortable to open it. When it opens, you see a green "H" icon in the taskbar.



3. Run:

Before open the game, run the Star Wars Squadrons.ahk. Move the Message Box that will appear in a place where is confortable for click on it with one of the "Touch as mouse".

Make confortable and position the Touch keeping in mind, when you hit OK in the Message Box, the position that will be taken will be the zero of you axes.