diff --git a/Libs/XInputDotNetPure.dll b/Libs/XInputDotNetPure.dll new file mode 100644 index 0000000..6e7df91 Binary files /dev/null and b/Libs/XInputDotNetPure.dll differ diff --git a/VookaRaylee/Libs/XInputInterface.dll b/VookaRaylee/Libs/XInputInterface.dll new file mode 100644 index 0000000..b9551df Binary files /dev/null and b/VookaRaylee/Libs/XInputInterface.dll differ diff --git a/VookaRaylee/RayleeControls.cs b/VookaRaylee/RayleeControls.cs new file mode 100644 index 0000000..541f23a --- /dev/null +++ b/VookaRaylee/RayleeControls.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using VRGIN.Core; +using XInputDotNetPure; + +namespace VookaRaylee +{ + + + class RayleeControls : ProtectedBehaviour + { + private GamePadState? _PrevState; + private const string TRIGGER = "Joy1Axis3"; + + private const string DPADX = "Joy1Axis6"; + private const string DPADY = "Joy1Axis7"; + private const KeyCode RIGHT_STICK = KeyCode.Joystick1Button9; + + private float? _RightStickPressTime = null; + private const float TIME_TO_RECENTER = 1.5f; + + protected override void OnUpdate() + { + base.OnUpdate(); + var state = GamePad.GetState(PlayerIndex.One); + var state2 = GamePad.GetState(PlayerIndex.Two); + var state3 = GamePad.GetState(PlayerIndex.Three); + var state4 = GamePad.GetState(PlayerIndex.Four); + + bool thumbStickPressed = state.Buttons.RightStick == ButtonState.Pressed; + + if (state.Triggers.Left > 0.5f || state.Triggers.Right > 0.5f) + { + if (state.DPad.Up == ButtonState.Pressed) HandlePressUp(state.Triggers.Left <= 0.5f); + else if (state.DPad.Down == ButtonState.Pressed) HandlePressDown(state.Triggers.Left <= 0.5f); + if (state.DPad.Right == ButtonState.Pressed) HandlePressRight(); + else if (state.DPad.Left == ButtonState.Pressed) HandlePressLeft(); + } + + if (thumbStickPressed) + { + if (_RightStickPressTime == null) + { + _RightStickPressTime = Time.time; + } + if (Time.time - _RightStickPressTime > TIME_TO_RECENTER) + { + (VR.Mode as VookaSeatedMode).Recenter(); + _RightStickPressTime = null; + } + } + else + { + _RightStickPressTime = null; + } + + _PrevState = state; + } + + private void HandlePressLeft() + { + + VR.Settings.Rotation -= Time.deltaTime * 90; + } + + private void HandlePressRight() + { + VR.Settings.Rotation += Time.deltaTime * 90; + } + + private void HandlePressUp(bool alternativeMode) + { + if (alternativeMode) + { + VR.Settings.Distance += Time.deltaTime * 0.5f; + } + else + { + VR.Settings.OffsetY += Time.deltaTime * 0.5f; + } + } + + private void HandlePressDown(bool alternativeMode) + { + if (alternativeMode) + { + VR.Settings.Distance -= Time.deltaTime * 0.5f; + } + else + { + VR.Settings.OffsetY -= Time.deltaTime * 0.5f; + + } + } + } + } diff --git a/VookaRaylee/RayleeInterpreter.cs b/VookaRaylee/RayleeInterpreter.cs index 6d48ea2..b050205 100644 --- a/VookaRaylee/RayleeInterpreter.cs +++ b/VookaRaylee/RayleeInterpreter.cs @@ -3,20 +3,15 @@ using System.Linq; using UnityEngine; using VRGIN.Core; +using XInputDotNetPure; namespace VookaRaylee { public class RayleeInterpreter : GameInterpreter { private readonly string[] FX_BLACKLIST = new string[] { "DepthOfField" }; - private const string TRIGGER = "Joy1Axis3"; + - private const string DPADX = "Joy1Axis6"; - private const string DPADY = "Joy1Axis7"; - private const KeyCode RIGHT_STICK = KeyCode.Joystick1Button9; - - private float? _RightStickPressTime = null; - private const float TIME_TO_RECENTER = 1.5f; // Not used public override IEnumerable Actors @@ -39,72 +34,7 @@ public override bool IsAllowedEffect(MonoBehaviour effect) { return !FX_BLACKLIST.Contains(effect.GetType().Name) && base.IsAllowedEffect(effect); } - - protected override void OnUpdate() - { - base.OnUpdate(); - - float trigger = Input.GetAxisRaw(TRIGGER); - float yPress = Input.GetAxisRaw(DPADY); - float xPress = Input.GetAxisRaw(DPADX); - - if (Mathf.Abs(trigger) > 0.5f) - { - if (yPress > 0.5f) HandlePressUp(trigger < 0); - else if (yPress < -0.5f) HandlePressDown(trigger < 0); - if (xPress > 0.5f) HandlePressRight(); - else if (xPress < -0.5f) HandlePressLeft(); - } - - if(Input.GetKeyDown(RIGHT_STICK)) - { - _RightStickPressTime = Time.time; - } - if(Input.GetKeyUp(RIGHT_STICK)) - { - _RightStickPressTime = null; - } - if(_RightStickPressTime != null && Time.time - _RightStickPressTime > TIME_TO_RECENTER) - { - (VR.Mode as VookaSeatedMode).Recenter(); - _RightStickPressTime = null; - } - } - - private void HandlePressLeft() - { - - VR.Settings.Rotation -= Time.deltaTime * 90; - } - - private void HandlePressRight() - { - VR.Settings.Rotation += Time.deltaTime * 90; - } - - private void HandlePressUp(bool alternativeMode) - { - if (alternativeMode) - { - VR.Settings.Distance += Time.deltaTime * 0.5f; - } - else - { - VR.Settings.OffsetY += Time.deltaTime * 0.5f; - } - } - - private void HandlePressDown(bool alternativeMode) - { - if (alternativeMode) - { - VR.Settings.Distance -= Time.deltaTime * 0.5f; - } - else - { - VR.Settings.OffsetY -= Time.deltaTime * 0.5f; - - } - } + } + } \ No newline at end of file diff --git a/VookaRaylee/VookaRaylee.csproj b/VookaRaylee/VookaRaylee.csproj index c1a55d5..36f9f7e 100644 --- a/VookaRaylee/VookaRaylee.csproj +++ b/VookaRaylee/VookaRaylee.csproj @@ -47,17 +47,19 @@ - - ..\VRGIN\Libs\Unity 5.3.4\UnityEngine.dll False + + ..\Libs\XInputDotNetPure.dll + + @@ -70,6 +72,11 @@ VRGIN + + + PreserveNewest + +