Replace UltimateXR with HurricaneVR
This commit is contained in:
@@ -0,0 +1,472 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
public class HVRControllerEvents : MonoBehaviour
|
||||
{
|
||||
public static HVRControllerEvents Instance { get; private set; }
|
||||
|
||||
public UnityEvent LeftGripActivated = new UnityEvent();
|
||||
public UnityEvent LeftGripDeactivated = new UnityEvent();
|
||||
public UnityEvent RightGripActivated = new UnityEvent();
|
||||
public UnityEvent RightGripDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTriggerActivated = new UnityEvent();
|
||||
public UnityEvent LeftTriggerDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTriggerActivated = new UnityEvent();
|
||||
public UnityEvent RightTriggerDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftPrimaryActivated = new UnityEvent();
|
||||
public UnityEvent LeftPrimaryDeactivated = new UnityEvent();
|
||||
public UnityEvent RightPrimaryActivated = new UnityEvent();
|
||||
public UnityEvent RightPrimaryDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftSecondaryActivated = new UnityEvent();
|
||||
public UnityEvent LeftSecondaryDeactivated = new UnityEvent();
|
||||
public UnityEvent RightSecondaryActivated = new UnityEvent();
|
||||
public UnityEvent RightSecondaryDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftMenuActivated = new UnityEvent();
|
||||
public UnityEvent LeftMenuDeactivated = new UnityEvent();
|
||||
public UnityEvent RightMenuActivated = new UnityEvent();
|
||||
public UnityEvent RightMenuDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftPrimaryTouchActivated = new UnityEvent();
|
||||
public UnityEvent LeftPrimaryTouchDeactivated = new UnityEvent();
|
||||
public UnityEvent RightPrimaryTouchActivated = new UnityEvent();
|
||||
public UnityEvent RightPrimaryTouchDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftSecondaryTouchActivated = new UnityEvent();
|
||||
public UnityEvent LeftSecondaryTouchDeactivated = new UnityEvent();
|
||||
public UnityEvent RightSecondaryTouchActivated = new UnityEvent();
|
||||
public UnityEvent RightSecondaryTouchDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftJoystickActivated = new UnityEvent();
|
||||
public UnityEvent LeftJoystickDeactivated = new UnityEvent();
|
||||
public UnityEvent RightJoystickActivated = new UnityEvent();
|
||||
public UnityEvent RightJoystickDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTrackpadActivated = new UnityEvent();
|
||||
public UnityEvent LeftTrackpadDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTrackpadActivated = new UnityEvent();
|
||||
public UnityEvent RightTrackpadDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftJoystickTouchActivated = new UnityEvent();
|
||||
public UnityEvent LeftJoystickTouchDeactivated = new UnityEvent();
|
||||
public UnityEvent RightJoystickTouchActivated = new UnityEvent();
|
||||
public UnityEvent RightJoystickTouchDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTrackPadTouchActivated = new UnityEvent();
|
||||
public UnityEvent LeftTrackPadTouchDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadTouchActivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadTouchDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTriggerTouchActivated = new UnityEvent();
|
||||
public UnityEvent LeftTriggerTouchDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTriggerTouchActivated = new UnityEvent();
|
||||
public UnityEvent RightTriggerTouchDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftThumbTouchActivated = new UnityEvent();
|
||||
public UnityEvent LeftThumbTouchDeactivated = new UnityEvent();
|
||||
public UnityEvent RightThumbTouchActivated = new UnityEvent();
|
||||
public UnityEvent RightThumbTouchDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTrackPadUpActivated = new UnityEvent();
|
||||
public UnityEvent LeftTrackPadUpDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadUpActivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadUpDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTrackPadLeftActivated = new UnityEvent();
|
||||
public UnityEvent LeftTrackPadLeftDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadLeftActivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadLeftDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTrackPadRightActivated = new UnityEvent();
|
||||
public UnityEvent LeftTrackPadRightDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadRightActivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadRightDeactivated = new UnityEvent();
|
||||
|
||||
public UnityEvent LeftTrackPadDownActivated = new UnityEvent();
|
||||
public UnityEvent LeftTrackPadDownDeactivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadDownActivated = new UnityEvent();
|
||||
public UnityEvent RightTrackPadDownDeactivated = new UnityEvent();
|
||||
|
||||
|
||||
|
||||
private HVRGlobalInputs _globalInputs;
|
||||
private bool _hasInputs;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!Instance)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
//testing...
|
||||
//LeftGripActivated.AddListener(() => { Debug.Log("LeftGripActivated"); });
|
||||
//LeftGripDeactivated.AddListener(() => { Debug.Log("LeftGripDeactivated"); });
|
||||
//RightGripActivated.AddListener(() => { Debug.Log("RightGripActivated"); });
|
||||
//RightGripDeactivated.AddListener(() => { Debug.Log("RightGripDeactivated"); });
|
||||
//LeftTriggerActivated.AddListener(() => { Debug.Log("LeftTriggerActivated"); });
|
||||
//LeftTriggerDeactivated.AddListener(() => { Debug.Log("LeftTriggerDeactivated"); });
|
||||
//RightTriggerActivated.AddListener(() => { Debug.Log("RightTriggerActivated"); });
|
||||
//RightTriggerDeactivated.AddListener(() => { Debug.Log("RightTriggerDeactivated"); });
|
||||
//LeftPrimaryActivated.AddListener(() => { Debug.Log("LeftPrimaryActivated"); });
|
||||
//LeftPrimaryDeactivated.AddListener(() => { Debug.Log("LeftPrimaryDeactivated"); });
|
||||
//RightPrimaryActivated.AddListener(() => { Debug.Log("RightPrimaryActivated"); });
|
||||
//RightPrimaryDeactivated.AddListener(() => { Debug.Log("RightPrimaryDeactivated"); });
|
||||
//LeftSecondaryActivated.AddListener(() => { Debug.Log("LeftSecondaryActivated"); });
|
||||
//LeftSecondaryDeactivated.AddListener(() => { Debug.Log("LeftSecondaryDeactivated"); });
|
||||
//RightSecondaryActivated.AddListener(() => { Debug.Log("RightSecondaryActivated"); });
|
||||
//RightSecondaryDeactivated.AddListener(() => { Debug.Log("RightSecondaryDeactivated"); });
|
||||
//LeftMenuActivated.AddListener(() => { Debug.Log("LeftMenuActivated"); });
|
||||
//LeftMenuDeactivated.AddListener(() => { Debug.Log("LeftMenuDeactivated"); });
|
||||
//RightMenuActivated.AddListener(() => { Debug.Log("RightMenuActivated"); });
|
||||
//RightMenuDeactivated.AddListener(() => { Debug.Log("RightMenuDeactivated"); });
|
||||
//LeftPrimaryTouchActivated.AddListener(() => { Debug.Log("LeftPrimaryTouchActivated"); });
|
||||
//LeftPrimaryTouchDeactivated.AddListener(() => { Debug.Log("LeftPrimaryTouchDeactivated"); });
|
||||
//RightPrimaryTouchActivated.AddListener(() => { Debug.Log("RightPrimaryTouchActivated"); });
|
||||
//RightPrimaryTouchDeactivated.AddListener(() => { Debug.Log("RightPrimaryTouchDeactivated"); });
|
||||
//LeftSecondaryTouchActivated.AddListener(() => { Debug.Log("LeftSecondaryTouchActivated"); });
|
||||
//LeftSecondaryTouchDeactivated.AddListener(() => { Debug.Log("LeftSecondaryTouchDeactivated"); });
|
||||
//RightSecondaryTouchActivated.AddListener(() => { Debug.Log("RightSecondaryTouchActivated"); });
|
||||
//RightSecondaryTouchDeactivated.AddListener(() => { Debug.Log("RightSecondaryTouchDeactivated"); });
|
||||
//LeftJoystickActivated.AddListener(() => { Debug.Log("LeftJoystickActivated"); });
|
||||
//LeftJoystickDeactivated.AddListener(() => { Debug.Log("LeftJoystickDeactivated"); });
|
||||
//RightJoystickActivated.AddListener(() => { Debug.Log("RightJoystickActivated"); });
|
||||
//RightJoystickDeactivated.AddListener(() => { Debug.Log("RightJoystickDeactivated"); });
|
||||
//LeftTrackpadActivated.AddListener(() => { Debug.Log("LeftTrackpadActivated"); });
|
||||
//LeftTrackpadDeactivated.AddListener(() => { Debug.Log("LeftTrackpadDeactivated"); });
|
||||
//RightTrackpadActivated.AddListener(() => { Debug.Log("RightTrackpadActivated"); });
|
||||
//RightTrackpadDeactivated.AddListener(() => { Debug.Log("RightTrackpadDeactivated"); });
|
||||
//LeftJoystickTouchActivated.AddListener(() => { Debug.Log("LeftJoystickTouchActivated"); });
|
||||
//LeftJoystickTouchDeactivated.AddListener(() => { Debug.Log("LeftJoystickTouchDeactivated"); });
|
||||
//RightJoystickTouchActivated.AddListener(() => { Debug.Log("RightJoystickTouchActivated"); });
|
||||
//RightJoystickTouchDeactivated.AddListener(() => { Debug.Log("RightJoystickTouchDeactivated"); });
|
||||
//LeftTrackPadTouchActivated.AddListener(() => { Debug.Log("LeftTrackPadTouchActivated"); });
|
||||
//LeftTrackPadTouchDeactivated.AddListener(() => { Debug.Log("LeftTrackPadTouchDeactivated"); });
|
||||
//RightTrackPadTouchActivated.AddListener(() => { Debug.Log("RightTrackPadTouchActivated"); });
|
||||
//RightTrackPadTouchDeactivated.AddListener(() => { Debug.Log("RightTrackPadTouchDeactivated"); });
|
||||
//LeftTriggerTouchActivated.AddListener(() => { Debug.Log("LeftTriggerTouchActivated"); });
|
||||
//LeftTriggerTouchDeactivated.AddListener(() => { Debug.Log("LeftTriggerTouchDeactivated"); });
|
||||
//RightTriggerTouchActivated.AddListener(() => { Debug.Log("RightTriggerTouchActivated"); });
|
||||
//RightTriggerTouchDeactivated.AddListener(() => { Debug.Log("RightTriggerTouchDeactivated"); });
|
||||
//LeftThumbTouchActivated.AddListener(() => { Debug.Log("LeftThumbTouchActivated"); });
|
||||
//LeftThumbTouchDeactivated.AddListener(() => { Debug.Log("LeftThumbTouchDeactivated"); });
|
||||
//RightThumbTouchActivated.AddListener(() => { Debug.Log("RightThumbTouchActivated"); });
|
||||
//RightThumbTouchDeactivated.AddListener(() => { Debug.Log("RightThumbTouchDeactivated"); });
|
||||
//LeftTrackPadUpActivated.AddListener(() => { Debug.Log("LeftTrackPadUpActivated"); });
|
||||
//LeftTrackPadUpDeactivated.AddListener(() => { Debug.Log("LeftTrackPadUpDeactivated"); });
|
||||
//RightTrackPadUpActivated.AddListener(() => { Debug.Log("RightTrackPadUpActivated"); });
|
||||
//RightTrackPadUpDeactivated.AddListener(() => { Debug.Log("RightTrackPadUpDeactivated"); });
|
||||
//LeftTrackPadLeftActivated.AddListener(() => { Debug.Log("LeftTrackPadLeftActivated"); });
|
||||
//LeftTrackPadLeftDeactivated.AddListener(() => { Debug.Log("LeftTrackPadLeftDeactivated"); });
|
||||
//RightTrackPadLeftActivated.AddListener(() => { Debug.Log("RightTrackPadLeftActivated"); });
|
||||
//RightTrackPadLeftDeactivated.AddListener(() => { Debug.Log("RightTrackPadLeftDeactivated"); });
|
||||
//LeftTrackPadRightActivated.AddListener(() => { Debug.Log("LeftTrackPadRightActivated"); });
|
||||
//LeftTrackPadRightDeactivated.AddListener(() => { Debug.Log("LeftTrackPadRightDeactivated"); });
|
||||
//RightTrackPadRightActivated.AddListener(() => { Debug.Log("RightTrackPadRightActivated"); });
|
||||
//RightTrackPadRightDeactivated.AddListener(() => { Debug.Log("RightTrackPadRightDeactivated"); });
|
||||
//LeftTrackPadDownActivated.AddListener(() => { Debug.Log("LeftTrackPadDownActivated"); });
|
||||
//LeftTrackPadDownDeactivated.AddListener(() => { Debug.Log("LeftTrackPadDownDeactivated"); });
|
||||
//RightTrackPadDownActivated.AddListener(() => { Debug.Log("RightTrackPadDownActivated"); });
|
||||
//RightTrackPadDownDeactivated.AddListener(() => { Debug.Log("RightTrackPadDownDeactivated"); });
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_globalInputs = HVRGlobalInputs.Instance;
|
||||
_hasInputs = _globalInputs;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_hasInputs)
|
||||
return;
|
||||
|
||||
if (_globalInputs.LeftGripButtonState.JustActivated)
|
||||
{
|
||||
LeftGripActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftGripButtonState.JustDeactivated)
|
||||
{
|
||||
LeftGripDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightGripButtonState.JustActivated)
|
||||
{
|
||||
RightGripActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightGripButtonState.JustDeactivated)
|
||||
{
|
||||
RightGripDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTriggerButtonState.JustActivated)
|
||||
{
|
||||
LeftTriggerActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTriggerButtonState.JustDeactivated)
|
||||
{
|
||||
LeftTriggerDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTriggerButtonState.JustActivated)
|
||||
{
|
||||
RightTriggerActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTriggerButtonState.JustDeactivated)
|
||||
{
|
||||
RightTriggerDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftPrimaryButtonState.JustActivated)
|
||||
{
|
||||
LeftPrimaryActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftPrimaryButtonState.JustDeactivated)
|
||||
{
|
||||
LeftPrimaryDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightPrimaryButtonState.JustActivated)
|
||||
{
|
||||
RightPrimaryActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightPrimaryButtonState.JustDeactivated)
|
||||
{
|
||||
RightPrimaryDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftSecondaryButtonState.JustActivated)
|
||||
{
|
||||
LeftSecondaryActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftSecondaryButtonState.JustDeactivated)
|
||||
{
|
||||
LeftSecondaryDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightSecondaryButtonState.JustActivated)
|
||||
{
|
||||
RightSecondaryActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightSecondaryButtonState.JustDeactivated)
|
||||
{
|
||||
RightSecondaryDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftMenuButtonState.JustActivated)
|
||||
{
|
||||
LeftMenuActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftMenuButtonState.JustDeactivated)
|
||||
{
|
||||
LeftMenuDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightMenuButtonState.JustActivated)
|
||||
{
|
||||
RightMenuActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightMenuButtonState.JustDeactivated)
|
||||
{
|
||||
RightMenuDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftPrimaryTouchButtonState.JustActivated)
|
||||
{
|
||||
LeftPrimaryTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftPrimaryTouchButtonState.JustDeactivated)
|
||||
{
|
||||
LeftPrimaryTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightPrimaryTouchButtonState.JustActivated)
|
||||
{
|
||||
RightPrimaryTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightPrimaryTouchButtonState.JustDeactivated)
|
||||
{
|
||||
RightPrimaryTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftSecondaryTouchButtonState.JustActivated)
|
||||
{
|
||||
LeftSecondaryTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftSecondaryTouchButtonState.JustDeactivated)
|
||||
{
|
||||
LeftSecondaryTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightSecondaryTouchButtonState.JustActivated)
|
||||
{
|
||||
RightSecondaryTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightSecondaryTouchButtonState.JustDeactivated)
|
||||
{
|
||||
RightSecondaryTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftJoystickButtonState.JustActivated)
|
||||
{
|
||||
LeftJoystickActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftJoystickButtonState.JustDeactivated)
|
||||
{
|
||||
LeftJoystickDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightJoystickButtonState.JustActivated)
|
||||
{
|
||||
RightJoystickActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightJoystickButtonState.JustDeactivated)
|
||||
{
|
||||
RightJoystickDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTrackpadButtonState.JustActivated)
|
||||
{
|
||||
LeftTrackpadActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTrackpadButtonState.JustDeactivated)
|
||||
{
|
||||
LeftTrackpadDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTrackpadButtonState.JustActivated)
|
||||
{
|
||||
RightTrackpadActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTrackpadButtonState.JustDeactivated)
|
||||
{
|
||||
RightTrackpadDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftJoystickTouchState.JustActivated)
|
||||
{
|
||||
LeftJoystickTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftJoystickTouchState.JustDeactivated)
|
||||
{
|
||||
LeftJoystickTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightJoystickTouchState.JustActivated)
|
||||
{
|
||||
RightJoystickTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightJoystickTouchState.JustDeactivated)
|
||||
{
|
||||
RightJoystickTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTrackPadTouchState.JustActivated)
|
||||
{
|
||||
LeftTrackPadTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTrackPadTouchState.JustDeactivated)
|
||||
{
|
||||
LeftTrackPadTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTrackPadTouchState.JustActivated)
|
||||
{
|
||||
RightTrackPadTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTrackPadTouchState.JustDeactivated)
|
||||
{
|
||||
RightTrackPadTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTriggerTouchState.JustActivated)
|
||||
{
|
||||
LeftTriggerTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTriggerTouchState.JustDeactivated)
|
||||
{
|
||||
LeftTriggerTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTriggerTouchState.JustActivated)
|
||||
{
|
||||
RightTriggerTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTriggerTouchState.JustDeactivated)
|
||||
{
|
||||
RightTriggerTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftThumbTouchState.JustActivated)
|
||||
{
|
||||
LeftThumbTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftThumbTouchState.JustDeactivated)
|
||||
{
|
||||
LeftThumbTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightThumbTouchState.JustActivated)
|
||||
{
|
||||
RightThumbTouchActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightThumbTouchState.JustDeactivated)
|
||||
{
|
||||
RightThumbTouchDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTrackPadUp.JustActivated)
|
||||
{
|
||||
LeftTrackPadUpActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTrackPadUp.JustDeactivated)
|
||||
{
|
||||
LeftTrackPadUpDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTrackPadUp.JustActivated)
|
||||
{
|
||||
RightTrackPadUpActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTrackPadUp.JustDeactivated)
|
||||
{
|
||||
RightTrackPadUpDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTrackPadLeft.JustActivated)
|
||||
{
|
||||
LeftTrackPadLeftActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTrackPadLeft.JustDeactivated)
|
||||
{
|
||||
LeftTrackPadLeftDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTrackPadLeft.JustActivated)
|
||||
{
|
||||
RightTrackPadLeftActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTrackPadLeft.JustDeactivated)
|
||||
{
|
||||
RightTrackPadLeftDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTrackPadRight.JustActivated)
|
||||
{
|
||||
LeftTrackPadRightActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTrackPadRight.JustDeactivated)
|
||||
{
|
||||
LeftTrackPadRightDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTrackPadRight.JustActivated)
|
||||
{
|
||||
RightTrackPadRightActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTrackPadRight.JustDeactivated)
|
||||
{
|
||||
RightTrackPadRightDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.LeftTrackPadDown.JustActivated)
|
||||
{
|
||||
LeftTrackPadDownActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.LeftTrackPadDown.JustDeactivated)
|
||||
{
|
||||
LeftTrackPadDownDeactivated.Invoke();
|
||||
}
|
||||
if (_globalInputs.RightTrackPadDown.JustActivated)
|
||||
{
|
||||
RightTrackPadDownActivated.Invoke();
|
||||
}
|
||||
else if (_globalInputs.RightTrackPadDown.JustDeactivated)
|
||||
{
|
||||
RightTrackPadDownDeactivated.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd07f8606d5a2184ca2bab0e57b64ef7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
public class HVRGlobalInputs : MonoBehaviour
|
||||
{
|
||||
public static HVRGlobalInputs Instance { get; private set; }
|
||||
|
||||
public float LeftTrigger;
|
||||
public float LeftGrip;
|
||||
public float RightTrigger;
|
||||
public float RightGrip;
|
||||
|
||||
public Vector2 LeftJoystickAxis;
|
||||
public Vector2 LeftTrackpadAxis;
|
||||
|
||||
public Vector2 RightJoystickAxis;
|
||||
public Vector2 RightTrackpadAxis;
|
||||
|
||||
public HVRButtonState LeftGripButtonState;
|
||||
public HVRButtonState LeftTriggerButtonState;
|
||||
public HVRButtonState LeftPrimaryButtonState;
|
||||
public HVRButtonState LeftSecondaryButtonState;
|
||||
public HVRButtonState LeftMenuButtonState;
|
||||
public HVRButtonState LeftPrimaryTouchButtonState;
|
||||
public HVRButtonState LeftSecondaryTouchButtonState;
|
||||
public HVRButtonState LeftJoystickButtonState;
|
||||
public HVRButtonState LeftTrackpadButtonState;
|
||||
|
||||
public HVRButtonState LeftJoystickTouchState;
|
||||
public HVRButtonState LeftTrackPadTouchState;
|
||||
public HVRButtonState LeftTriggerTouchState;
|
||||
public HVRButtonState LeftThumbTouchState;
|
||||
|
||||
public HVRButtonState LeftTriggerNearTouchState;
|
||||
public HVRButtonState LeftThumbNearTouchState;
|
||||
|
||||
public HVRButtonState LeftTrackPadUp;
|
||||
public HVRButtonState LeftTrackPadLeft;
|
||||
public HVRButtonState LeftTrackPadRight;
|
||||
public HVRButtonState LeftTrackPadDown;
|
||||
|
||||
|
||||
public HVRButtonState RightGripButtonState;
|
||||
public HVRButtonState RightTriggerButtonState;
|
||||
public HVRButtonState RightPrimaryButtonState;
|
||||
public HVRButtonState RightSecondaryButtonState;
|
||||
public HVRButtonState RightMenuButtonState;
|
||||
public HVRButtonState RightPrimaryTouchButtonState;
|
||||
public HVRButtonState RightSecondaryTouchButtonState;
|
||||
public HVRButtonState RightJoystickButtonState;
|
||||
public HVRButtonState RightTrackpadButtonState;
|
||||
|
||||
public HVRButtonState RightJoystickTouchState;
|
||||
public HVRButtonState RightTrackPadTouchState;
|
||||
public HVRButtonState RightTriggerTouchState;
|
||||
public HVRButtonState RightThumbTouchState;
|
||||
|
||||
public HVRButtonState RightTriggerNearTouchState;
|
||||
public HVRButtonState RightThumbNearTouchState;
|
||||
|
||||
public HVRButtonState RightTrackPadUp;
|
||||
public HVRButtonState RightTrackPadLeft;
|
||||
public HVRButtonState RightTrackPadRight;
|
||||
public HVRButtonState RightTrackPadDown;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!Instance)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var controller = HVRInputManager.Instance.LeftController;
|
||||
LeftTrigger = controller.Trigger;
|
||||
LeftGrip = controller.Grip;
|
||||
|
||||
LeftJoystickAxis = controller.JoystickAxis;
|
||||
LeftTrackpadAxis = controller.TrackpadAxis;
|
||||
|
||||
LeftGripButtonState = controller.GripButtonState;
|
||||
LeftTriggerButtonState = controller.TriggerButtonState;
|
||||
LeftPrimaryButtonState = controller.PrimaryButtonState;
|
||||
LeftSecondaryButtonState = controller.SecondaryButtonState;
|
||||
LeftMenuButtonState = controller.MenuButtonState;
|
||||
LeftPrimaryTouchButtonState = controller.PrimaryTouchButtonState;
|
||||
LeftSecondaryTouchButtonState = controller.SecondaryTouchButtonState;
|
||||
LeftJoystickButtonState = controller.JoystickButtonState;
|
||||
LeftTrackpadButtonState = controller.TrackpadButtonState;
|
||||
|
||||
LeftJoystickTouchState = controller.JoystickTouchState;
|
||||
LeftTrackPadTouchState = controller.TrackPadTouchState;
|
||||
LeftTriggerTouchState = controller.TriggerTouchState;
|
||||
LeftThumbTouchState = controller.ThumbTouchState;
|
||||
|
||||
LeftTriggerNearTouchState = controller.TriggerNearTouchState;
|
||||
LeftThumbNearTouchState = controller.ThumbNearTouchState;
|
||||
|
||||
LeftTrackPadUp = controller.TrackPadUp;
|
||||
LeftTrackPadLeft = controller.TrackPadLeft;
|
||||
LeftTrackPadRight = controller.TrackPadRight;
|
||||
LeftTrackPadDown = controller.TrackPadDown;
|
||||
|
||||
controller = HVRInputManager.Instance.RightController;
|
||||
|
||||
RightTrigger = controller.Trigger;
|
||||
RightGrip = controller.Grip;
|
||||
|
||||
RightJoystickAxis = controller.JoystickAxis;
|
||||
RightTrackpadAxis = controller.TrackpadAxis;
|
||||
|
||||
RightGripButtonState = controller.GripButtonState;
|
||||
RightTriggerButtonState = controller.TriggerButtonState;
|
||||
RightPrimaryButtonState = controller.PrimaryButtonState;
|
||||
RightSecondaryButtonState = controller.SecondaryButtonState;
|
||||
RightMenuButtonState = controller.MenuButtonState;
|
||||
RightPrimaryTouchButtonState = controller.PrimaryTouchButtonState;
|
||||
RightSecondaryTouchButtonState = controller.SecondaryTouchButtonState;
|
||||
RightJoystickButtonState = controller.JoystickButtonState;
|
||||
RightTrackpadButtonState = controller.TrackpadButtonState;
|
||||
|
||||
RightJoystickTouchState = controller.JoystickTouchState;
|
||||
RightTrackPadTouchState = controller.TrackPadTouchState;
|
||||
RightTriggerTouchState = controller.TriggerTouchState;
|
||||
RightThumbTouchState = controller.ThumbTouchState;
|
||||
|
||||
RightTriggerNearTouchState = controller.TriggerNearTouchState;
|
||||
RightThumbNearTouchState = controller.ThumbNearTouchState;
|
||||
|
||||
RightTrackPadUp = controller.TrackPadUp;
|
||||
RightTrackPadLeft = controller.TrackPadLeft;
|
||||
RightTrackPadRight = controller.TrackPadRight;
|
||||
RightTrackPadDown = controller.TrackPadDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cbdb3f5a90abf442b512b58ce932e71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using HurricaneVR.Framework.Core;
|
||||
using HurricaneVR.Framework.Core.Grabbers;
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
[RequireComponent(typeof(HVRGrabbable))]
|
||||
public abstract class HVRInputAction : MonoBehaviour
|
||||
{
|
||||
public HVRGrabbable Grabbable { get; private set; }
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Grabbable = GetComponent<HVRGrabbable>();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
for (var i = 0; i < Grabbable.HandGrabbers.Count; i++)
|
||||
{
|
||||
var hand = Grabbable.HandGrabbers[i];
|
||||
var controller = HVRInputManager.Instance.GetController(hand.HandSide);
|
||||
CheckInput(controller);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void CheckInput(HVRController controller);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a934dfe7ddf4fb2a1ec98943c4bcd57
|
||||
timeCreated: 1604448529
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94e2703aa70f47be808cc7d516fced77
|
||||
timeCreated: 1600342873
|
||||
@@ -0,0 +1,167 @@
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using HurricaneVR.Framework.Core;
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
#if USING_OPENXR
|
||||
using UnityEngine.XR.OpenXR.Input;
|
||||
#endif
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
|
||||
public class HVRInputSystemController : HVRController
|
||||
{
|
||||
public static HVRInputActions InputActions = null;
|
||||
private InputDevice _inputDevice;
|
||||
|
||||
public bool IsOpenXR;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
static void Cleanup()
|
||||
{
|
||||
if (InputActions != null)
|
||||
{
|
||||
InputActions.Disable();
|
||||
InputActions.Dispose();
|
||||
InputActions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (InputActions == null)
|
||||
{
|
||||
InputActions = new HVRInputActions();
|
||||
InputActions.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
Init();
|
||||
|
||||
UnityEngine.InputSystem.InputSystem.onDeviceChange += OnDeviceChanged;
|
||||
}
|
||||
|
||||
private void OnDeviceChanged(InputDevice device, InputDeviceChange change)
|
||||
{
|
||||
if (change == InputDeviceChange.Added)
|
||||
{
|
||||
if (device.usages.Contains(CommonUsages.LeftHand) && Side == HVRHandSide.Left || device.usages.Contains(CommonUsages.RightHand) && Side == HVRHandSide.Right)
|
||||
{
|
||||
_inputDevice = device;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateInput()
|
||||
{
|
||||
if (Side == HVRHandSide.Left)
|
||||
{
|
||||
JoystickAxis = InputActions.LeftHand.Primary2DAxis.ReadValue<Vector2>();
|
||||
|
||||
SetBool(out JoystickClicked, InputActions.LeftHand.Primary2DAxisClick);
|
||||
SetBool(out TrackPadClicked, InputActions.LeftHand.Secondary2DAxisClick);
|
||||
|
||||
TrackpadAxis = InputActions.LeftHand.Secondary2DAxis.ReadValue<Vector2>();
|
||||
|
||||
Grip = InputActions.LeftHand.Grip.ReadValue<float>();
|
||||
GripForce = InputActions.LeftHand.GripForce.ReadValue<float>();
|
||||
Trigger = InputActions.LeftHand.Trigger.ReadValue<float>();
|
||||
|
||||
SetBool(out PrimaryButton, InputActions.LeftHand.PrimaryButton);
|
||||
SetBool(out SecondaryButton, InputActions.LeftHand.SecondaryButton);
|
||||
|
||||
SetBool(out PrimaryTouch, InputActions.LeftHand.PrimaryTouch);
|
||||
SetBool(out SecondaryTouch, InputActions.LeftHand.SecondaryTouch);
|
||||
|
||||
SetBool(out JoystickTouch, InputActions.LeftHand.Primary2DAxisTouch);
|
||||
SetBool(out TrackPadTouch, InputActions.LeftHand.Secondary2DAxisTouch);
|
||||
|
||||
SetBool(out TriggerTouch, InputActions.LeftHand.TriggerTouch);
|
||||
|
||||
SetBool(out MenuButton, InputActions.LeftHand.Menu);
|
||||
|
||||
SetBool(out GripButton, InputActions.LeftHand.GripPress);
|
||||
SetBool(out TriggerButton, InputActions.LeftHand.TriggerPress);
|
||||
}
|
||||
else
|
||||
{
|
||||
JoystickAxis = InputActions.RightHand.Primary2DAxis.ReadValue<Vector2>();
|
||||
|
||||
SetBool(out JoystickClicked, InputActions.RightHand.Primary2DAxisClick);
|
||||
SetBool(out TrackPadClicked, InputActions.RightHand.Secondary2DAxisClick);
|
||||
|
||||
TrackpadAxis = InputActions.RightHand.Secondary2DAxis.ReadValue<Vector2>();
|
||||
|
||||
Grip = InputActions.RightHand.Grip.ReadValue<float>();
|
||||
GripForce = InputActions.RightHand.GripForce.ReadValue<float>();
|
||||
Trigger = InputActions.RightHand.Trigger.ReadValue<float>();
|
||||
|
||||
SetBool(out PrimaryButton, InputActions.RightHand.PrimaryButton);
|
||||
SetBool(out SecondaryButton, InputActions.RightHand.SecondaryButton);
|
||||
|
||||
SetBool(out PrimaryTouch, InputActions.RightHand.PrimaryTouch);
|
||||
SetBool(out SecondaryTouch, InputActions.RightHand.SecondaryTouch);
|
||||
|
||||
SetBool(out JoystickTouch, InputActions.RightHand.Primary2DAxisTouch);
|
||||
SetBool(out TrackPadTouch, InputActions.RightHand.Secondary2DAxisTouch);
|
||||
|
||||
SetBool(out TriggerTouch, InputActions.RightHand.TriggerTouch);
|
||||
|
||||
SetBool(out MenuButton, InputActions.RightHand.Menu);
|
||||
|
||||
SetBool(out GripButton, InputActions.RightHand.GripPress);
|
||||
SetBool(out TriggerButton, InputActions.RightHand.TriggerPress);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SetBool(out bool val, InputAction action)
|
||||
{
|
||||
val = false;
|
||||
if (action.activeControl != null)
|
||||
{
|
||||
var type = action.activeControl.valueType;
|
||||
if (type == typeof(bool))
|
||||
{
|
||||
val = action.ReadValue<bool>();
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
val = action.ReadValue<float>() > .5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Vibrate(float amplitude, float duration = 1, float frequency = 1)
|
||||
{
|
||||
if (HVRSettings.Instance.DisableHaptics) return;
|
||||
|
||||
#if USING_OPENXR
|
||||
|
||||
if (IsOpenXR)
|
||||
{
|
||||
var action = Side == HVRHandSide.Left ? InputActions.LeftHand.Haptics : InputActions.RightHand.Haptics;
|
||||
|
||||
if (action != null && _inputDevice != null)
|
||||
{
|
||||
OpenXRInput.SendHapticImpulse(action, amplitude, frequency, duration, _inputDevice);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
base.Vibrate(amplitude, duration, frequency);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e9db12adedf02d4797c05ee5c7cbacb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,112 @@
|
||||
#if USING_XRHANDS
|
||||
using System.Collections.Generic;
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Hands;
|
||||
|
||||
#endif
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
public static class HVROpenXRFingerCurls
|
||||
{
|
||||
#if USING_XRHANDS
|
||||
private static float minCurl = 0.15f;
|
||||
private static float maxCurl = 0.9f;
|
||||
|
||||
private static XRHandSubsystem system;
|
||||
private static readonly List<XRHandSubsystem> systems = new List<XRHandSubsystem>();
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (system == null || !system.running)
|
||||
{
|
||||
SubsystemManager.GetSubsystems(systems);
|
||||
for (var i = 0; i < systems.Count; ++i)
|
||||
{
|
||||
var handSubsystem = systems[i];
|
||||
if (handSubsystem.running)
|
||||
{
|
||||
system = handSubsystem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetCurls(HVRHandSide handSide, float[] curls)
|
||||
{
|
||||
if (system == null || !system.running)
|
||||
return false;
|
||||
|
||||
XRHand hand = default;
|
||||
|
||||
if (handSide == HVRHandSide.Left)
|
||||
{
|
||||
hand = system.leftHand;
|
||||
}
|
||||
else
|
||||
{
|
||||
hand = system.rightHand;
|
||||
}
|
||||
|
||||
return hand.isTracked && TryCalculateFingerCurvatures(hand, curls);
|
||||
}
|
||||
|
||||
static bool TryCalculateFingerCurvatures(XRHand hand, float[] curls)
|
||||
{
|
||||
Handedness handedness = hand.handedness;
|
||||
|
||||
if (!TryCalculateFingerCurvature(hand, handedness, XRHandJointID.ThumbMetacarpal, XRHandJointID.ThumbProximal, XRHandJointID.ThumbDistal, XRHandJointID.ThumbTip, out curls[0]))
|
||||
return false;
|
||||
if (!TryCalculateFingerCurvature(hand, handedness, XRHandJointID.IndexMetacarpal, XRHandJointID.IndexProximal, XRHandJointID.IndexIntermediate, XRHandJointID.IndexDistal, out curls[1]))
|
||||
return false;
|
||||
if (!TryCalculateFingerCurvature(hand, handedness, XRHandJointID.MiddleMetacarpal, XRHandJointID.MiddleProximal, XRHandJointID.MiddleIntermediate, XRHandJointID.MiddleDistal, out curls[2]))
|
||||
return false;
|
||||
if (!TryCalculateFingerCurvature(hand, handedness, XRHandJointID.RingMetacarpal, XRHandJointID.RingProximal, XRHandJointID.RingIntermediate, XRHandJointID.RingDistal, out curls[3]))
|
||||
return false;
|
||||
if (!TryCalculateFingerCurvature(hand, handedness, XRHandJointID.LittleMetacarpal, XRHandJointID.LittleProximal, XRHandJointID.LittleIntermediate, XRHandJointID.LittleDistal, out curls[4]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool TryCalculateFingerCurvature(XRHand hand, Handedness handName, XRHandJointID metacarpalId, XRHandJointID proximalId, XRHandJointID intermediateId, XRHandJointID distalId, out float curl)
|
||||
{
|
||||
var metacarpalJoint = hand.GetJoint(metacarpalId);
|
||||
var proximalJoint = hand.GetJoint(proximalId);
|
||||
var intermediateJoint = hand.GetJoint(intermediateId);
|
||||
var distalJoint = hand.GetJoint(distalId);
|
||||
|
||||
if (metacarpalJoint.TryGetPose(out Pose metacarpalPose) &&
|
||||
proximalJoint.TryGetPose(out Pose proximalPose) &&
|
||||
intermediateJoint.TryGetPose(out Pose intermediatePose) &&
|
||||
distalJoint.TryGetPose(out Pose distalPose))
|
||||
{
|
||||
float curvature = CalculateCurvature(metacarpalPose, proximalPose, intermediatePose, distalPose);
|
||||
float remappedCurvature = Remap(curvature, minCurl, maxCurl, 0f, 1f);
|
||||
curl = remappedCurvature;
|
||||
return true;
|
||||
}
|
||||
|
||||
curl = 0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
static float CalculateCurvature(Pose metacarpal, Pose proximal, Pose intermediate, Pose distal)
|
||||
{
|
||||
float angle1 = Vector3.Angle(metacarpal.position - proximal.position, proximal.position - intermediate.position);
|
||||
float angle2 = Vector3.Angle(proximal.position - intermediate.position, intermediate.position - distal.position);
|
||||
float normalizedAngle = (angle1 + angle2) / 180.0f; // 180 degrees being the max angle (fully extended)
|
||||
return Mathf.Clamp01(normalizedAngle);
|
||||
}
|
||||
|
||||
static float Remap(float value, float from1, float to1, float from2, float to2)
|
||||
{
|
||||
value = Mathf.Clamp(value, minCurl, maxCurl);
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7033fdbdef534aeaaad3c868224922db
|
||||
timeCreated: 1718677714
|
||||
@@ -0,0 +1,501 @@
|
||||
using System;
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the player controller, teleporter, and hand grabbing systems to drive their actions.
|
||||
/// Subclass and override the virtual methods if you wish to customize inputs per device.
|
||||
/// </summary>
|
||||
public class HVRPlayerInputs : MonoBehaviour
|
||||
{
|
||||
[Header("Grab Settings")]
|
||||
public bool CanDistanceGrab = true;
|
||||
|
||||
public bool CanTriggerGrab;
|
||||
|
||||
[Tooltip("For non flick style force grabber")]
|
||||
public HVRForceGrabActivation ForceGrabActivation = HVRForceGrabActivation.Grip;
|
||||
|
||||
[Range(0f, 1f)]
|
||||
public float TriggerGrabThreshold = .7f;
|
||||
|
||||
[Header("Inputs Debugging")]
|
||||
public Vector2 MovementAxis;
|
||||
|
||||
public Vector2 TurnAxis;
|
||||
|
||||
public bool IsTeleportActivated;
|
||||
public bool IsTeleportDeactivated;
|
||||
|
||||
public bool IsSprintingActivated;
|
||||
public bool SprintRequiresDoubleClick;
|
||||
|
||||
public bool IsCrouchActivated;
|
||||
public bool IsStandActivated;
|
||||
|
||||
public HVRButtonState JumpState;
|
||||
public HVRButtonState CrouchState;
|
||||
public HVRButtonState StandState;
|
||||
|
||||
public HVRButtonState LeftTriggerGrabState;
|
||||
public HVRButtonState RightTriggerGrabState;
|
||||
|
||||
public bool IsLeftGrabActivated;
|
||||
public bool IsLeftHoldActive;
|
||||
public bool IsLeftGripHoldActive;
|
||||
public bool IsLeftTriggerHoldActive;
|
||||
|
||||
public bool IsRightGrabActivated;
|
||||
public bool IsRightHoldActive;
|
||||
public bool IsRightGripHoldActive;
|
||||
public bool IsRightTriggerHoldActive;
|
||||
|
||||
public bool IsLeftForceGrabActive;
|
||||
public bool IsRightForceGrabActive;
|
||||
|
||||
public bool IsLeftForceGrabActivated;
|
||||
public bool IsRightForceGrabActivated;
|
||||
|
||||
public bool IsJumpActivated;
|
||||
|
||||
public HVRHandSide TeleportHandSide = HVRHandSide.Right;
|
||||
public bool SwapMovementAxis;
|
||||
|
||||
|
||||
[Header("Debugging")]
|
||||
public bool UseWASD;
|
||||
|
||||
public bool IsMouseDown;
|
||||
public Vector2 MouseAxis;
|
||||
|
||||
public bool UpdateInputs { get; set; } = true;
|
||||
|
||||
public HVRController RightController => HVRInputManager.Instance.RightController;
|
||||
public HVRController LeftController => HVRInputManager.Instance.LeftController;
|
||||
|
||||
public HVRControllerType RightControllerType => RightController.ControllerType;
|
||||
public HVRControllerType LeftControllerType => LeftController.ControllerType;
|
||||
|
||||
public HVRController TeleportController => TeleportHandSide == HVRHandSide.Left ? HVRInputManager.Instance.LeftController : HVRInputManager.Instance.RightController;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
UpdateInput();
|
||||
AfterInputUpdate();
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected virtual void UpdateInput()
|
||||
{
|
||||
if (!UpdateInputs)
|
||||
return;
|
||||
|
||||
ResetState(ref LeftTriggerGrabState);
|
||||
ResetState(ref RightTriggerGrabState);
|
||||
SetState(ref LeftTriggerGrabState, LeftController.Trigger > TriggerGrabThreshold);
|
||||
SetState(ref RightTriggerGrabState, RightController.Trigger > TriggerGrabThreshold);
|
||||
|
||||
MovementAxis = GetMovementAxis();
|
||||
TurnAxis = GetTurnAxis();
|
||||
IsTeleportActivated = GetTeleportActivated();
|
||||
IsTeleportDeactivated = GetTeleportDeactivated();
|
||||
IsSprintingActivated = GetSprinting();
|
||||
|
||||
IsCrouchActivated = GetCrouch();
|
||||
|
||||
IsLeftGrabActivated = GetIsLeftGrabActivated();
|
||||
IsLeftHoldActive = GetIsLeftHoldActive();
|
||||
|
||||
IsRightGrabActivated = GetIsRightGrabActivated();
|
||||
IsRightHoldActive = GetIsRightHoldActive();
|
||||
|
||||
GetForceGrabActivated(out IsLeftForceGrabActivated, out IsRightForceGrabActivated);
|
||||
GetForceGrabActive(out IsLeftForceGrabActive, out IsRightForceGrabActive);
|
||||
|
||||
IsJumpActivated = GetIsJumpActivated();
|
||||
IsStandActivated = GetStand();
|
||||
MouseAxis = GetMouse(out IsMouseDown);
|
||||
|
||||
ResetState(ref CrouchState);
|
||||
ResetState(ref StandState);
|
||||
ResetState(ref JumpState);
|
||||
|
||||
SetState(ref CrouchState, IsCrouchActivated);
|
||||
SetState(ref StandState, IsStandActivated);
|
||||
SetState(ref JumpState, IsJumpActivated);
|
||||
}
|
||||
|
||||
protected virtual void AfterInputUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected void ResetState(ref HVRButtonState buttonState)
|
||||
{
|
||||
buttonState.JustDeactivated = false;
|
||||
buttonState.JustActivated = false;
|
||||
buttonState.Value = 0f;
|
||||
}
|
||||
|
||||
protected void SetState(ref HVRButtonState buttonState, bool pressed)
|
||||
{
|
||||
if (pressed)
|
||||
{
|
||||
if (!buttonState.Active)
|
||||
{
|
||||
buttonState.JustActivated = true;
|
||||
buttonState.Active = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buttonState.Active)
|
||||
{
|
||||
buttonState.Active = false;
|
||||
buttonState.JustDeactivated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected virtual bool GetStand()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool GetIsJumpActivated()
|
||||
{
|
||||
if (RightController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
return false; //todo
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void GetForceGrabActivated(out bool left, out bool right)
|
||||
{
|
||||
left = false;
|
||||
right = false;
|
||||
|
||||
if (!CanDistanceGrab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ForceGrabActivation == HVRForceGrabActivation.Grip)
|
||||
{
|
||||
left = LeftController.GripButtonState.JustActivated;
|
||||
right = RightController.GripButtonState.JustActivated;
|
||||
}
|
||||
else if (ForceGrabActivation == HVRForceGrabActivation.GripAndTrigger)
|
||||
{
|
||||
left = LeftController.GripButtonState.Active && LeftTriggerGrabState.JustActivated || LeftTriggerGrabState.Active && LeftController.GripButtonState.JustActivated;
|
||||
right = RightController.GripButtonState.Active && RightTriggerGrabState.JustActivated || RightTriggerGrabState.Active && RightController.GripButtonState.JustActivated;
|
||||
}
|
||||
else if (ForceGrabActivation == HVRForceGrabActivation.Trigger)
|
||||
{
|
||||
left = LeftTriggerGrabState.JustActivated;
|
||||
right = RightTriggerGrabState.JustActivated;
|
||||
}
|
||||
else if (ForceGrabActivation == HVRForceGrabActivation.GripOrTrigger)
|
||||
{
|
||||
left = LeftController.GripButtonState.JustActivated || LeftTriggerGrabState.JustActivated;
|
||||
right = RightController.GripButtonState.JustActivated || RightTriggerGrabState.JustActivated;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected virtual void GetForceGrabActive(out bool left, out bool right)
|
||||
{
|
||||
left = false;
|
||||
right = false;
|
||||
|
||||
if (!CanDistanceGrab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ForceGrabActivation == HVRForceGrabActivation.Grip)
|
||||
{
|
||||
left = LeftController.GripButtonState.Active;
|
||||
right = RightController.GripButtonState.Active;
|
||||
}
|
||||
else if (ForceGrabActivation == HVRForceGrabActivation.GripAndTrigger || ForceGrabActivation == HVRForceGrabActivation.GripOrTrigger)
|
||||
{
|
||||
left = LeftController.GripButtonState.Active || LeftTriggerGrabState.Active;
|
||||
right = RightController.GripButtonState.Active || RightTriggerGrabState.Active;
|
||||
}
|
||||
else if (ForceGrabActivation == HVRForceGrabActivation.Trigger)
|
||||
{
|
||||
left = LeftTriggerGrabState.Active;
|
||||
right = RightTriggerGrabState.Active;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool GetForceGrabActivated(HVRHandSide side)
|
||||
{
|
||||
if (!CanDistanceGrab)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return side == HVRHandSide.Left ? IsLeftForceGrabActivated : IsRightForceGrabActivated;
|
||||
}
|
||||
|
||||
public bool GetForceGrabActive(HVRHandSide side)
|
||||
{
|
||||
if (!CanDistanceGrab)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return side == HVRHandSide.Left ? IsLeftForceGrabActive : IsRightForceGrabActive;
|
||||
}
|
||||
|
||||
public bool GetGrabActivated(HVRHandSide side)
|
||||
{
|
||||
return side == HVRHandSide.Left ? IsLeftGrabActivated : IsRightGrabActivated;
|
||||
}
|
||||
|
||||
public bool GetGripHoldActive(HVRHandSide side)
|
||||
{
|
||||
return side == HVRHandSide.Left ? IsLeftGripHoldActive : IsRightGripHoldActive;
|
||||
}
|
||||
|
||||
public HVRButtonState GetTriggerGrabState(HVRHandSide side)
|
||||
{
|
||||
return side == HVRHandSide.Left ? LeftTriggerGrabState : RightTriggerGrabState;
|
||||
}
|
||||
|
||||
protected virtual bool GetIsLeftGrabActivated()
|
||||
{
|
||||
return LeftController.GripButtonState.JustActivated;
|
||||
}
|
||||
|
||||
|
||||
protected virtual bool GetIsLeftHoldActive()
|
||||
{
|
||||
IsLeftTriggerHoldActive = LeftController.Trigger > TriggerGrabThreshold;
|
||||
IsLeftGripHoldActive = LeftController.GripButtonState.Active;
|
||||
if (CanTriggerGrab && IsLeftTriggerHoldActive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return LeftController.GripButtonState.Active;
|
||||
}
|
||||
|
||||
protected virtual bool GetIsRightGrabActivated()
|
||||
{
|
||||
return RightController.GripButtonState.JustActivated;
|
||||
}
|
||||
|
||||
|
||||
protected virtual bool GetIsRightHoldActive()
|
||||
{
|
||||
IsRightTriggerHoldActive = RightController.Trigger > TriggerGrabThreshold;
|
||||
IsRightGripHoldActive = RightController.GripButtonState.Active;
|
||||
if (CanTriggerGrab && IsRightTriggerHoldActive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return RightController.GripButtonState.Active;
|
||||
}
|
||||
|
||||
protected virtual Vector2 GetMovementAxis()
|
||||
{
|
||||
if (UseWASD)
|
||||
{
|
||||
var wasd = CheckWASD();
|
||||
if (wasd.sqrMagnitude > 0f)
|
||||
return wasd;
|
||||
}
|
||||
|
||||
if (SwapMovementAxis)
|
||||
{
|
||||
if (RightController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
if (RightController.TrackpadButtonState.Active)
|
||||
return RightController.TrackpadAxis;
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
return RightController.JoystickAxis;
|
||||
}
|
||||
|
||||
if (LeftController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
if (LeftController.TrackpadButtonState.Active)
|
||||
return LeftController.TrackpadAxis;
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
return LeftController.JoystickAxis;
|
||||
}
|
||||
|
||||
private Vector2 CheckWASD()
|
||||
{
|
||||
var x = 0f;
|
||||
var y = 0f;
|
||||
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
if (Input.GetKey(KeyCode.W))
|
||||
y += 1f;
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
y -= 1f;
|
||||
if (Input.GetKey(KeyCode.A))
|
||||
x += -1f;
|
||||
if (Input.GetKey(KeyCode.D))
|
||||
x += 1f;
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
if (Keyboard.current[Key.W].isPressed)
|
||||
y += 1f;
|
||||
if (Keyboard.current[Key.S].isPressed)
|
||||
y -= 1f;
|
||||
if (Keyboard.current[Key.A].isPressed)
|
||||
x += -1f;
|
||||
if (Keyboard.current[Key.D].isPressed)
|
||||
x += 1f;
|
||||
#endif
|
||||
|
||||
return new Vector2(x, y);
|
||||
}
|
||||
|
||||
protected virtual Vector2 GetTurnAxis()
|
||||
{
|
||||
if (SwapMovementAxis)
|
||||
{
|
||||
if (LeftController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
if (Mathf.Abs(LeftController.TrackpadAxis.y) > .6f)
|
||||
return Vector2.zero;
|
||||
|
||||
if (LeftController.TrackpadButtonState.Active)
|
||||
{
|
||||
return LeftController.TrackpadAxis;
|
||||
}
|
||||
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
return LeftController.JoystickAxis;
|
||||
}
|
||||
|
||||
if (RightController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
if (Mathf.Abs(RightController.TrackpadAxis.y) > .6f)
|
||||
return Vector2.zero;
|
||||
|
||||
if (RightController.TrackpadButtonState.Active)
|
||||
{
|
||||
return RightController.TrackpadAxis;
|
||||
}
|
||||
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
return RightController.JoystickAxis;
|
||||
}
|
||||
|
||||
protected virtual bool GetTeleportDeactivated()
|
||||
{
|
||||
if (HVRInputManager.Instance.RightController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
return HVRController.GetButtonState(HVRHandSide.Right, HVRButtons.Menu).JustDeactivated;
|
||||
}
|
||||
|
||||
return TeleportController.JoystickAxis.y > -.25f;
|
||||
}
|
||||
|
||||
protected virtual bool GetTeleportActivated()
|
||||
{
|
||||
if (HVRInputManager.Instance.RightController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
return HVRController.GetButtonState(HVRHandSide.Right, HVRButtons.Menu).Active;
|
||||
}
|
||||
|
||||
return TeleportController.JoystickAxis.y < -.5f && Mathf.Abs(TeleportController.JoystickAxis.x) < .30;
|
||||
}
|
||||
|
||||
protected virtual bool GetSprinting()
|
||||
{
|
||||
if (LeftController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
SprintRequiresDoubleClick = true;
|
||||
return LeftController.TrackpadButtonState.JustActivated;
|
||||
}
|
||||
|
||||
SprintRequiresDoubleClick = false;
|
||||
if (RightController.ControllerType == HVRControllerType.WMR)
|
||||
{
|
||||
return RightController.TrackPadRight.JustActivated;
|
||||
}
|
||||
|
||||
//controls that allow you to depress the joystick (wmr opens up steamvr)
|
||||
return LeftController.JoystickButtonState.JustActivated;
|
||||
}
|
||||
|
||||
protected virtual bool GetCrouch()
|
||||
{
|
||||
if (RightController.ControllerType == HVRControllerType.Vive)
|
||||
{
|
||||
return RightController.TrackPadUp.JustActivated;
|
||||
}
|
||||
|
||||
if (RightController.ControllerType == HVRControllerType.WMR)
|
||||
{
|
||||
return RightController.TrackPadDown.JustActivated;
|
||||
}
|
||||
|
||||
return RightController.SecondaryButtonState.JustActivated;
|
||||
}
|
||||
|
||||
protected virtual Vector2 GetMouse(out bool mouseDown)
|
||||
{
|
||||
mouseDown = false;
|
||||
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
mouseDown = true;
|
||||
return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
|
||||
}
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
if (Mouse.current.rightButton.isPressed)
|
||||
{
|
||||
mouseDown = true;
|
||||
return Mouse.current.delta.ReadValue();
|
||||
}
|
||||
#endif
|
||||
|
||||
return Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
public enum HVRForceGrabActivation
|
||||
{
|
||||
Grip,
|
||||
GripAndTrigger,
|
||||
Trigger,
|
||||
GripOrTrigger
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f258b67bcfea4b9782cfcdcd54058670
|
||||
timeCreated: 1603043879
|
||||
@@ -0,0 +1,38 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
public class HVRTrackedController : MonoBehaviour
|
||||
{
|
||||
public HVRHandSide HandSide;
|
||||
|
||||
public float VelocityMagnitude;// { get; private set; }
|
||||
public float AngularVelocityMagnitude;// { get; private set; }
|
||||
|
||||
public Quaternion DeltaRotationZ { get; private set; }
|
||||
public float DeltaEulerZ { get; private set; }
|
||||
private Vector3 _previousUp;
|
||||
public float DeltaZDisplay;
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var delta = Vector3.SignedAngle(_previousUp, transform.up, transform.forward);
|
||||
DeltaEulerZ = delta;
|
||||
DeltaRotationZ = Quaternion.Euler(0, 0, delta);
|
||||
_previousUp = transform.up;
|
||||
if (Mathf.Abs(DeltaEulerZ) > 2)
|
||||
{
|
||||
DeltaZDisplay = DeltaEulerZ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
VelocityMagnitude = HVRInputManager.Instance.GetController(HandSide).VelocityMagnitude;
|
||||
AngularVelocityMagnitude = HVRInputManager.Instance.GetController(HandSide).AngularVelocityMagnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44ea0e34f99846a4824b42b44d2e35cd
|
||||
timeCreated: 1600355474
|
||||
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput
|
||||
{
|
||||
|
||||
|
||||
enum ButtonReadType
|
||||
{
|
||||
None = 0,
|
||||
Binary,
|
||||
Axis1D,
|
||||
Axis2DUp,
|
||||
Axis2DDown,
|
||||
Axis2DLeft,
|
||||
Axis2DRight
|
||||
}
|
||||
|
||||
struct ButtonInfo
|
||||
{
|
||||
public ButtonInfo(string name, ButtonReadType type)
|
||||
{
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public string name;
|
||||
public ButtonReadType type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class HVRXRInputController : HVRController
|
||||
{
|
||||
|
||||
static ButtonInfo[] s_ButtonData = new ButtonInfo[]
|
||||
{
|
||||
new ButtonInfo("", ButtonReadType.None),
|
||||
new ButtonInfo("MenuButton", ButtonReadType.Binary),
|
||||
new ButtonInfo("Trigger", ButtonReadType.Axis1D),
|
||||
new ButtonInfo("Grip", ButtonReadType.Axis1D),
|
||||
new ButtonInfo("TriggerPressed", ButtonReadType.Binary),
|
||||
new ButtonInfo("GripPressed", ButtonReadType.Binary),
|
||||
new ButtonInfo("PrimaryButton", ButtonReadType.Binary),
|
||||
new ButtonInfo("PrimaryTouch", ButtonReadType.Binary),
|
||||
new ButtonInfo("SecondaryButton", ButtonReadType.Binary),
|
||||
new ButtonInfo("SecondaryTouch", ButtonReadType.Binary),
|
||||
new ButtonInfo("Primary2DAxisTouch", ButtonReadType.Binary),
|
||||
new ButtonInfo("Primary2DAxisClick", ButtonReadType.Binary),
|
||||
new ButtonInfo("Secondary2DAxisTouch", ButtonReadType.Binary),
|
||||
new ButtonInfo("Secondary2DAxisClick", ButtonReadType.Binary),
|
||||
new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DUp),
|
||||
new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DDown),
|
||||
new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DLeft),
|
||||
new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DRight),
|
||||
new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DUp),
|
||||
new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DDown),
|
||||
new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DLeft),
|
||||
new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DRight),
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
protected virtual InputFeatureUsage<Vector2> JoystickAxisFeature => InputMap.JoystickAxis == InputAxes.Primary2DAxis ?
|
||||
CommonUsages.primary2DAxis : CommonUsages.secondary2DAxis;
|
||||
|
||||
protected virtual InputFeatureUsage<Vector2> TrackPadAxisFeature => InputMap.TrackPadAxis == InputAxes.Primary2DAxis ?
|
||||
CommonUsages.primary2DAxis : CommonUsages.secondary2DAxis;
|
||||
|
||||
|
||||
|
||||
protected override void UpdateInput()
|
||||
{
|
||||
if (InputMap)
|
||||
{
|
||||
Device.TryGetFeatureValue(JoystickAxisFeature, out JoystickAxis);
|
||||
Device.TryGetFeatureValue(TrackPadAxisFeature, out TrackpadAxis);
|
||||
|
||||
Device.TryGetFeatureValue(CommonUsages.grip, out Grip);
|
||||
Device.TryGetFeatureValue(CommonUsages.trigger, out Trigger);
|
||||
|
||||
PrimaryButton = IsPressed(Device, InputMap.Primary);
|
||||
PrimaryTouch = IsPressed(Device, InputMap.PrimaryTouch);
|
||||
|
||||
SecondaryButton = IsPressed(Device, InputMap.Secondary);
|
||||
SecondaryTouch = IsPressed(Device, InputMap.SecondaryTouch);
|
||||
|
||||
MenuButton = IsPressed(Device, InputMap.Menu);
|
||||
|
||||
JoystickClicked = IsPressed(Device, InputMap.JoystickButton);
|
||||
TrackPadClicked = IsPressed(Device, InputMap.TrackPadButton);
|
||||
|
||||
JoystickTouch = IsPressed(Device, InputMap.JoystickTouch);
|
||||
TrackPadTouch = IsPressed(Device, InputMap.TrackPadTouch);
|
||||
|
||||
#if USING_XR_MANAGEMENT
|
||||
Device.TryGetFeatureValue(indexTouch, out TriggerTouch);
|
||||
#else
|
||||
Device.TryGetFeatureValue(legacyIndexTouch, out var temp);
|
||||
|
||||
TriggerTouch = temp > 0f;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private readonly InputFeatureUsage<bool> indexTouch = new InputFeatureUsage<bool>("IndexTouch");
|
||||
private static InputFeatureUsage<float> legacyIndexTouch = new InputFeatureUsage<float>("IndexTouch");
|
||||
|
||||
protected override void AfterInputUpdate()
|
||||
{
|
||||
SetButtonState(HVRButtons.ThumbNearTouch, ref ThumbNearTouchState, ThumbTouch);
|
||||
SetButtonState(HVRButtons.TriggerNearTouch, ref TriggerNearTouchState, TriggerTouch);
|
||||
SetButtonState(HVRButtons.ThumbTouch, ref ThumbTouchState, PrimaryTouch || SecondaryTouch || TrackPadTouch || JoystickTouch);
|
||||
}
|
||||
|
||||
public bool CheckAdditionalFeature(HVRXRInputFeatures input)
|
||||
{
|
||||
if (input == HVRXRInputFeatures.SecondaryAxis2DUp ||
|
||||
input == HVRXRInputFeatures.SecondaryAxis2DDown ||
|
||||
input == HVRXRInputFeatures.SecondaryAxis2DLeft ||
|
||||
input == HVRXRInputFeatures.SecondaryAxis2DRight)
|
||||
{
|
||||
return IsPressed(Device, InputMap.TrackPadButton);
|
||||
}
|
||||
|
||||
if (input == HVRXRInputFeatures.PrimaryAxis2DUp ||
|
||||
input == HVRXRInputFeatures.PrimaryAxis2DDown ||
|
||||
input == HVRXRInputFeatures.PrimaryAxis2DLeft ||
|
||||
input == HVRXRInputFeatures.PrimaryAxis2DRight)
|
||||
{
|
||||
return IsPressed(Device, InputMap.TrackPadButton);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsPressed(InputDevice device, HVRXRInputFeatures inputFeature, float threshold = 0f)
|
||||
{
|
||||
if ((int)inputFeature >= s_ButtonData.Length)
|
||||
{
|
||||
throw new ArgumentException("[InputHelpers.IsPressed] The value of <button> is out or the supported range.");
|
||||
}
|
||||
|
||||
//button down check in addition to track pad check
|
||||
if (!CheckAdditionalFeature(inputFeature))
|
||||
return false;
|
||||
|
||||
var info = s_ButtonData[(int)inputFeature];
|
||||
switch (info.type)
|
||||
{
|
||||
case ButtonReadType.Binary:
|
||||
{
|
||||
if (device.TryGetFeatureValue(new InputFeatureUsage<bool>(info.name), out bool value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ButtonReadType.Axis1D:
|
||||
{
|
||||
if (device.TryGetFeatureValue(new InputFeatureUsage<float>(info.name), out float value))
|
||||
{
|
||||
return value >= threshold;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ButtonReadType.Axis2DUp:
|
||||
{
|
||||
if (device.TryGetFeatureValue(new InputFeatureUsage<Vector2>(info.name), out Vector2 value))
|
||||
{
|
||||
return value.y >= InputMap.Axis2DUpThreshold;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ButtonReadType.Axis2DDown:
|
||||
{
|
||||
if (device.TryGetFeatureValue(new InputFeatureUsage<Vector2>(info.name), out Vector2 value))
|
||||
{
|
||||
return value.y <= -InputMap.Axis2DDownThreshold;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ButtonReadType.Axis2DLeft:
|
||||
{
|
||||
if (device.TryGetFeatureValue(new InputFeatureUsage<Vector2>(info.name), out Vector2 value))
|
||||
{
|
||||
return value.x <= -InputMap.Axis2DLeftThreshold;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ButtonReadType.Axis2DRight:
|
||||
{
|
||||
if (device.TryGetFeatureValue(new InputFeatureUsage<Vector2>(info.name), out Vector2 value))
|
||||
{
|
||||
return value.x >= InputMap.Axis2DRighThreshold;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 783ea3a1358f4960b7aafcc2c2778559
|
||||
timeCreated: 1597711347
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d273bf0a8d63e942948e47c85ba070e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents
|
||||
{
|
||||
public class HVRGripButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
public float Value;
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
Value = controller.Grip;
|
||||
|
||||
if (controller.GripButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.GripButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c773e81cb9c97548984b0405de96a04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRJoystickButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.JoystickButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.JoystickButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5790f4335c7cbd34393eac06ba1babd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRJoystickTouchEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.JoystickTouchState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.JoystickTouchState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d50c4b7a2526094084ef1f8c684d967
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRMenuButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.MenuButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.MenuButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d089d1719788c3d48b9bfa0f21332090
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRPrimaryButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.PrimaryButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.PrimaryButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b98dcb1ca8a3be4999be6c93fff5d07
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRPrimaryTouchButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.PrimaryTouchButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.PrimaryTouchButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7661c402b69812345ba71e28a39394df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRSecondaryButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.SecondaryButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.SecondaryButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4197bc7562b4ffa4b8c9385912f0ece0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRSecondaryTouchButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.SecondaryTouchButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.SecondaryTouchButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48fee757bfc3dad47bf38d83a2515334
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRThumbTouchEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.ThumbTouchState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.ThumbTouchState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c525ea7fd95c1c441bcab7267d3856c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTrackPadDownEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TrackPadDown.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TrackPadDown.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92fbfe59fc667134b857688c59aad6af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTrackPadLeftEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TrackPadLeft.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TrackPadLeft.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91ee1ae41e1621e4787c76059d4cfad9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTrackPadRightEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TrackPadRight.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TrackPadRight.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4480afa81378c6942ab2c57d49f852dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTrackPadTouchEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TrackPadTouchState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TrackPadTouchState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fe996b53b1d84d45942e667ad562962
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTrackPadUpEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TrackPadUp.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TrackPadUp.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b4041c0db61d9047a8598079e59f2b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTrackpadButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TrackpadButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TrackpadButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0df599ae5b2a5d3469594004cdcb41e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents
|
||||
{
|
||||
public class HVRTriggerButtonEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
public float Value;
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
Value = controller.Trigger;
|
||||
|
||||
if (controller.TriggerButtonState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TriggerButtonState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 531cb4b539136df43aebce206f6a260a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine.Events;
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputEvents{
|
||||
public class HVRTriggerTouchEvents : HVRInputAction
|
||||
{
|
||||
public UnityEvent Activated = new UnityEvent();
|
||||
public UnityEvent Deactivated = new UnityEvent();
|
||||
|
||||
protected override void CheckInput(HVRController controller)
|
||||
{
|
||||
if (controller.TriggerTouchState.JustActivated)
|
||||
{
|
||||
Activated.Invoke();
|
||||
}
|
||||
else if (controller.TriggerTouchState.JustDeactivated)
|
||||
{
|
||||
Deactivated.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6212f3feb19a46247bc9c73a6dbd06f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cccc3f9d7eb63f479ae790f372455da
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 871a8b45229d1d54f8d54e3b327e8bb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66fb30876468dda489c60824a458326c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath: Assets/HurricaneVR/Framework/Scripts/ControllerInput/InputSystem/HVRInputActions.cs
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
@@ -0,0 +1,364 @@
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using Assets.HurricaneVR.Framework.Shared.Utilities;
|
||||
using HurricaneVR.Framework.Shared;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.LowLevel;
|
||||
|
||||
|
||||
namespace HurricaneVR.Framework.ControllerInput.InputSystem
|
||||
{
|
||||
public class HVRTrackedPoseDriver : MonoBehaviour
|
||||
{
|
||||
public HVRHandSide Side;
|
||||
|
||||
/// <summary>
|
||||
/// Options for which <see cref="Transform"/> properties to update.
|
||||
/// </summary>
|
||||
/// <seealso cref="trackingType"/>
|
||||
public enum TrackingType
|
||||
{
|
||||
/// <summary>
|
||||
/// Update both rotation and position.
|
||||
/// </summary>
|
||||
RotationAndPosition,
|
||||
|
||||
/// <summary>
|
||||
/// Update rotation only.
|
||||
/// </summary>
|
||||
RotationOnly,
|
||||
|
||||
/// <summary>
|
||||
/// Update position only.
|
||||
/// </summary>
|
||||
PositionOnly,
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
TrackingType m_TrackingType;
|
||||
/// <summary>
|
||||
/// The tracking type being used by the Tracked Pose Driver
|
||||
/// to control which <see cref="Transform"/> properties to update.
|
||||
/// </summary>
|
||||
/// <seealso cref="TrackingType"/>
|
||||
public TrackingType trackingType
|
||||
{
|
||||
get => m_TrackingType;
|
||||
set => m_TrackingType = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options for which phases of the player loop will update <see cref="Transform"/> properties.
|
||||
/// </summary>
|
||||
/// <seealso cref="updateType"/>
|
||||
public enum UpdateType
|
||||
{
|
||||
/// <summary>
|
||||
/// Update after the Input System has completed an update and right before rendering.
|
||||
/// </summary>
|
||||
/// <seealso cref="InputUpdateType.Dynamic"/>
|
||||
/// <seealso cref="InputUpdateType.BeforeRender"/>
|
||||
UpdateAndBeforeRender,
|
||||
|
||||
/// <summary>
|
||||
/// Update after the Input System has completed an update.
|
||||
/// </summary>
|
||||
/// <seealso cref="InputUpdateType.Dynamic"/>
|
||||
Update,
|
||||
|
||||
/// <summary>
|
||||
/// Update right before rendering.
|
||||
/// </summary>
|
||||
/// <seealso cref="InputUpdateType.BeforeRender"/>
|
||||
BeforeRender,
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
UpdateType m_UpdateType = UpdateType.UpdateAndBeforeRender;
|
||||
/// <summary>
|
||||
/// The update type being used by the Tracked Pose Driver
|
||||
/// to control which phases of the player loop will update <see cref="Transform"/> properties.
|
||||
/// </summary>
|
||||
/// <seealso cref="UpdateType"/>
|
||||
public UpdateType updateType
|
||||
{
|
||||
get => m_UpdateType;
|
||||
set => m_UpdateType = value;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
InputActionProperty m_PositionInput;
|
||||
/// <summary>
|
||||
/// The action to read the position value of a tracked device.
|
||||
/// Must support reading a value of type <see cref="Vector3"/>.
|
||||
/// </summary>
|
||||
public InputActionProperty positionInput
|
||||
{
|
||||
get => m_PositionInput;
|
||||
set
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
UnbindPosition();
|
||||
|
||||
m_PositionInput = value;
|
||||
|
||||
if (Application.isPlaying && isActiveAndEnabled)
|
||||
BindPosition();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
InputActionProperty m_RotationInput;
|
||||
/// <summary>
|
||||
/// The action to read the rotation value of a tracked device.
|
||||
/// Must support reading a value of type <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
public InputActionProperty rotationInput
|
||||
{
|
||||
get => m_RotationInput;
|
||||
set
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
UnbindRotation();
|
||||
|
||||
m_RotationInput = value;
|
||||
|
||||
if (Application.isPlaying && isActiveAndEnabled)
|
||||
BindRotation();
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 m_CurrentPosition = Vector3.zero;
|
||||
Quaternion m_CurrentRotation = Quaternion.identity;
|
||||
bool m_RotationBound;
|
||||
bool m_PositionBound;
|
||||
|
||||
void BindActions()
|
||||
{
|
||||
BindPosition();
|
||||
BindRotation();
|
||||
}
|
||||
|
||||
void BindPosition()
|
||||
{
|
||||
if (m_PositionBound)
|
||||
return;
|
||||
|
||||
var action = m_PositionInput.action;
|
||||
if (action == null || action.bindings.Count == 0)
|
||||
{
|
||||
if (Side == HVRHandSide.Left)
|
||||
action = HVRInputSystemController.InputActions.LeftHand.ControllerPosition;
|
||||
else
|
||||
action = HVRInputSystemController.InputActions.RightHand.ControllerPosition;
|
||||
}
|
||||
|
||||
if (!action.enabled)
|
||||
action.Enable();
|
||||
|
||||
action.performed += OnPositionPerformed;
|
||||
action.canceled += OnPositionCanceled;
|
||||
m_PositionBound = true;
|
||||
_positionAction = action;
|
||||
}
|
||||
|
||||
void BindRotation()
|
||||
{
|
||||
if (m_RotationBound)
|
||||
return;
|
||||
|
||||
var action = m_RotationInput.action;
|
||||
if (action == null || action.bindings.Count == 0)
|
||||
{
|
||||
if (Side == HVRHandSide.Left)
|
||||
action = HVRInputSystemController.InputActions.LeftHand.ControllerRotation;
|
||||
else
|
||||
action = HVRInputSystemController.InputActions.RightHand.ControllerRotation;
|
||||
}
|
||||
|
||||
if (!action.enabled)
|
||||
action.Enable();
|
||||
|
||||
action.performed += OnRotationPerformed;
|
||||
action.canceled += OnRotationCanceled;
|
||||
m_RotationBound = true;
|
||||
_rotationAction = action;
|
||||
}
|
||||
|
||||
private InputAction _positionAction;
|
||||
private InputAction _rotationAction;
|
||||
|
||||
|
||||
|
||||
void UnbindActions()
|
||||
{
|
||||
UnbindPosition();
|
||||
UnbindRotation();
|
||||
}
|
||||
|
||||
void UnbindPosition()
|
||||
{
|
||||
if (!m_PositionBound)
|
||||
return;
|
||||
|
||||
var action = _positionAction;
|
||||
if (action == null)
|
||||
return;
|
||||
|
||||
if (m_PositionInput.action.bindings.Count > 0 && m_PositionInput.reference == null)
|
||||
action.Disable();
|
||||
|
||||
action.performed -= OnPositionPerformed;
|
||||
action.canceled -= OnPositionCanceled;
|
||||
m_PositionBound = false;
|
||||
_positionAction = null;
|
||||
}
|
||||
|
||||
void UnbindRotation()
|
||||
{
|
||||
if (!m_RotationBound)
|
||||
return;
|
||||
|
||||
var action = _rotationAction;
|
||||
if (action == null)
|
||||
return;
|
||||
|
||||
if (m_RotationInput.action.bindings.Count > 0 && m_RotationInput.reference == null)
|
||||
action.Disable();
|
||||
|
||||
action.performed -= OnRotationPerformed;
|
||||
action.canceled -= OnRotationCanceled;
|
||||
m_RotationBound = false;
|
||||
_rotationAction = null;
|
||||
}
|
||||
|
||||
void OnPositionPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
Debug.Assert(m_PositionBound, this);
|
||||
m_CurrentPosition = context.ReadValue<Vector3>();
|
||||
}
|
||||
|
||||
void OnPositionCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
Debug.Assert(m_PositionBound, this);
|
||||
m_CurrentPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
void OnRotationPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
Debug.Assert(m_RotationBound, this);
|
||||
m_CurrentRotation = context.ReadValue<Quaternion>();
|
||||
}
|
||||
|
||||
void OnRotationCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
Debug.Assert(m_RotationBound, this);
|
||||
m_CurrentRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the script instance is being loaded.
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if UNITY_INPUT_SYSTEM_ENABLE_VR && ENABLE_VR
|
||||
if (HasStereoCamera())
|
||||
{
|
||||
UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(GetComponent<Camera>(), true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected void OnEnable()
|
||||
{
|
||||
if (HVRInputManager.Instance.IsOpenXR)
|
||||
{
|
||||
UnityEngine.InputSystem.InputSystem.onAfterUpdate += UpdateCallback;
|
||||
HVRInputSystemController.Init();
|
||||
this.ExecuteNextUpdate(BindActions);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes disabled or inactive.
|
||||
/// </summary>
|
||||
protected void OnDisable()
|
||||
{
|
||||
if (HVRInputManager.Instance.IsOpenXR)
|
||||
{
|
||||
UnbindActions();
|
||||
UnityEngine.InputSystem.InputSystem.onAfterUpdate -= UpdateCallback;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the <see cref="MonoBehaviour"/> will be destroyed.
|
||||
/// </summary>
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
#if UNITY_INPUT_SYSTEM_ENABLE_VR && ENABLE_VR
|
||||
if (HasStereoCamera())
|
||||
{
|
||||
UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(GetComponent<Camera>(), false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
protected void UpdateCallback()
|
||||
{
|
||||
if (InputState.currentUpdateType == InputUpdateType.BeforeRender)
|
||||
OnBeforeRender();
|
||||
else
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
protected virtual void OnUpdate()
|
||||
{
|
||||
if (m_UpdateType == UpdateType.Update ||
|
||||
m_UpdateType == UpdateType.UpdateAndBeforeRender)
|
||||
{
|
||||
PerformUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnBeforeRender()
|
||||
{
|
||||
if (m_UpdateType == UpdateType.BeforeRender ||
|
||||
m_UpdateType == UpdateType.UpdateAndBeforeRender)
|
||||
{
|
||||
PerformUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRotation)
|
||||
{
|
||||
if (m_TrackingType == TrackingType.RotationAndPosition ||
|
||||
m_TrackingType == TrackingType.RotationOnly)
|
||||
{
|
||||
transform.localRotation = newRotation;
|
||||
}
|
||||
|
||||
if (m_TrackingType == TrackingType.RotationAndPosition ||
|
||||
m_TrackingType == TrackingType.PositionOnly)
|
||||
{
|
||||
transform.localPosition = newPosition;
|
||||
}
|
||||
}
|
||||
|
||||
bool HasStereoCamera()
|
||||
{
|
||||
var cameraComponent = GetComponent<Camera>();
|
||||
return cameraComponent != null && cameraComponent.stereoEnabled;
|
||||
}
|
||||
|
||||
protected virtual void PerformUpdate()
|
||||
{
|
||||
SetLocalTransform(m_CurrentPosition, m_CurrentRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 590ae77d131f4448894cbe1df6373c2b
|
||||
timeCreated: 1635272558
|
||||
Reference in New Issue
Block a user