Skip to content

Commit 985df5b

Browse files
author
lawwong
committed
Update to v1.13.2
* 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)
2 parents 99d91dd + ae60aac commit 985df5b

File tree

14 files changed

+506
-126
lines changed

14 files changed

+506
-126
lines changed

Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModule.cs

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected override void UpdateNewConnectedInputDevice(IVRModuleDeviceStateRW sta
120120
updateFunc = UpdateWaveCRControllerState;
121121
break;
122122
default:
123-
updateFunc = null;
123+
updateFunc = UpdateUnknownControllerState;
124124
break;
125125
}
126126

@@ -176,6 +176,48 @@ private void UpdateControllerState(IVRModuleDeviceStateRW state, InputDevice dev
176176
}
177177
}
178178

179+
private void UpdateUnknownControllerState(IVRModuleDeviceStateRW state, InputDevice device)
180+
{
181+
bool primaryButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.primaryButton);
182+
bool primaryTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.primaryTouch);
183+
bool secondaryButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondaryButton);
184+
bool secondaryTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondaryTouch);
185+
bool gripButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.gripButton);
186+
bool triggerButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.triggerButton);
187+
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton);
188+
bool primary2DAxisClick = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxisClick);
189+
bool primary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxisTouch);
190+
bool secondary2DAxisClick = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxisClick);
191+
bool secondary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxisTouch);
192+
193+
float triggerValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.trigger);
194+
float gripValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.grip);
195+
196+
Vector2 primary2DAxisValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxis);
197+
Vector2 secondary2DAxisValue = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxis);
198+
199+
state.SetButtonPress(VRModuleRawButton.A, primaryButton);
200+
state.SetButtonPress(VRModuleRawButton.ApplicationMenu, secondaryButton | menuButton);
201+
state.SetButtonPress(VRModuleRawButton.Trigger, triggerButton);
202+
state.SetButtonPress(VRModuleRawButton.Grip, gripButton);
203+
state.SetButtonPress(VRModuleRawButton.Touchpad, primary2DAxisClick);
204+
state.SetButtonPress(VRModuleRawButton.Joystick, secondary2DAxisClick);
205+
206+
state.SetButtonTouch(VRModuleRawButton.A, primaryTouch);
207+
state.SetButtonTouch(VRModuleRawButton.ApplicationMenu, secondaryTouch | menuButton);
208+
state.SetButtonTouch(VRModuleRawButton.Trigger, triggerButton);
209+
state.SetButtonTouch(VRModuleRawButton.Grip, gripButton);
210+
state.SetButtonTouch(VRModuleRawButton.Touchpad, primary2DAxisTouch);
211+
state.SetButtonTouch(VRModuleRawButton.Joystick, secondary2DAxisTouch);
212+
213+
state.SetAxisValue(VRModuleRawAxis.Trigger, triggerValue);
214+
state.SetAxisValue(VRModuleRawAxis.CapSenseGrip, gripValue);
215+
state.SetAxisValue(VRModuleRawAxis.TouchpadX, primary2DAxisValue.x);
216+
state.SetAxisValue(VRModuleRawAxis.TouchpadY, primary2DAxisValue.y);
217+
state.SetAxisValue(VRModuleRawAxis.JoystickX, secondary2DAxisValue.x);
218+
state.SetAxisValue(VRModuleRawAxis.JoystickY, secondary2DAxisValue.y);
219+
}
220+
179221
private void UpdateViveControllerState(IVRModuleDeviceStateRW state, InputDevice device)
180222
{
181223
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton);
@@ -331,8 +373,8 @@ private void UpdateOculusControllerState(IVRModuleDeviceStateRW state, InputDevi
331373

332374
state.SetAxisValue(VRModuleRawAxis.Trigger, trigger);
333375
state.SetAxisValue(VRModuleRawAxis.CapSenseGrip, grip);
334-
state.SetAxisValue(VRModuleRawAxis.JoystickX, primary2DAxis.x);
335-
state.SetAxisValue(VRModuleRawAxis.JoystickY, primary2DAxis.y);
376+
state.SetAxisValue(VRModuleRawAxis.TouchpadX, primary2DAxis.x);
377+
state.SetAxisValue(VRModuleRawAxis.TouchpadY, primary2DAxis.y);
336378

337379
if (KnownActiveInputSubsystem == VRModuleKnownXRInputSubsystem.OpenVR)
338380
{
@@ -639,15 +681,15 @@ private void UpdateViveFocusFinchControllerState(IVRModuleDeviceStateRW state, I
639681
bool primary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxisTouch); // Touchpad
640682
bool secondary2DAxisClick = GetDeviceFeatureValueOrDefault(device, new InputFeatureUsage<bool>("Secondary2DAxisClick")); // No data
641683
bool secondary2DAxisTouch = GetDeviceFeatureValueOrDefault(device, new InputFeatureUsage<bool>("Secondary2DAxisTouch")); // No data
642-
bool gripButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.gripButton); // Trigger
684+
bool triggerButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.triggerButton);
643685
bool menuButton = GetDeviceFeatureValueOrDefault(device, CommonUsages.menuButton); // No Data
644686
float trigger = GetDeviceFeatureValueOrDefault(device, CommonUsages.trigger); // No Data
645687
Vector2 primary2DAxis = GetDeviceFeatureValueOrDefault(device, CommonUsages.primary2DAxis); // Touchpad
646688
Vector2 secondary2DAxis = GetDeviceFeatureValueOrDefault(device, CommonUsages.secondary2DAxis); // No data
647689
Vector2 dPad = GetDeviceFeatureValueOrDefault(device, new InputFeatureUsage<Vector2>("DPad")); // No Data
648690

649691
state.SetButtonPress(VRModuleRawButton.Touchpad, primary2DAxisClick);
650-
state.SetButtonPress(VRModuleRawButton.Trigger, gripButton);
692+
state.SetButtonPress(VRModuleRawButton.Trigger, triggerButton);
651693
state.SetButtonPress(VRModuleRawButton.ApplicationMenu, menuButton);
652694
state.SetButtonPress(VRModuleRawButton.DPadUp, dPad.y > 0);
653695
state.SetButtonPress(VRModuleRawButton.DPadDown, dPad.y < 0);

Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModuleBase.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,13 @@ public sealed override void BeforeRenderUpdate()
226226
submodules.UpdateModulesDeviceConnectionAndPoses();
227227

228228
// process hand role
229-
var currentRight = uxrRightIndex != INVALID_DEVICE_INDEX ? uxrRightIndex : submodules.GetFirstRightHandedIndex();
230-
var currentLeft = uxrLeftIndex != INVALID_DEVICE_INDEX ? uxrLeftIndex : submodules.GetFirstLeftHandedIndex();
229+
var subRightIndex = submodules.GetFirstRightHandedIndex();
230+
var currentRight = (subRightIndex == INVALID_DEVICE_INDEX || (TryGetValidDeviceState(uxrRightIndex, out prevState, out currState) && currState.isPoseValid)) ? uxrRightIndex : subRightIndex;
231+
var subLeftIndex = submodules.GetFirstLeftHandedIndex();
232+
var currentLeft = (subLeftIndex == INVALID_DEVICE_INDEX || (TryGetValidDeviceState(uxrLeftIndex, out prevState, out currState) && currState.isPoseValid)) ? uxrLeftIndex : subLeftIndex;
231233
var roleChanged = ChangeProp.Set(ref moduleRightIndex, currentRight);
232234
roleChanged |= ChangeProp.Set(ref moduleLeftIndex, currentLeft);
235+
233236
if (roleChanged)
234237
{
235238
InvokeControllerRoleChangedEvent();

Assets/HTC.UnityPlugin/VRModule/Modules/WaveVRModule.cs

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,23 @@ public override void UpdateRenderModel()
7979
{
8080
UpdateDefaultRenderModel(false);
8181

82-
m_modelObj = new GameObject("Model");
83-
m_modelObj.SetActive(false);
84-
m_modelObj.transform.SetParent(hook.transform, false);
82+
if (m_modelObj == null)
83+
{
84+
m_modelObj = new GameObject("Model");
85+
m_modelObj.transform.SetParent(hook.transform, false);
86+
m_modelObj.SetActive(false);
8587
#if VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL
8688
#if VIU_WAVE_XRSDK_3_99_31_OR_NEWER
87-
m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
89+
m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
8890
#endif
89-
m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
90-
m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
91+
m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
92+
m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
9193
#elif VIU_WAVEXR_ESSENCE_RENDERMODEL
92-
m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
93-
m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
94+
m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
95+
m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
9496
#endif
97+
}
98+
9599
m_modelObj.SetActive(true);
96100
}
97101
}
@@ -112,24 +116,28 @@ public override void UpdateRenderModel()
112116
{
113117
UpdateDefaultRenderModel(false);
114118

115-
m_modelObj = new GameObject("Model");
116-
m_modelObj.SetActive(false);
117-
m_modelObj.transform.SetParent(hook.transform, false);
119+
if (m_modelObj == null)
120+
{
121+
m_modelObj = new GameObject("Model");
122+
m_modelObj.transform.SetParent(hook.transform, false);
123+
m_modelObj.SetActive(false);
118124
#if VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL
119125
#if VIU_WAVE_XRSDK_3_99_31_OR_NEWER
120-
var pm = m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
121-
pm.WhichHand = XR_Hand.NonDominant;
126+
var pm = m_modelObj.transform.parent.gameObject.AddComponent<PoseMode>();
127+
pm.WhichHand = XR_Hand.NonDominant;
122128
#endif
123-
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
124-
rm.WhichHand = XR_Hand.NonDominant;
125-
var be = m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
126-
be.HandType = XR_Hand.NonDominant;
129+
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.Model.RenderModel>();
130+
rm.WhichHand = XR_Hand.NonDominant;
131+
var be = m_modelObj.AddComponent<Wave.Essence.Controller.Model.ButtonEffect>();
132+
be.HandType = XR_Hand.NonDominant;
127133
#elif VIU_WAVEXR_ESSENCE_RENDERMODEL
128-
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
129-
rm.WhichHand = XR_Hand.NonDominant;
130-
var be = m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
131-
be.HandType = XR_Hand.NonDominant;
134+
var rm = m_modelObj.AddComponent<Wave.Essence.Controller.RenderModel>();
135+
rm.WhichHand = XR_Hand.NonDominant;
136+
var be = m_modelObj.AddComponent<Wave.Essence.Controller.ButtonEffect>();
137+
be.HandType = XR_Hand.NonDominant;
132138
#endif
139+
}
140+
133141
m_modelObj.SetActive(true);
134142
}
135143
}
@@ -437,14 +445,18 @@ public override void OnActivated()
437445
WaveVR_ButtonList.EControllerButtons.Grip,
438446
WaveVR_ButtonList.EControllerButtons.Menu,
439447
WaveVR_ButtonList.EControllerButtons.Touchpad,
440-
WaveVR_ButtonList.EControllerButtons.Trigger
448+
WaveVR_ButtonList.EControllerButtons.Trigger,
449+
WaveVR_ButtonList.EControllerButtons.A_X,
450+
WaveVR_ButtonList.EControllerButtons.B_Y
441451
};
442452
buttonList.NonDominantButtons = new List<WaveVR_ButtonList.EControllerButtons>()
443453
{
444454
WaveVR_ButtonList.EControllerButtons.Grip,
445455
WaveVR_ButtonList.EControllerButtons.Menu,
446456
WaveVR_ButtonList.EControllerButtons.Touchpad,
447-
WaveVR_ButtonList.EControllerButtons.Trigger
457+
WaveVR_ButtonList.EControllerButtons.Trigger,
458+
WaveVR_ButtonList.EControllerButtons.A_X,
459+
WaveVR_ButtonList.EControllerButtons.B_Y
448460
};
449461
}
450462
}
@@ -584,6 +596,9 @@ private void UpdateDeviceInput(uint deviceIndex, WaveVR_Controller.Device device
584596
var dpadUpPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Up);
585597
var dpadRightPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Right);
586598
var dpadDownPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Down);
599+
var buttonAPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_A);
600+
var buttonBPressed = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_B);
601+
587602
currState.SetButtonPress(VRModuleRawButton.System, systemPressed);
588603
currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, menuPressed);
589604
currState.SetButtonPress(VRModuleRawButton.Touchpad, touchpadPressed || dpadLeftPressed || dpadUpPressed || dpadRightPressed || dpadDownPressed);
@@ -593,6 +608,8 @@ private void UpdateDeviceInput(uint deviceIndex, WaveVR_Controller.Device device
593608
currState.SetButtonPress(VRModuleRawButton.DPadUp, dpadUpPressed);
594609
currState.SetButtonPress(VRModuleRawButton.DPadRight, dpadRightPressed);
595610
currState.SetButtonPress(VRModuleRawButton.DPadDown, dpadDownPressed);
611+
currState.SetButtonPress(VRModuleRawButton.A, buttonAPressed);
612+
currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, buttonBPressed);
596613

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

617634
var triggerAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Trigger);
618635
var touchAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Touchpad);
636+
var gripAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Grip);
637+
619638
currState.SetAxisValue(VRModuleRawAxis.Trigger, triggerAxis.x);
639+
currState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, gripAxis.x);
620640
currState.SetAxisValue(VRModuleRawAxis.TouchpadX, touchAxis.x);
621641
currState.SetAxisValue(VRModuleRawAxis.TouchpadY, touchAxis.y);
622642
}

Assets/HTC.UnityPlugin/VRModule/Submodules/Editor/ViveHandTrackingSubmoduleEditor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ public ViveHandTrackingRequirementCollection()
1515
reqTypeNames = new string[] { "ViveHandTracking.GestureInterface", "ViveHandTracking.GestureOption" },
1616
reqFileNames = new string[] { "aristo_interface.dll", "GestureInterface.cs" },
1717
});
18+
19+
Add(new SymbolRequirement()
20+
{
21+
symbol = "VIU_VIVE_HAND_TRACKING_0_10_0_OR_NEWER",
22+
reqFileNames = new string[] { "GestureResultExtension.cs" },
23+
});
24+
1825
}
1926
}
2027
}

0 commit comments

Comments
 (0)