Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Resolves issue with WMR grip (#312)
Browse files Browse the repository at this point in the history
Also updates axis data from Unity input to use raw data for precision
  • Loading branch information
SimonDarksideJ authored and StephenHodgson committed Sep 9, 2019
1 parent 5da0051 commit 710feae
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions Providers/Controllers/UnityInput/GenericJoystickController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ protected void UpdateButtonData(MixedRealityInteractionMapping interactionMappin
switch (interactionMapping.InputType)
{
case DeviceInputType.TriggerPress:
interactionMapping.BoolData = Input.GetAxis(interactionMapping.AxisCodeX).Equals(1);
interactionMapping.BoolData = Input.GetAxisRaw(interactionMapping.AxisCodeX).Equals(1);
break;
case DeviceInputType.TriggerNearTouch:
case DeviceInputType.ThumbNearTouch:
case DeviceInputType.IndexFingerNearTouch:
case DeviceInputType.MiddleFingerNearTouch:
case DeviceInputType.RingFingerNearTouch:
case DeviceInputType.PinkyFingerNearTouch:
interactionMapping.BoolData = !Input.GetAxis(interactionMapping.AxisCodeX).Equals(0);
interactionMapping.BoolData = !Input.GetAxisRaw(interactionMapping.AxisCodeX).Equals(0);
break;
default:
interactionMapping.BoolData = Input.GetKey(interactionMapping.KeyCode);
Expand All @@ -107,7 +107,7 @@ protected void UpdateButtonData(MixedRealityInteractionMapping interactionMappin
// If our value changed raise it.
if (interactionMapping.Changed)
{
// Raise input system Event if it enabled
// Raise input system Event if it is enabled
if (interactionMapping.BoolData)
{
MixedRealityToolkit.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
Expand Down Expand Up @@ -136,22 +136,38 @@ protected void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMa
{
Debug.Assert(interactionMapping.AxisType == AxisType.SingleAxis);

var singleAxisValue = Input.GetAxis(interactionMapping.AxisCodeX);
var singleAxisValue = Input.GetAxisRaw(interactionMapping.AxisCodeX);

// Update the interaction data source
interactionMapping.FloatData = singleAxisValue;

// If our value was updated, raise it.
if (interactionMapping.Updated)
if (interactionMapping.InputType == DeviceInputType.TriggerPress)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
}
// Update the interaction data source
interactionMapping.BoolData = singleAxisValue.Equals(1);

// If our value was updated, raise it.
if (interactionMapping.Updated)
// If our value changed raise it.
if (interactionMapping.Changed)
{
// Raise input system Event if it is enabled
if (interactionMapping.BoolData)
{
MixedRealityToolkit.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
}
else
{
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
}
}
}
else
{
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, singleAxisValue);
// Update the interaction data source
interactionMapping.FloatData = singleAxisValue;

// If our value was updated, raise it.
if (interactionMapping.Updated)
{
// Raise input system Event if it is enabled
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
}
}
}

Expand All @@ -172,7 +188,7 @@ protected void UpdateDualAxisData(MixedRealityInteractionMapping interactionMapp
// If our value was updated, raise it.
if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
// Raise input system Event if it is enabled
MixedRealityToolkit.InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.Vector2Data);
}
}
Expand Down Expand Up @@ -207,7 +223,7 @@ protected void UpdatePoseData(MixedRealityInteractionMapping interactionMapping)
// If our value was updated, raise it.
if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
// Raise input system Event if it is enabled
MixedRealityToolkit.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.PoseData);
}
}
Expand Down

0 comments on commit 710feae

Please sign in to comment.