mirror of
https://github.com/overte-org/overte.git
synced 2025-04-11 09:52:20 +02:00
better solution
This commit is contained in:
parent
7daad29906
commit
9a5f0dea95
1 changed files with 8 additions and 7 deletions
|
@ -280,13 +280,13 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu
|
|||
_inputDevice->update(deltaTime, inputCalibrationData);
|
||||
});
|
||||
|
||||
if (isDesktopMode() && _registeredWithInputMapper) {
|
||||
if (_inputDevice->_trackedControllers == 0 && _registeredWithInputMapper) {
|
||||
userInputMapper->removeDevice(_inputDevice->_deviceID);
|
||||
_registeredWithInputMapper = false;
|
||||
_inputDevice->_poseStateMap.clear();
|
||||
}
|
||||
|
||||
if (!_registeredWithInputMapper && !isDesktopMode()) {
|
||||
if (!_registeredWithInputMapper && _inputDevice->_trackedControllers > 0) {
|
||||
userInputMapper->registerDevice(_inputDevice);
|
||||
_registeredWithInputMapper = true;
|
||||
}
|
||||
|
@ -337,6 +337,7 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle
|
|||
_poseStateMap.clear();
|
||||
_buttonPressedMap.clear();
|
||||
_validTrackedObjects.clear();
|
||||
_trackedControllers = 0;
|
||||
|
||||
// While the keyboard is open, we defer strictly to the keyboard values
|
||||
if (isOpenVrKeyboardShown()) {
|
||||
|
@ -369,20 +370,19 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle
|
|||
}
|
||||
}
|
||||
|
||||
int numTrackedControllers = 0;
|
||||
if (leftHandDeviceIndex != vr::k_unTrackedDeviceIndexInvalid) {
|
||||
numTrackedControllers++;
|
||||
_trackedControllers++;
|
||||
}
|
||||
if (rightHandDeviceIndex != vr::k_unTrackedDeviceIndexInvalid) {
|
||||
numTrackedControllers++;
|
||||
_trackedControllers++;
|
||||
}
|
||||
_trackedControllers = numTrackedControllers;
|
||||
|
||||
calibrateFromHandController(inputCalibrationData);
|
||||
calibrateFromUI(inputCalibrationData);
|
||||
|
||||
updateCalibratedLimbs(inputCalibrationData);
|
||||
_lastSimPoseData = _nextSimPoseData;
|
||||
qDebug() << _trackedControllers;
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData) {
|
||||
|
@ -527,6 +527,7 @@ void ViveControllerManager::InputDevice::handleTrackedObject(uint32_t deviceInde
|
|||
|
||||
// but _validTrackedObjects remain in sensor frame
|
||||
_validTrackedObjects.push_back(std::make_pair(poseIndex, pose));
|
||||
_trackedControllers++;
|
||||
} else {
|
||||
controller::Pose invalidPose;
|
||||
_poseStateMap[poseIndex] = invalidPose;
|
||||
|
@ -758,9 +759,9 @@ void ViveControllerManager::InputDevice::handleHmd(uint32_t deviceIndex, const c
|
|||
} else {
|
||||
const mat4& mat = mat4();
|
||||
const vec3 zero = vec3();
|
||||
|
||||
handleHeadPoseEvent(inputCalibrationData, mat, zero, zero);
|
||||
}
|
||||
_trackedControllers++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue