Skip to content

Commit 9d8d22f

Browse files
ChengNan Yanglawwong
authored andcommitted
Add VIVE Focus controller model name
* Update Finch and Chirp model name
1 parent 3ef02b1 commit 9d8d22f

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ private Transform FindWaveVRControllerActionsObjInChildren()
247247
private IVRModuleDeviceStateRW m_rightState;
248248
private IVRModuleDeviceStateRW m_leftState;
249249
private WaveVR_ControllerLoader.ControllerHand[] m_deviceHands = new WaveVR_ControllerLoader.ControllerHand[DEVICE_COUNT];
250+
private static Dictionary<string, VRModuleDeviceModel> m_models = new Dictionary<string, VRModuleDeviceModel>
251+
{
252+
{"WVR_CONTROLLER_FINCH3DOF_2_0", VRModuleDeviceModel.ViveFocusFinch},
253+
{"WVR_CONTROLLER_ASPEN_MI6_1", VRModuleDeviceModel.ViveFocusChirp}
254+
};
250255

251256
#region 6Dof Controller Simulation
252257

@@ -280,12 +285,6 @@ static WaveVRModule()
280285
s_type2class[(int)WVR_DeviceType.WVR_DeviceType_Controller_Right] = VRModuleDeviceClass.Controller;
281286
s_type2class[(int)WVR_DeviceType.WVR_DeviceType_Controller_Left] = VRModuleDeviceClass.Controller;
282287

283-
s_type2model = new VRModuleDeviceModel[s_type2index.Length];
284-
for (int i = 0; i < s_type2model.Length; ++i) { s_type2model[i] = VRModuleDeviceModel.Unknown; }
285-
s_type2model[(int)WVR_DeviceType.WVR_DeviceType_HMD] = VRModuleDeviceModel.ViveFocusHMD;
286-
s_type2model[(int)WVR_DeviceType.WVR_DeviceType_Controller_Right] = VRModuleDeviceModel.ViveFocusFinch;
287-
s_type2model[(int)WVR_DeviceType.WVR_DeviceType_Controller_Left] = VRModuleDeviceModel.ViveFocusFinch;
288-
289288
s_simulatedCtrlPosArray = new Vector3[s_type2index.Length];
290289
}
291290

@@ -544,7 +543,7 @@ private IVRModuleDeviceStateRW UpdateDevicePose(uint deviceIndex, WaveVR.Device
544543
{
545544
currState.isConnected = true;
546545
currState.deviceClass = s_type2class[(int)content.type];
547-
currState.deviceModel = s_type2model[(int)content.type];
546+
currState.deviceModel = QueryDeviceModel(s_type2class[(int)content.type]);
548547
currState.serialNumber = content.type.ToString();
549548
currState.modelNumber = content.type.ToString();
550549
currState.renderModelName = content.type.ToString();
@@ -799,6 +798,30 @@ public override void TriggerViveControllerHaptic(uint deviceIndex, ushort durati
799798
}
800799
}
801800

801+
private VRModuleDeviceModel QueryDeviceModel(VRModuleDeviceClass device)
802+
{
803+
if (device.Equals(VRModuleDeviceClass.HMD))
804+
{
805+
return VRModuleDeviceModel.ViveFocusHMD;
806+
}
807+
else if (device.Equals(VRModuleDeviceClass.Controller))
808+
{
809+
VRModuleDeviceModel model;
810+
if (m_models.TryGetValue(WaveVR_Utils.GetControllerName(WaveVR_Controller.EDeviceType.Dominant), out model))
811+
{
812+
return model;
813+
}
814+
else
815+
{
816+
return VRModuleDeviceModel.Unknown;
817+
}
818+
}
819+
else
820+
{
821+
return VRModuleDeviceModel.Unknown;
822+
}
823+
}
824+
802825
#if VIU_WAVEVR_3_1_0_OR_NEWER
803826
public override void TriggerHapticVibration(uint deviceIndex, float durationSeconds = 0.01f, float frequency = 85, float amplitude = 0.125f, float startSecondsFromNow = 0)
804827
{

Assets/HTC.UnityPlugin/VRModule/VRModuleBase.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,16 @@ protected static void SetupKnownDeviceModel(IVRModuleDeviceStateRW deviceState)
333333
deviceState.deviceModel = VRModuleDeviceModel.ViveFocusHMD;
334334
return;
335335
case VRModuleDeviceClass.Controller:
336-
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;
337-
deviceState.deviceModel = VRModuleDeviceModel.ViveFocusChirp;
336+
if (deviceState.renderModelName.Equals("WVR_CONTROLLER_FINCH3DOF_2_0"))
337+
{
338+
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;
339+
deviceState.deviceModel = VRModuleDeviceModel.ViveFocusFinch;
340+
}
341+
else if (deviceState.renderModelName.Equals("WVR_CONTROLLER_ASPEN_MI6_1"))
342+
{
343+
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;
344+
deviceState.deviceModel = VRModuleDeviceModel.ViveFocusChirp;
345+
}
338346
return;
339347
}
340348
}

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Misc/BasicGrabbable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BasicGrabbable : GrabbableBase<BasicGrabbable.Grabber>
1616
, IColliderEventDragFixedUpdateHandler
1717
, IColliderEventDragUpdateHandler
1818
, IColliderEventDragEndHandler
19-
, IColliderEventPressUpHandler
19+
, IColliderEventPressUpHandler
2020
{
2121
[Serializable]
2222
public class UnityEventGrabbable : UnityEvent<BasicGrabbable> { }

0 commit comments

Comments
 (0)