Skip to content

Commit

Permalink
add support for Warthog TARGET profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjarv committed May 13, 2018
1 parent cfe148f commit a5319b3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions JoystickProxyWin/Joystick Proxy/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private void ScanJoysticks()

device.Acquire();
_devices.Add(device);
SendEvent(device, "Connected=1");
}
}

Expand Down
1 change: 1 addition & 0 deletions JoystickProxyWin/Joystick Proxy/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
044f:b108 = Thrustmaster T.Flight HOTAS X
044f:0402 = Thrustmaster Warthog Joystick
044f:0404 = Thrustmaster Warthog Throttle
044f:ffff = Thrustmaster Warthog Combined
06a3:0763 = Saitek Rudder Pedals
06a3:0764 = Saitek Combat Rudder Pedals
068e:c0f2 = CH Pro Pedals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

public class TMWarthogJoystick : MonoBehaviour {
public const string USB_ID = "044f:0402";
public const string USB_ID_COMBINED = "044f:ffff";

public Boolean ButtonIndicator = false;

Expand Down Expand Up @@ -38,28 +39,30 @@ void Update()

void StickEvent(JoystickState state)
{
if (state.UsbID != USB_ID)
if (state.UsbID != USB_ID && state.UsbID != USB_ID_COMBINED)
{
return;
}

Model.SetActive(true);
//Model.SetActive(true);

foreach (KeyValuePair<string, int> entry in state.Data)
{
switch (entry.Key)
{
case "Connected":
if (Model.activeInHierarchy)
if (state.UsbID == USB_ID && Model.activeInHierarchy)
Model.SetActive(entry.Value == 1);
break;

case "X":
// Rotate Z between -30 and 30
Model.SetActive(true);
StickGimbal.transform.eulerAngles = new Vector3(StickGimbal.transform.eulerAngles.x, StickGimbal.transform.eulerAngles.y, ConvertRange(entry.Value, 0, 65535, 20, -20));
break;
case "Y":
// Rotate X between -30 and 30
Model.SetActive(true);
StickGimbal.transform.eulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, 20, -20), StickGimbal.transform.eulerAngles.y, StickGimbal.transform.eulerAngles.z);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public class TMWarthogThrottle : MonoBehaviour {
public const string USB_ID = "044f:0404";
public const string USB_ID_COMBINED = "044f:ffff";

private const float FLIP_SWITCH_ROTATION = 20.0f;
public GameObject Model;
Expand Down Expand Up @@ -48,29 +49,29 @@ void Update()

void StickEvent(JoystickState state)
{
if (state.UsbID != USB_ID)
if (state.UsbID != USB_ID && state.UsbID != USB_ID_COMBINED)
{
return;
}

Model.SetActive(true);

foreach (KeyValuePair<string, int> entry in state.Data)
{
switch (entry.Key)
{
case "Connected":
if(Model.activeInHierarchy)
if(state.UsbID == USB_ID && Model.activeInHierarchy)
Model.SetActive(entry.Value == 1);
break;

case "RotationZ": // Left Throttle
// Rotate Z between -30 and 30
Model.SetActive(true);
GimbalLeft.transform.eulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, 40, -25), GimbalLeft.transform.eulerAngles.y, GimbalLeft.transform.eulerAngles.z);
break;

case "Z": // Right Throttle
// Rotate X between -30 and 30
Model.SetActive(true);
GimbalRight.transform.eulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, 40, -25), GimbalRight.transform.eulerAngles.y, GimbalRight.transform.eulerAngles.z);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public class JoystickThrustmasterWarthog : MonoBehaviour {
public const string USB_ID = "044f:0402";
public const string USB_ID_COMBINED = "044f:ffff";

//public const string USB_ID = "044f:0404";

public GameObject Model;
Expand All @@ -22,13 +24,11 @@ void Update()

void StickEvent(JoystickState state)
{
if (state.UsbID != USB_ID)
if (state.UsbID != USB_ID && state.UsbID != USB_ID_COMBINED)
{
return;
}

Model.SetActive(true);

foreach (KeyValuePair<string, int> entry in state.Data)
{
switch (entry.Key)
Expand All @@ -37,11 +37,12 @@ void StickEvent(JoystickState state)
if (Model.activeInHierarchy)
Model.SetActive(entry.Value == 1);
break;

case "X":
Model.SetActive(true);
Joystick.transform.localEulerAngles = new Vector3(Joystick.transform.localEulerAngles.x, ConvertRange(entry.Value, 0, 65535, -20, 20), Joystick.transform.localEulerAngles.z);
break;
case "Y":
Model.SetActive(true);
Joystick.transform.localEulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, -20, 20), Joystick.transform.localEulerAngles.y, Joystick.transform.localEulerAngles.z);
break;
}
Expand Down

0 comments on commit a5319b3

Please sign in to comment.