Skip to content

Commit 677624f

Browse files
author
lawwong
committed
Now mix hmd name to recognize controller for Oculus devices only
1 parent 98e98ea commit 677624f

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ private struct XRInputSubsystemProfile
8282
private uint uxrLeftIndex = INVALID_DEVICE_INDEX;
8383
private uint moduleRightIndex = INVALID_DEVICE_INDEX;
8484
private uint moduleLeftIndex = INVALID_DEVICE_INDEX;
85-
private string hmdDeviceName = string.Empty;
8685
private VRModule.SubmoduleBase.Collection submodules = new VRModule.SubmoduleBase.Collection(
8786
new ViveHandTrackingSubmodule(),
8887
new WaveHandTrackingSubmodule(),
@@ -161,14 +160,13 @@ public sealed override void BeforeRenderUpdate()
161160
deviceIndex = VRModule.HMD_DEVICE_INDEX;
162161
EnsureValidDeviceState(deviceIndex, out prevState, out currState);
163162
deviceName = device.name;
164-
hmdDeviceName = deviceName + " - ";
165163
}
166164
else
167165
{
168166
// this function will skip VRModule.HMD_DEVICE_INDEX (preserved index for HMD)
169167
deviceIndex = FindAndEnsureUnusedNotHMDDeviceState(out prevState, out currState);
170168
indexMap.MapNonHMD(device, deviceIndex);
171-
deviceName = hmdDeviceName + device.name;
169+
deviceName = device.name;
172170
}
173171

174172
currState.deviceClass = GetDeviceClass(device.name, device.characteristics);

Assets/HTC.UnityPlugin/VRModule/VRModuleBase.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,32 +234,32 @@ protected static void SetupKnownDeviceModel(IVRModuleDeviceStateRW deviceState)
234234
return;
235235
case VRModuleDeviceClass.Controller:
236236
{
237-
var headName = GetDeviceState(HMD_DEVICE_INDEX).modelNumber;
238-
if (s_quest2Rgx.IsMatch(deviceState.modelNumber))
237+
var modelNumWithHmd = GetDeviceState(HMD_DEVICE_INDEX).modelNumber + " " + deviceState.modelNumber;
238+
if (s_quest2Rgx.IsMatch(modelNumWithHmd))
239239
{
240-
deviceState.deviceModel = s_leftRgx.IsMatch(deviceState.modelNumber) ? VRModuleDeviceModel.OculusQuest2ControllerLeft : VRModuleDeviceModel.OculusQuest2ControllerRight;
240+
deviceState.deviceModel = s_leftRgx.IsMatch(modelNumWithHmd) ? VRModuleDeviceModel.OculusQuest2ControllerLeft : VRModuleDeviceModel.OculusQuest2ControllerRight;
241241
deviceState.input2DType = VRModuleInput2DType.JoystickOnly;
242242
return;
243243
}
244-
else if (deviceState.modelNumber.Contains("Rift S") || deviceState.modelNumber.Contains("Quest"))
244+
else if (modelNumWithHmd.Contains("Rift S") || modelNumWithHmd.Contains("Quest"))
245245
{
246-
deviceState.deviceModel = s_leftRgx.IsMatch(deviceState.modelNumber) ? VRModuleDeviceModel.OculusQuestOrRiftSControllerLeft : VRModuleDeviceModel.OculusQuestOrRiftSControllerRight;
246+
deviceState.deviceModel = s_leftRgx.IsMatch(modelNumWithHmd) ? VRModuleDeviceModel.OculusQuestOrRiftSControllerLeft : VRModuleDeviceModel.OculusQuestOrRiftSControllerRight;
247247
deviceState.input2DType = VRModuleInput2DType.JoystickOnly;
248248
return;
249249
}
250-
else if (deviceState.modelNumber.Contains("Touch"))
250+
else if (modelNumWithHmd.Contains("Touch"))
251251
{
252-
deviceState.deviceModel = s_leftRgx.IsMatch(deviceState.modelNumber) ? VRModuleDeviceModel.OculusTouchLeft : VRModuleDeviceModel.OculusTouchRight;
252+
deviceState.deviceModel = s_leftRgx.IsMatch(modelNumWithHmd) ? VRModuleDeviceModel.OculusTouchLeft : VRModuleDeviceModel.OculusTouchRight;
253253
deviceState.input2DType = VRModuleInput2DType.JoystickOnly;
254254
return;
255255
}
256-
else if (deviceState.modelNumber.Contains("Go"))
256+
else if (modelNumWithHmd.Contains("Go"))
257257
{
258258
deviceState.deviceModel = VRModuleDeviceModel.OculusGoController;
259259
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;
260260
return;
261261
}
262-
else if (deviceState.modelNumber.Contains("Gear"))
262+
else if (modelNumWithHmd.Contains("Gear"))
263263
{
264264
deviceState.deviceModel = VRModuleDeviceModel.OculusGearVrController;
265265
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;

0 commit comments

Comments
 (0)