Skip to content

Commit

Permalink
tm throttle base switches now move
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjarv committed Nov 10, 2017
1 parent c136673 commit f74d495
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ public class TMWarthogThrottle : MonoBehaviour {

public GameObject GimbalFriction;

public GameObject GimbalAPU;
public GameObject FlowL;
public GameObject FlowR;
public GameObject IgnL;
public GameObject IgnR;
public GameObject Flaps;
public GameObject APU;
public GameObject LG;
public GameObject EAC;
public GameObject RDR;
public GameObject AutopilotEngage;
public GameObject AutopilotLaste;


// Use this for initialization
void Start()
Expand Down Expand Up @@ -43,28 +54,85 @@ void StickEvent(JoystickState state)
// Rotate Z between -30 and 30
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
GimbalRight.transform.eulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, 40, -25), GimbalRight.transform.eulerAngles.y, GimbalRight.transform.eulerAngles.z);
break;
case "Buttons19": // Right Throttle Idle/Off
GimbalAPU.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 30.0f);
break;

case "Buttons28": // Right Throttle Idle/Off
if (entry.Value == 0)
GimbalRight.transform.eulerAngles = new Vector3(-25, GimbalRight.transform.eulerAngles.y, GimbalRight.transform.eulerAngles.z);
else
GimbalRight.transform.eulerAngles = new Vector3(-35, GimbalRight.transform.eulerAngles.y, GimbalRight.transform.eulerAngles.z);
break;

case "Buttons29": // Left Throttle Idle/Off
if (entry.Value == 0)
GimbalLeft.transform.eulerAngles = new Vector3(-25, GimbalLeft.transform.eulerAngles.y, GimbalLeft.transform.eulerAngles.z);
else
GimbalLeft.transform.eulerAngles = new Vector3(-35, GimbalLeft.transform.eulerAngles.y, GimbalLeft.transform.eulerAngles.z);
break;

case "Sliders0": // Friction
GimbalFriction.transform.eulerAngles = new Vector3(ConvertRange(entry.Value, 0, 65535, 40, -40), GimbalFriction.transform.eulerAngles.y, GimbalFriction.transform.eulerAngles.z);
break;

case "Buttons15":
FlowL.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 40.0f);
break;

case "Buttons16":
FlowR.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 40.0f);
break;

case "Buttons17":
IgnL.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : -20.0f);
break;
case "Buttons30":
IgnL.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 20.0f);
break;

case "Buttons18":
IgnR.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : -20.0f);
break;
case "Buttons31":
IgnR.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 20.0f);
break;

case "Buttons19":
APU.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 40.0f);
break;

case "Buttons20":
LG.transform.localPosition = Vector3.down * ((entry.Value == 0) ? 0.0f : 0.0035f);
break;

case "Buttons25":
AutopilotEngage.transform.localPosition = Vector3.down * ((entry.Value == 0) ? 0.0f : 0.0035f);
break;

case "Buttons23":
EAC.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 40.0f);
break;

case "Buttons24":
RDR.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 40.0f);
break;

case "Buttons26":
AutopilotLaste.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 20.0f);
break;
case "Buttons27":
AutopilotLaste.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : -20.0f);
break;

case "Buttons21":
Flaps.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : 20.0f);
break;
case "Buttons22":
Flaps.transform.eulerAngles = Vector3.right * ((entry.Value == 0) ? 0.0f : -20.0f);
break;
}
}
}
Expand Down
Binary file modified JoystickVisualizer/Assets/JoystickVisualizer.unity
Binary file not shown.
3 changes: 3 additions & 0 deletions JoystickVisualizer/Assets/StickOrganizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class StickOrganizer : MonoBehaviour {
private const float OFFSET = 20.0f;

public GameObject NoDevicesText;
public GameObject[] ControllerModels;

private List<GameObject> activeControllers = new List<GameObject>();
Expand Down Expand Up @@ -33,6 +34,8 @@ void Update () {

if (oldLength != activeControllers.Count)
{
NoDevicesText.SetActive(activeControllers.Count == 0);

Debug.Log("Active controller count changed from "+ oldLength + " to " + activeControllers.Count + ", reorganizing models");

float center = ((activeControllers.Count-1) * OFFSET) / 2;
Expand Down

0 comments on commit f74d495

Please sign in to comment.