Skip to content

Commit

Permalink
Update to v1.13.2
Browse files Browse the repository at this point in the history
* New Features
  - Add support for Wave 4.1
  - Add support for Vive Hand Tracking 0.10

* Changes
  - Now Grabbable able to be stretch around using 2 grabbers
    - Requires enabling "multiple grabbers" option
    - Able to scale if min/maxScaleOnStretch set to proper values (min < max)
  - Optimize process creating Wave Render Model

* Bug Fixes
  - Fix Grip axis returns joystick value on Oculus controller (Unity XR only)
  - Fix ControllerRole doesn't map left hand device correctly
  - Fix unable to get Grip/A/B/X/Y button values on Wave controllers (Wave 3.2 only)
  • Loading branch information
lawwong committed Jun 25, 2021
2 parents 99d91dd + ae60aac commit 985df5b
Show file tree
Hide file tree
Showing 14 changed files with 506 additions and 126 deletions.
52 changes: 47 additions & 5 deletions Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected override void UpdateNewConnectedInputDevice(IVRModuleDeviceStateRW sta
updateFunc = UpdateWaveCRControllerState;
break;
default:
updateFunc = null;
updateFunc = UpdateUnknownControllerState;
break;
}

Expand Down Expand Up @@ -176,6 +176,48 @@ private void UpdateControllerState(IVRModuleDeviceStateRW state, InputDevice dev
}
}

private void UpdateUnknownControllerState(IVRModuleDeviceStateRW state, InputDevice device)
{
bool primaryButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.primaryButton);
bool primaryTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.primaryTouch);
bool secondaryButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondaryButton);
bool secondaryTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondaryTouch);
bool gripButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.gripButton);
bool triggerButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.triggerButton);
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton);
bool primary2DAxisClick = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxisClick);
bool primary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxisTouch);
bool secondary2DAxisClick = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxisClick);
bool secondary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxisTouch);

float triggerValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.trigger);
float gripValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.grip);

Vector2 primary2DAxisValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxis);
Vector2 secondary2DAxisValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxis);

state.SetButtonPress(VRModuleRawButton.A, primaryButton);
state.SetButtonPress(VRModuleRawButton.ApplicationMenu, secondaryButton | menuButton);
state.SetButtonPress(VRModuleRawButton.Trigger, triggerButton);
state.SetButtonPress(VRModuleRawButton.Grip, gripButton);
state.SetButtonPress(VRModuleRawButton.Touchpad, primary2DAxisClick);
state.SetButtonPress(VRModuleRawButton.Joystick, secondary2DAxisClick);

state.SetButtonTouch(VRModuleRawButton.A, primaryTouch);
state.SetButtonTouch(VRModuleRawButton.ApplicationMenu, secondaryTouch | menuButton);
state.SetButtonTouch(VRModuleRawButton.Trigger, triggerButton);
state.SetButtonTouch(VRModuleRawButton.Grip, gripButton);
state.SetButtonTouch(VRModuleRawButton.Touchpad, primary2DAxisTouch);
state.SetButtonTouch(VRModuleRawButton.Joystick, secondary2DAxisTouch);

state.SetAxisValue(VRModuleRawAxis.Trigger, triggerValue);
state.SetAxisValue(VRModuleRawAxis.CapSenseGrip, gripValue);
state.SetAxisValue(VRModuleRawAxis.TouchpadX, primary2DAxisValue.x);
state.SetAxisValue(VRModuleRawAxis.TouchpadY, primary2DAxisValue.y);
state.SetAxisValue(VRModuleRawAxis.JoystickX, secondary2DAxisValue.x);
state.SetAxisValue(VRModuleRawAxis.JoystickY, secondary2DAxisValue.y);
}

private void UpdateViveControllerState(IVRModuleDeviceStateRW state, InputDevice device)
{
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton);
Expand Down Expand Up @@ -331,8 +373,8 @@ private void UpdateOculusControllerState(IVRModuleDeviceStateRW state, InputDevi

state.SetAxisValue(VRModuleRawAxis.Trigger, trigger);
state.SetAxisValue(VRModuleRawAxis.CapSenseGrip, grip);
state.SetAxisValue(VRModuleRawAxis.JoystickX, primary2DAxis.x);
state.SetAxisValue(VRModuleRawAxis.JoystickY, primary2DAxis.y);
state.SetAxisValue(VRModuleRawAxis.TouchpadX, primary2DAxis.x);
state.SetAxisValue(VRModuleRawAxis.TouchpadY, primary2DAxis.y);

if (KnownActiveInputSubsystem == VRModuleKnownXRInputSubsystem.OpenVR)
{
Expand Down Expand Up @@ -639,15 +681,15 @@ private void UpdateViveFocusFinchControllerState(IVRModuleDeviceStateRW state, I
bool primary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxisTouch); // Touchpad
bool secondary2DAxisClick = GetDeviceFeatureValueOrDefault(device, new InputFeatureUsage<bool>("Secondary2DAxisClick")); // No data
bool secondary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, new InputFeatureUsage<bool>("Secondary2DAxisTouch")); // No data
bool gripButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.gripButton); // Trigger
bool triggerButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.triggerButton);
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton); // No Data
float trigger = GetDeviceFeatureValueOrDefault(device, CommonUsages.trigger); // No Data
Vector2 primary2DAxis = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxis); // Touchpad
Vector2 secondary2DAxis = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxis); // No data
Vector2 dPad = GetDeviceFeatureValueOrDefault(device, new InputFeatureUsage<Vector2>("DPad")); // No Data

state.SetButtonPress(VRModuleRawButton.Touchpad, primary2DAxisClick);
state.SetButtonPress(VRModuleRawButton.Trigger, gripButton);
state.SetButtonPress(VRModuleRawButton.Trigger, triggerButton);
state.SetButtonPress(VRModuleRawButton.ApplicationMenu, menuButton);
state.SetButtonPress(VRModuleRawButton.DPadUp, dPad.y > 0);
state.SetButtonPress(VRModuleRawButton.DPadDown, dPad.y < 0);
Expand Down
7 changes: 5 additions & 2 deletions Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ public sealed override void BeforeRenderUpdate()
submodules.UpdateModulesDeviceConnectionAndPoses();

// process hand role
var currentRight = uxrRightIndex != INVALID_DEVICE_INDEX ? uxrRightIndex : submodules.GetFirstRightHandedIndex();
var currentLeft = uxrLeftIndex != INVALID_DEVICE_INDEX ? uxrLeftIndex : submodules.GetFirstLeftHandedIndex();
var subRightIndex = submodules.GetFirstRightHandedIndex();
var currentRight = (subRightIndex == INVALID_DEVICE_INDEX || (TryGetValidDeviceState(uxrRightIndex, out prevState, out currState) && currState.isPoseValid)) ? uxrRightIndex : subRightIndex;
var subLeftIndex = submodules.GetFirstLeftHandedIndex();
var currentLeft = (subLeftIndex == INVALID_DEVICE_INDEX || (TryGetValidDeviceState(uxrLeftIndex, out prevState, out currState) && currState.isPoseValid)) ? uxrLeftIndex : subLeftIndex;
var roleChanged = ChangeProp.Set(ref moduleRightIndex, currentRight);
roleChanged |= ChangeProp.Set(ref moduleLeftIndex, currentLeft);

if (roleChanged)
{
InvokeControllerRoleChangedEvent();
Expand Down
66 changes: 43 additions & 23 deletions Assets/HTC.UnityPlugin/VRModule/Modules/WaveVRModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,23 @@ public override void UpdateRenderModel()
{
UpdateDefaultRenderModel(false);

m_modelObj = new GameObject("Model");
m_modelObj.SetActive(false);
m_modelObj.transform.SetParent(hook.transform, false);
if (m_modelObj == null)
{
m_modelObj = new GameObject("Model");
m_modelObj.transform.SetParent(hook.transform, false);
m_modelObj.SetActive(false);
#if VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL
#if VIU_WAVE_XRSDK_3_99_31_OR_NEWER
m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
#endif
m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
#elif VIU_WAVEXR_ESSENCE_RENDERMODEL
m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
#endif
}

m_modelObj.SetActive(true);
}
}
Expand All @@ -112,24 +116,28 @@ public override void UpdateRenderModel()
{
UpdateDefaultRenderModel(false);

m_modelObj = new GameObject("Model");
m_modelObj.SetActive(false);
m_modelObj.transform.SetParent(hook.transform, false);
if (m_modelObj == null)
{
m_modelObj = new GameObject("Model");
m_modelObj.transform.SetParent(hook.transform, false);
m_modelObj.SetActive(false);
#if VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL
#if VIU_WAVE_XRSDK_3_99_31_OR_NEWER
var pm = m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
pm.WhichHand = XR_Hand.NonDominant;
var pm = m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
pm.WhichHand = XR_Hand.NonDominant;
#endif
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
rm.WhichHand = XR_Hand.NonDominant;
var be = m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
be.HandType = XR_Hand.NonDominant;
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
rm.WhichHand = XR_Hand.NonDominant;
var be = m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
be.HandType = XR_Hand.NonDominant;
#elif VIU_WAVEXR_ESSENCE_RENDERMODEL
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
rm.WhichHand = XR_Hand.NonDominant;
var be = m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
be.HandType = XR_Hand.NonDominant;
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
rm.WhichHand = XR_Hand.NonDominant;
var be = m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
be.HandType = XR_Hand.NonDominant;
#endif
}

m_modelObj.SetActive(true);
}
}
Expand Down Expand Up @@ -437,14 +445,18 @@ public override void OnActivated()
WaveVR_ButtonList.EControllerButtons.Grip,
WaveVR_ButtonList.EControllerButtons.Menu,
WaveVR_ButtonList.EControllerButtons.Touchpad,
WaveVR_ButtonList.EControllerButtons.Trigger
WaveVR_ButtonList.EControllerButtons.Trigger,
WaveVR_ButtonList.EControllerButtons.A_X,
WaveVR_ButtonList.EControllerButtons.B_Y
};
buttonList.NonDominantButtons = new List<WaveVR_ButtonList.EControllerButtons>()
{
WaveVR_ButtonList.EControllerButtons.Grip,
WaveVR_ButtonList.EControllerButtons.Menu,
WaveVR_ButtonList.EControllerButtons.Touchpad,
WaveVR_ButtonList.EControllerButtons.Trigger
WaveVR_ButtonList.EControllerButtons.Trigger,
WaveVR_ButtonList.EControllerButtons.A_X,
WaveVR_ButtonList.EControllerButtons.B_Y
};
}
}
Expand Down Expand Up @@ -584,6 +596,9 @@ private void UpdateDeviceInput(uint deviceIndex, WaveVR_Controller.Device device
var dpadUpPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Up);
var dpadRightPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Right);
var dpadDownPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Down);
var buttonAPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_A);
var buttonBPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_B);

currState.SetButtonPress(VRModuleRawButton.System, systemPressed);
currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, menuPressed);
currState.SetButtonPress(VRModuleRawButton.Touchpad, touchpadPressed || dpadLeftPressed || dpadUpPressed || dpadRightPressed || dpadDownPressed);
Expand All @@ -593,6 +608,8 @@ private void UpdateDeviceInput(uint deviceIndex, WaveVR_Controller.Device device
currState.SetButtonPress(VRModuleRawButton.DPadUp, dpadUpPressed);
currState.SetButtonPress(VRModuleRawButton.DPadRight, dpadRightPressed);
currState.SetButtonPress(VRModuleRawButton.DPadDown, dpadDownPressed);
currState.SetButtonPress(VRModuleRawButton.A, buttonAPressed);
currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, buttonBPressed);

var systemTouched = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_System);
var menuTouched = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_Menu);
Expand All @@ -616,7 +633,10 @@ private void UpdateDeviceInput(uint deviceIndex, WaveVR_Controller.Device device

var triggerAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Trigger);
var touchAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Touchpad);
var gripAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Grip);

currState.SetAxisValue(VRModuleRawAxis.Trigger, triggerAxis.x);
currState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, gripAxis.x);
currState.SetAxisValue(VRModuleRawAxis.TouchpadX, touchAxis.x);
currState.SetAxisValue(VRModuleRawAxis.TouchpadY, touchAxis.y);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public ViveHandTrackingRequirementCollection()
reqTypeNames = new string[] { "ViveHandTracking.GestureInterface", "ViveHandTracking.GestureOption" },
reqFileNames = new string[] { "aristo_interface.dll", "GestureInterface.cs" },
});

Add(new SymbolRequirement()
{
symbol = "VIU_VIVE_HAND_TRACKING_0_10_0_OR_NEWER",
reqFileNames = new string[] { "GestureResultExtension.cs" },
});

}
}
}
Loading

0 comments on commit 985df5b

Please sign in to comment.