mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 10:59:55 +02:00
Fix Oculus Touch + Remote not being detected after initial launch
This commit is contained in:
parent
a231b57472
commit
56c5f06365
2 changed files with 19 additions and 6 deletions
|
@ -20,6 +20,8 @@
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
|
#include <OVR_CAPI.h>
|
||||||
|
|
||||||
#include "OculusHelpers.h"
|
#include "OculusHelpers.h"
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(oculus)
|
Q_DECLARE_LOGGING_CATEGORY(oculus)
|
||||||
|
@ -42,26 +44,33 @@ bool OculusControllerManager::activate() {
|
||||||
}
|
}
|
||||||
Q_ASSERT(_session);
|
Q_ASSERT(_session);
|
||||||
|
|
||||||
// register with UserInputMapper
|
checkForConnectedDevices();
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OculusControllerManager::checkForConnectedDevices() {
|
||||||
|
if (_touch && _remote) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int controllerConnected = ovr_GetConnectedControllerTypes(_session);
|
unsigned int controllerConnected = ovr_GetConnectedControllerTypes(_session);
|
||||||
|
|
||||||
if ((controllerConnected & ovrControllerType_Remote) == ovrControllerType_Remote) {
|
if (!_remote && (controllerConnected & ovrControllerType_Remote) == ovrControllerType_Remote) {
|
||||||
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Remote, &_inputState))) {
|
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Remote, &_inputState))) {
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
_remote = std::make_shared<RemoteDevice>(*this);
|
_remote = std::make_shared<RemoteDevice>(*this);
|
||||||
userInputMapper->registerDevice(_remote);
|
userInputMapper->registerDevice(_remote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((controllerConnected & ovrControllerType_Touch) != 0) {
|
if (!_touch && (controllerConnected & ovrControllerType_Touch) != 0) {
|
||||||
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) {
|
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) {
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
_touch = std::make_shared<TouchDevice>(*this);
|
_touch = std::make_shared<TouchDevice>(*this);
|
||||||
userInputMapper->registerDevice(_touch);
|
userInputMapper->registerDevice(_touch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusControllerManager::deactivate() {
|
void OculusControllerManager::deactivate() {
|
||||||
|
@ -85,6 +94,8 @@ void OculusControllerManager::deactivate() {
|
||||||
void OculusControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void OculusControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
PerformanceTimer perfTimer("OculusControllerManager::TouchDevice::update");
|
PerformanceTimer perfTimer("OculusControllerManager::TouchDevice::update");
|
||||||
|
|
||||||
|
checkForConnectedDevices();
|
||||||
|
|
||||||
if (_touch) {
|
if (_touch) {
|
||||||
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) {
|
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) {
|
||||||
_touch->update(deltaTime, inputCalibrationData);
|
_touch->update(deltaTime, inputCalibrationData);
|
||||||
|
|
|
@ -91,6 +91,8 @@ private:
|
||||||
friend class OculusControllerManager;
|
friend class OculusControllerManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void checkForConnectedDevices();
|
||||||
|
|
||||||
ovrSession _session { nullptr };
|
ovrSession _session { nullptr };
|
||||||
ovrInputState _inputState {};
|
ovrInputState _inputState {};
|
||||||
RemoteDevice::Pointer _remote;
|
RemoteDevice::Pointer _remote;
|
||||||
|
|
Loading…
Reference in a new issue