From a5319b3fc6cee867c309f26274b9eab2a0cf3e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Dj=C3=A4rv?= Date: Sun, 13 May 2018 19:35:36 +0200 Subject: [PATCH] add support for Warthog TARGET profiles --- JoystickProxyWin/Joystick Proxy/Form1.cs | 1 + JoystickProxyWin/Joystick Proxy/settings.ini | 1 + .../Assets/Devices/HOTAS Warthog/TMWarthogJoystick.cs | 9 ++++++--- .../Assets/Devices/HOTAS Warthog/TMWarthogThrottle.cs | 9 +++++---- .../JoystickThrustmasterWarthog.cs | 9 +++++---- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/JoystickProxyWin/Joystick Proxy/Form1.cs b/JoystickProxyWin/Joystick Proxy/Form1.cs index 3ffa12c..016b9b5 100644 --- a/JoystickProxyWin/Joystick Proxy/Form1.cs +++ b/JoystickProxyWin/Joystick Proxy/Form1.cs @@ -121,6 +121,7 @@ private void ScanJoysticks() device.Acquire(); _devices.Add(device); + SendEvent(device, "Connected=1"); } } diff --git a/JoystickProxyWin/Joystick Proxy/settings.ini b/JoystickProxyWin/Joystick Proxy/settings.ini index abbc556..b98a9b0 100644 --- a/JoystickProxyWin/Joystick Proxy/settings.ini +++ b/JoystickProxyWin/Joystick Proxy/settings.ini @@ -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 diff --git a/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogJoystick.cs b/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogJoystick.cs index 18aa99e..3a704e7 100644 --- a/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogJoystick.cs +++ b/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogJoystick.cs @@ -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; @@ -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 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; diff --git a/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogThrottle.cs b/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogThrottle.cs index 9b2e74c..780600d 100644 --- a/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogThrottle.cs +++ b/JoystickVisualizer/Assets/Devices/HOTAS Warthog/TMWarthogThrottle.cs @@ -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; @@ -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 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; diff --git a/JoystickVisualizer/Assets/Devices/Thrustmaster Warthog Joystick/JoystickThrustmasterWarthog.cs b/JoystickVisualizer/Assets/Devices/Thrustmaster Warthog Joystick/JoystickThrustmasterWarthog.cs index 95c63b3..4bb9173 100644 --- a/JoystickVisualizer/Assets/Devices/Thrustmaster Warthog Joystick/JoystickThrustmasterWarthog.cs +++ b/JoystickVisualizer/Assets/Devices/Thrustmaster Warthog Joystick/JoystickThrustmasterWarthog.cs @@ -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; @@ -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 entry in state.Data) { switch (entry.Key) @@ -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; }