Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for Thrustmaster T.Flight HOTAS 4 #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions JoystickProxyWin/Joystick Proxy/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions JoystickProxyWin/Joystick Proxy/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
044f:b678 = Thrustmaster T.Flight Rudder Car Mode
044f:b679 = Thrustmaster T.Flight Rudder
044f:b108 = Thrustmaster T.Flight HOTAS X
044f:b67c = Thrustmaster T.Flight HOTAS 4
044f:0402 = Thrustmaster Warthog Joystick
044f:0404 = Thrustmaster Warthog Throttle
044f:ffff = Thrustmaster Warthog Combined
Expand Down
6 changes: 6 additions & 0 deletions JoystickVisualizer/.vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
Binary file modified JoystickVisualizer/Assets/JoystickVisualizerSettings.lighting
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Assets;
using System.Collections.Generic;
using UnityEngine;

public class ThrustmasterTFlightHOTAS4Stick : MonoBehaviour {
public const string USB_ID = "044f:b67c";
//public const string USB_ID = "044f:b108";
//public const string USB_ID = "044f:0402";

public GameObject Model;
public GameObject Joystick;

// Use this for initialization
void Start()
{
UDPListener.StickEventListener += StickEvent;
}

// Update is called once per frame
void Update()
{
}

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

Model.SetActive(true);

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

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

public static float ConvertRange(
double value, // value to convert
double originalStart, double originalEnd, // original range
double newStart, double newEnd) // desired range
{
double scale = (double)(newEnd - newStart) / (originalEnd - originalStart);
return (float)(newStart + ((value - originalStart) * scale));
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Assets;
using System;
using System.Collections.Generic;
using UnityEngine;

public class ThrustmasterTFlightHOTAS4Throttle : MonoBehaviour {
public const string USB_ID = "044f:b67c";
//public const string USB_ID = "044f:b108";
//public const string USB_ID = "044f:0404";

public GameObject Model;
public GameObject LeftThrottle;
public GameObject RightThrottle;

private int ZVal = 32767;
private int Slider0Val = 32767;

// Use this for initialization
void Start()
{
UDPListener.StickEventListener += StickEvent;
}

// Update is called once per frame
void Update()
{
}

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

Model.SetActive(true);

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

case "Z":
ZVal = entry.Value;
break;

case "Sliders0":
Slider0Val = entry.Value;
break;
}

int LeftValue = Math.Max(0, Math.Min(65535, ZVal + (Slider0Val - 32767) / 2));
int RightValue = Math.Max(0, Math.Min(65535, ZVal - (Slider0Val - 32767) / 2));

RightThrottle.transform.localEulerAngles = new Vector3(ConvertRange(RightValue, 0, 65535, 30, -30), RightThrottle.transform.localEulerAngles.y, RightThrottle.transform.localEulerAngles.z);
LeftThrottle.transform.localEulerAngles = new Vector3(ConvertRange(LeftValue, 0, 65535, 30, -30), LeftThrottle.transform.localEulerAngles.y, LeftThrottle.transform.localEulerAngles.z);
}
}

public static float ConvertRange(
double value, // value to convert
double originalStart, double originalEnd, // original range
double newStart, double newEnd) // desired range
{
double scale = (double)(newEnd - newStart) / (originalEnd - originalStart);
return (float)(newStart + ((value - originalStart) * scale));
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified JoystickVisualizer/Assets/Scenes/JoystickVisualizer.unity
Binary file not shown.
Binary file modified JoystickVisualizer/ProjectSettings/InputManager.asset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ MonoBehaviour:
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_EnablePreviewPackages: 0
m_EnablePreReleasePackages: 0
m_EnablePackageDependencies: 0
m_AdvancedSettingsExpanded: 1
m_ScopedRegistriesSettingsExpanded: 1
m_SeeAllPackageVersions: 0
oneTimeWarningShown: 0
m_Registries:
- m_Id: main
m_Name:
m_Url: https://staging-packages.unity.com
m_Url: https://packages.unity.com
m_Scopes: []
m_IsDefault: 1
m_Capabilities: 0
m_Capabilities: 7
m_UserSelectedRegistryName:
m_UserAddingNewScopedRegistry: 0
m_RegistryInfoDraft:
Expand All @@ -41,3 +42,4 @@ MonoBehaviour:
m_Scopes:
-
m_SelectedScopeIndex: 0
m_LoadAssets: 0
Binary file modified JoystickVisualizer/ProjectSettings/ProjectSettings.asset
Binary file not shown.
Binary file modified JoystickVisualizer/ProjectSettings/QualitySettings.asset
Binary file not shown.
5 changes: 4 additions & 1 deletion JoystickVisualizer/UserSettings/EditorUserSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ EditorUserSettings:
value: 224247031146467102171f36192054261f040d2b20213c353f67083debf42d
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c751f0f040c232f2310393e3c1c3febfa312aacf238e0f323
value: 224247031146467508193a2b03365e1c1f0d1d38623d28393930
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c72111f19352f223d68252320092a
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c751f0f040c232f2310393e3c1c3febfa312aacf238e0f323
flags: 0
UnityEditor.ShaderGraph.FloatingWindowsLayout:
value: 181344140043005e1a220d3b1f364b524c0c5a27130c293326201334cee5322ca0bd30e8eb293a707b0fd0180b3d0a36fc0d3d04e649500d1002ee0b5dbd1d2c27c00ad113cb1e10e41f1addc80993b98c9884a69ae6d8f0d1cda9e8fbfefaf9f9dea3fdb9ade882f0fbb0e1e380cafbf2c3adc18e9cd285a2908b80e88a9c8395949c9483d3888c97ddbd90eed2a5a892a2af949aa48bafb19f85bd75a7ed3a7d25658598b7b58bb4b76aaf777690ca2863946c72c6cd81b6b6708f9f879f88769589d91c8f888e64d20f935e796571755c6b546677696a486c781c073c713d756a66771753783a27353f4c504172674347264e2e7a16016a711e4d7d5f686758400216064d1b4f487873735e6d726f6b3f577c7d47786579002d5170ed3627f73426d6f730ff32e8f9df0bea067daaedb5e048565b50474359b151db824e4b94905899da07
flags: 0
Expand Down
13 changes: 13 additions & 0 deletions JoystickVisualizer/UserSettings/Search.index
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Assets",
"roots": ["Assets"],
"includes": [],
"excludes": ["Temp/", "External/"],
"options": {
"types": true,
"properties": false,
"extended": false,
"dependencies": false
},
"baseScore": 999
}
61 changes: 60 additions & 1 deletion JoystickVisualizer/UserSettings/Search.settings
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
{}
trackSelection = true
fetchPreview = true
wantsMore = false
keepOpen = false
itemIconSize = 1
queryFolder = "Assets"
onBoardingDoNotAskAgain = true
showPackageIndexes = false
showStatusBar = false
scopes = {
"last_search.785D90A9" = "deep profile"
"asset.785D90A9" = "True"
"menu.785D90A9" = "True"
"scene.785D90A9" = "True"
"settings.785D90A9" = "True"
"m_ShownPanels.785D90A9" = "3"
"m_SideBarSplitter.785D90A9" = "180"
"m_DetailsPanelSplitter.785D90A9" = "700"
"currentGroup.785D90A9" = "all"
}
providers = {
asset = {
active = true
priority = 25
defaultAction = null
}
store = {
active = true
priority = 100
defaultAction = null
}
find = {
active = true
priority = 25
defaultAction = null
}
log = {
active = false
priority = 210
defaultAction = null
}
packages = {
active = true
priority = 90
defaultAction = null
}
scene = {
active = true
priority = 50
defaultAction = null
}
query = {
active = true
priority = 100
defaultAction = null
}
}
recentSearches = [
]
savedSearchesSortOrder = 0