Skip to content

Commit

Permalink
Fix left/right ctrl model not appear correctly on simulator
Browse files Browse the repository at this point in the history
SimulatorModule returns left/right index even when the device isn't created
this causes HandRole does't trigger device changed then causes
RenderModelHook doesn't refresh models

also add connected check when mapping left/right device in
HandRole.cs to prevent mapping a disconnected device. Suppose this only
effects SimulatorModule since currently all other modules only return
connected left/right index
  • Loading branch information
lawwong committed Jun 5, 2023
1 parent 05d9209 commit 87340ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Assets/HTC.UnityPlugin/VRModule/Modules/SimulatorModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public override void OnDeactivated()
}
}

public override uint GetRightControllerDeviceIndex() { return RIGHT_INDEX; }
public override uint GetRightControllerDeviceIndex() { return m_currStates != null && m_currStates[RIGHT_INDEX].isConnected ? RIGHT_INDEX : VRModule.INVALID_DEVICE_INDEX; }

public override uint GetLeftControllerDeviceIndex() { return LEFT_INDEX; }
public override uint GetLeftControllerDeviceIndex() { return m_currStates != null && m_currStates[LEFT_INDEX].isConnected ? LEFT_INDEX : VRModule.INVALID_DEVICE_INDEX; }

public override void Update()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ private void MappingLeftRightHands()
else
{
rightIndex = VRModule.GetRightControllerDeviceIndex();
if (rightIndex >= deviceCount || RoleMap.IsDeviceConnectedAndBound(rightIndex))
var rightIndexState = VRModule.GetCurrentDeviceState(rightIndex);
if (!rightIndexState.isConnected || RoleMap.IsDeviceBound(rightIndexState.serialNumber))
{
rightIndex = VRModule.INVALID_DEVICE_INDEX;
}
Expand All @@ -159,7 +160,8 @@ private void MappingLeftRightHands()
else
{
leftIndex = VRModule.GetLeftControllerDeviceIndex();
if (leftIndex >= deviceCount || RoleMap.IsDeviceConnectedAndBound(leftIndex))
var leftIndexState = VRModule.GetCurrentDeviceState(leftIndex);
if (!leftIndexState.isConnected || RoleMap.IsDeviceBound(leftIndexState.serialNumber))
{
leftIndex = VRModule.INVALID_DEVICE_INDEX;
}
Expand All @@ -172,7 +174,7 @@ private void MappingLeftRightHands()
{
if (i == rightIndex || i == leftIndex) { continue; }
var state = VRModule.GetCurrentDeviceState(i);
if (state.deviceClass != VRModuleDeviceClass.Controller) { continue; }
if (!state.isConnected || state.deviceClass != VRModuleDeviceClass.Controller) { continue; }
if (RoleMap.IsDeviceBound(state.serialNumber)) { continue; }
m_sortedDeviceList.Add(i);
}
Expand Down

0 comments on commit 87340ea

Please sign in to comment.