mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 06:02:07 +02:00
Fix touch controller button handling when Oculus remote is paired
This commit is contained in:
parent
74e5c4bf60
commit
197fb469eb
2 changed files with 8 additions and 7 deletions
|
@ -51,7 +51,7 @@ void OculusControllerManager::checkForConnectedDevices() {
|
||||||
unsigned int controllerConnected = ovr_GetConnectedControllerTypes(session);
|
unsigned int controllerConnected = ovr_GetConnectedControllerTypes(session);
|
||||||
|
|
||||||
if (!_remote && (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, &_remoteInputState))) {
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
_remote = std::make_shared<RemoteDevice>(*this);
|
_remote = std::make_shared<RemoteDevice>(*this);
|
||||||
userInputMapper->registerDevice(_remote);
|
userInputMapper->registerDevice(_remote);
|
||||||
|
@ -59,7 +59,7 @@ void OculusControllerManager::checkForConnectedDevices() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_touch && (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, &_touchInputState))) {
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
_touch = std::make_shared<TouchDevice>(*this);
|
_touch = std::make_shared<TouchDevice>(*this);
|
||||||
userInputMapper->registerDevice(_touch);
|
userInputMapper->registerDevice(_touch);
|
||||||
|
@ -90,13 +90,13 @@ void OculusControllerManager::pluginUpdate(float deltaTime, const controller::In
|
||||||
|
|
||||||
ovr::withSession([&](ovrSession session) {
|
ovr::withSession([&](ovrSession session) {
|
||||||
if (_touch) {
|
if (_touch) {
|
||||||
updateTouch = OVR_SUCCESS(ovr_GetInputState(session, ovrControllerType_Touch, &_inputState));
|
updateTouch = OVR_SUCCESS(ovr_GetInputState(session, ovrControllerType_Touch, &_touchInputState));
|
||||||
if (!updateTouch) {
|
if (!updateTouch) {
|
||||||
qCWarning(oculusLog) << "Unable to read Oculus touch input state" << ovr::getError();
|
qCWarning(oculusLog) << "Unable to read Oculus touch input state" << ovr::getError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_remote) {
|
if (_remote) {
|
||||||
updateRemote = OVR_SUCCESS(ovr_GetInputState(session, ovrControllerType_Remote, &_inputState));
|
updateRemote = OVR_SUCCESS(ovr_GetInputState(session, ovrControllerType_Remote, &_remoteInputState));
|
||||||
if (!updateRemote) {
|
if (!updateRemote) {
|
||||||
qCWarning(oculusLog) << "Unable to read Oculus remote input state" << ovr::getError();
|
qCWarning(oculusLog) << "Unable to read Oculus remote input state" << ovr::getError();
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ QString OculusControllerManager::RemoteDevice::getDefaultMappingConfig() const {
|
||||||
|
|
||||||
void OculusControllerManager::RemoteDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void OculusControllerManager::RemoteDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
_buttonPressedMap.clear();
|
_buttonPressedMap.clear();
|
||||||
const auto& inputState = _parent._inputState;
|
const auto& inputState = _parent._remoteInputState;
|
||||||
for (const auto& pair : BUTTON_MAP) {
|
for (const auto& pair : BUTTON_MAP) {
|
||||||
if (inputState.Buttons & pair.first) {
|
if (inputState.Buttons & pair.first) {
|
||||||
_buttonPressedMap.insert(pair.second);
|
_buttonPressedMap.insert(pair.second);
|
||||||
|
@ -257,7 +257,7 @@ void OculusControllerManager::TouchDevice::update(float deltaTime,
|
||||||
|
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
// Axes
|
// Axes
|
||||||
const auto& inputState = _parent._inputState;
|
const auto& inputState = _parent._touchInputState;
|
||||||
_axisStateMap[LX] = inputState.Thumbstick[ovrHand_Left].x;
|
_axisStateMap[LX] = inputState.Thumbstick[ovrHand_Left].x;
|
||||||
_axisStateMap[LY] = inputState.Thumbstick[ovrHand_Left].y;
|
_axisStateMap[LY] = inputState.Thumbstick[ovrHand_Left].y;
|
||||||
_axisStateMap[LT] = inputState.IndexTrigger[ovrHand_Left];
|
_axisStateMap[LT] = inputState.IndexTrigger[ovrHand_Left];
|
||||||
|
|
|
@ -103,7 +103,8 @@ private:
|
||||||
|
|
||||||
void checkForConnectedDevices();
|
void checkForConnectedDevices();
|
||||||
|
|
||||||
ovrInputState _inputState {};
|
ovrInputState _remoteInputState {};
|
||||||
|
ovrInputState _touchInputState {};
|
||||||
RemoteDevice::Pointer _remote;
|
RemoteDevice::Pointer _remote;
|
||||||
TouchDevice::Pointer _touch;
|
TouchDevice::Pointer _touch;
|
||||||
static const char* NAME;
|
static const char* NAME;
|
||||||
|
|
Loading…
Reference in a new issue