Skip to content

Commit

Permalink
add Thrustmaster T.Flight rudder with saitek rudder model
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjarv committed Mar 28, 2018
1 parent 65e0f5f commit 1ebfb95
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 5 deletions.
8 changes: 5 additions & 3 deletions JoystickProxy/JoystickProxy/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Port = 11011
FPS = 60

[Devices]
044f:0402 = Warthog Joystick
044f:0404 = Warthog Throttle
044f:b10a = T.16000M
044f:b10a = Thrustmaster T.16000M
044f:b678 = Thrustmaster T.Flight Rudder Car Mode
044f:b679 = Thrustmaster T.Flight Rudder
044f:0402 = Thrustmaster Warthog Joystick
044f:0404 = Thrustmaster Warthog Throttle
06a3:0763 = Saitek Rudder Pedals
06a3:0764 = Saitek Combat Rudder Pedals
068e:00f = CH Pro Pedals
Expand Down
2 changes: 1 addition & 1 deletion JoystickVisualizer/Assets/CameraControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void LateUpdate()
Quaternion toRotation = Quaternion.Euler(rotationXAxis, rotationYAxis, 0);
Quaternion rotation = toRotation;

distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") * 5, distanceMin, distanceMax);
distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") * 100, distanceMin, distanceMax);
RaycastHit hit;
if (Physics.Linecast(target.position, transform.position, out hit))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Assets;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand Down
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,68 @@
using Assets;
using System.Collections.Generic;
using UnityEngine;

public class ThrustmasterTFlightRudder : MonoBehaviour {
public const string USB_ID = "044f:b679";

public GameObject Model;

public GameObject LeftPedal;
public GameObject RightPedal;

public GameObject LeftPedalBrake;
public GameObject RightPedalBrake;

// 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":
LeftPedal.transform.localPosition = new Vector3(LeftPedal.transform.localPosition.x, ConvertRange(entry.Value, 0, 65535, 1.2, -1.2), LeftPedal.transform.localPosition.z);
RightPedal.transform.localPosition = new Vector3(RightPedal.transform.localPosition.x, ConvertRange(entry.Value, 0, 65535, -1.2, 1.2), RightPedal.transform.localPosition.z);
break;
case "Y": // Left brake
LeftPedalBrake.transform.localEulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, -20, 0), 0, 0);
break;
case "X": // Right brake
RightPedalBrake.transform.localEulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, -20, 0), 0, 0);
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,68 @@
using Assets;
using System.Collections.Generic;
using UnityEngine;

public class ThrustmasterTFlightRudderCarMode : MonoBehaviour {
public const string USB_ID = "044f:b678";

public GameObject Model;

public GameObject LeftPedal;
public GameObject RightPedal;

public GameObject LeftPedalBrake;
public GameObject RightPedalBrake;

// 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 "Sliders0":
LeftPedal.transform.localPosition = new Vector3(LeftPedal.transform.localPosition.x, ConvertRange(entry.Value, 0, 65535, 0, -1.2), LeftPedal.transform.localPosition.z);
RightPedal.transform.localPosition = new Vector3(RightPedal.transform.localPosition.x, ConvertRange(entry.Value, 0, 65535, 0, 1.2), RightPedal.transform.localPosition.z);
break;
case "Z": // Left brake
LeftPedalBrake.transform.localEulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, -20, 0), 0, 0);
break;
case "RotationZ": // Right brake
RightPedalBrake.transform.localEulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, -20, 0), 0, 0);
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.

Binary file modified JoystickVisualizer/Assets/JoystickVisualizer.unity
Binary file not shown.

0 comments on commit 1ebfb95

Please sign in to comment.