Skip to content

Commit

Permalink
fix(Internal): emit tracked controller index change events
Browse files Browse the repository at this point in the history
There was an issue with the code that checks to see if a controller
index has changed which was preventing the index changed event
from being emitted.

This issue has now been fixed by ensuring the index is set to the
newly found index.

It's also not appropriate to only emit events when their index is
less than the `uint.MaxValue` because a controller event can still
be valid even if the index has become the max value.
  • Loading branch information
thestonefox committed Jun 30, 2017
1 parent 7490bea commit a740146
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Assets/VRTK/Scripts/Internal/VRTK_TrackedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ public class VRTK_TrackedController : MonoBehaviour

public virtual void OnControllerEnabled(VRTKTrackedControllerEventArgs e)
{
if (index < uint.MaxValue && ControllerEnabled != null)
if (ControllerEnabled != null)
{
ControllerEnabled(this, e);
}
}

public virtual void OnControllerDisabled(VRTKTrackedControllerEventArgs e)
{
if (index < uint.MaxValue && ControllerDisabled != null)
if (ControllerDisabled != null)
{
ControllerDisabled(this, e);
}
}

public virtual void OnControllerIndexChanged(VRTKTrackedControllerEventArgs e)
{
if (index < uint.MaxValue && ControllerIndexChanged != null)
if (ControllerIndexChanged != null)
{
ControllerIndexChanged(this, e);
}
Expand Down Expand Up @@ -87,9 +87,10 @@ protected virtual void FixedUpdate()
protected virtual void Update()
{
uint checkIndex = VRTK_DeviceFinder.GetControllerIndex(gameObject);
if (index < uint.MaxValue && checkIndex != index)
if (checkIndex != index)
{
uint previousIndex = index;
index = checkIndex;
OnControllerIndexChanged(SetEventPayload(previousIndex));
}

Expand Down

0 comments on commit a740146

Please sign in to comment.