diff --git a/Controllers/LuminController.cs b/Controllers/LuminController.cs
index 2edfe65..4b4cd18 100644
--- a/Controllers/LuminController.cs
+++ b/Controllers/LuminController.cs
@@ -32,6 +32,7 @@ public LuminController(TrackingState trackingState, Handedness controllerHandedn
new MixedRealityInteractionMapping(5, "Home Press", AxisType.Digital, DeviceInputType.ButtonPress, MixedRealityInputAction.None),
new MixedRealityInteractionMapping(6, "Touchpad Position", AxisType.DualAxis, DeviceInputType.Touchpad, MixedRealityInputAction.None),
new MixedRealityInteractionMapping(7, "Touchpad Press", AxisType.SingleAxis, DeviceInputType.TouchpadPress, MixedRealityInputAction.None),
+ new MixedRealityInteractionMapping(8, "Touchpad Touch", AxisType.SingleAxis, DeviceInputType.TouchpadTouch, MixedRealityInputAction.None),
};
///
@@ -50,6 +51,8 @@ public override void SetupDefaultInteractions(Handedness controllerHandedness)
internal MLInputController MlControllerReference { get; set; }
//internal LuminControllerGestureSettings ControllerGestureSettings { get; set; }
+ internal bool IsHomePressed;
+
private MixedRealityPose currentPointerPose = MixedRealityPose.ZeroIdentity;
private MixedRealityPose lastControllerPose = MixedRealityPose.ZeroIdentity;
private MixedRealityPose currentControllerPose = MixedRealityPose.ZeroIdentity;
@@ -166,12 +169,18 @@ private void UpdateButtonData(MixedRealityInteractionMapping interactionMapping)
{
Debug.Assert(interactionMapping.AxisType == AxisType.Digital);
- var buttonId = interactionMapping.Description.Contains("Home")
- ? (int)MLInputControllerButton.HomeTap
- : (int)MLInputControllerButton.Bumper;
+ var isHomeButton = interactionMapping.Description.Contains("Home");
// Update the interaction data source
- interactionMapping.BoolData = MlControllerReference.State.ButtonState[buttonId] == 1;
+ if (!isHomeButton)
+ {
+ interactionMapping.BoolData = MlControllerReference.State.ButtonState[(int)MLInputControllerButton.Bumper] > 0;
+ }
+ else
+ {
+ interactionMapping.BoolData = IsHomePressed;
+ IsHomePressed = false;
+ }
// If our value changed raise it.
if (interactionMapping.Changed)
@@ -186,12 +195,11 @@ private void UpdateButtonData(MixedRealityInteractionMapping interactionMapping)
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
}
}
- else
+
+
+ if (interactionMapping.Updated)
{
- if (interactionMapping.BoolData)
- {
- MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
- }
+ MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
}
}
@@ -207,21 +215,22 @@ private void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapp
{
case DeviceInputType.Select:
case DeviceInputType.TriggerPress:
+ case DeviceInputType.TouchpadPress:
// Update the interaction data source
- interactionMapping.BoolData = singleAxisValue.Equals(1);
+ interactionMapping.BoolData = singleAxisValue.Equals(1f);
break;
case DeviceInputType.TriggerTouch:
+ case DeviceInputType.TouchpadTouch:
case DeviceInputType.TriggerNearTouch:
// Update the interaction data source
- interactionMapping.BoolData = !singleAxisValue.Equals(0);
+ interactionMapping.BoolData = !singleAxisValue.Equals(0f);
break;
case DeviceInputType.Trigger:
- case DeviceInputType.TouchpadPress:
// Update the interaction data source
interactionMapping.FloatData = singleAxisValue;
// If our value changed raise it.
- if (interactionMapping.Changed)
+ if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
@@ -245,12 +254,10 @@ private void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapp
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
}
}
- else
+
+ if (interactionMapping.Updated)
{
- if (interactionMapping.BoolData)
- {
- MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, singleAxisValue);
- }
+ MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, singleAxisValue);
}
}
@@ -265,7 +272,7 @@ private void UpdateDualAxisData(MixedRealityInteractionMapping interactionMappin
interactionMapping.Vector2Data = dualAxisPosition;
// If our value changed raise it.
- if (interactionMapping.Changed)
+ if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.Vector2Data);
@@ -291,7 +298,7 @@ private void UpdatePoseData(MixedRealityInteractionMapping interactionMapping)
interactionMapping.PoseData = currentPointerPose;
// If our value changed raise it.
- if (interactionMapping.Changed)
+ if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.PoseData);
diff --git a/Controllers/LuminControllerDataProvider.cs b/Controllers/LuminControllerDataProvider.cs
index 0452c2d..f73d958 100644
--- a/Controllers/LuminControllerDataProvider.cs
+++ b/Controllers/LuminControllerDataProvider.cs
@@ -25,7 +25,7 @@ public class LuminControllerDataProvider : BaseControllerDataProvider
///
///
///
- public LuminControllerDataProvider(string name, uint priority, BaseMixedRealityControllerDataProviderProfile profile)
+ public LuminControllerDataProvider(string name, uint priority, BaseMixedRealityControllerDataProviderProfile profile)
: base(name, priority, profile)
{
}
@@ -42,9 +42,9 @@ public override IMixedRealityController[] GetActiveControllers()
{
var list = new List();
- foreach (LuminController value in activeControllers.Values)
+ foreach (var controller in activeControllers.Values)
{
- list.Add(value);
+ list.Add(controller);
}
return list.ToArray();
@@ -91,6 +91,7 @@ public override void Enable()
MLInput.OnControllerConnected += OnControllerConnected;
MLInput.OnControllerDisconnected += OnControllerDisconnected;
+ MLInput.OnControllerButtonDown += MlInputOnControllerButtonDown;
}
///
@@ -100,8 +101,6 @@ public override void Update()
{
controller.Value?.UpdateController();
}
-
- // TODO Update hand gestures
}
///
@@ -109,6 +108,7 @@ public override void Disable()
{
MLInput.OnControllerConnected -= OnControllerConnected;
MLInput.OnControllerDisconnected -= OnControllerDisconnected;
+ MLInput.OnControllerButtonDown -= MlInputOnControllerButtonDown;
MLInput.Stop();
MLHands.Stop();
@@ -188,9 +188,8 @@ private void OnControllerConnected(byte controllerId)
if (controller != null)
{
MixedRealityToolkit.InputSystem?.RaiseSourceDetected(controller.InputSource, controller);
+ controller.UpdateController();
}
-
- controller?.UpdateController();
}
private void OnControllerDisconnected(byte controllerId)
@@ -205,6 +204,19 @@ private void OnControllerDisconnected(byte controllerId)
activeControllers.Remove(controllerId);
}
+ private void MlInputOnControllerButtonDown(byte controllerId, MLInputControllerButton button)
+ {
+ if (activeControllers.TryGetValue(controllerId, out var controller))
+ {
+ switch (button)
+ {
+ case MLInputControllerButton.HomeTap:
+ controller.IsHomePressed = true;
+ break;
+ }
+ }
+ }
+
#endregion Controller Events
#endif // PLATFORM_LUMIN