void Update()
{
if (_trackedObject.index == SteamVR_TrackedObject.EIndex.None)
{
// No device
// TODO: Cancel events that were in progress?
return;
}
SteamVR_Controller.Device device = SteamVR_Controller.Input((int)_trackedObject.index);
triggerPosition = device.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger).x;
// Trigger
bool hairTriggerBegan = device.GetHairTriggerDown();
bool hairTriggerActive = device.GetHairTrigger();
bool hairTriggerEnded = device.GetHairTriggerUp();
if (hairTriggerBegan)
{
DelegateFireTriggerBegan();
}
if (hairTriggerActive)
{
DelegateFireTriggerActive();
}
if (hairTriggerEnded)
{
DelegateFireTriggerEnded();
}
// Grip
bool gripBegan = device.GetPressDown(EVRButtonId.k_EButton_Grip);
bool gripActive = device.GetPress(EVRButtonId.k_EButton_Grip);
bool gripEnded = device.GetPressUp(EVRButtonId.k_EButton_Grip);
if (gripBegan)
{
DelegateFireGripBegan();
}
if (gripActive)
{
DelegateFireGripActive();
}
if (gripEnded)
{
DelegateFireGripEnded();
}
}