-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Thrustmaster T.Flight rudder with saitek rudder model
- Loading branch information
Showing
11 changed files
with
178 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
JoystickVisualizer/Assets/Devices/Saitek Combat Rudder/SaitekCombatRudder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
Binary file modified
BIN
-8.22 KB
(99%)
JoystickVisualizer/Assets/Devices/Saitek Rudder Pedals/Saitek Rudder Pedals.blend
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
JoystickVisualizer/Assets/Devices/Saitek Rudder Pedals/Saitek Rudder Pedals.blend1
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
JoystickVisualizer/Assets/Devices/Thrustmaster T.Flight Rudder.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
JoystickVisualizer/Assets/Devices/Thrustmaster T.Flight Rudder/ThrustmasterTFlightRudder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...kVisualizer/Assets/Devices/Thrustmaster T.Flight Rudder/ThrustmasterTFlightRudder.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
...isualizer/Assets/Devices/Thrustmaster T.Flight Rudder/ThrustmasterTFlightRudderCarMode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...izer/Assets/Devices/Thrustmaster T.Flight Rudder/ThrustmasterTFlightRudderCarMode.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.