mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 09:42:11 +02:00
Support oculus remote input
This commit is contained in:
parent
50a081db00
commit
a58a627fdf
4 changed files with 98 additions and 15 deletions
14
interface/resources/controllers/oculus_remote.json
Normal file
14
interface/resources/controllers/oculus_remote.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "Oculus Remote to Standard",
|
||||
"channels": [
|
||||
{ "from": "OculusRemote.Back", "to": "Standard.Back" },
|
||||
{ "from": "OculusRemote.Start", "to": "Standard.Start" },
|
||||
|
||||
{ "from": "OculusRemote.DU", "to": "Standard.DU" },
|
||||
{ "from": "OculusRemote.DD", "to": "Standard.DD" },
|
||||
{ "from": "OculusRemote.DL", "to": "Standard.DL" },
|
||||
{ "from": "OculusRemote.DR", "to": "Standard.DR" }
|
||||
]
|
||||
}
|
||||
|
||||
|
23
interface/resources/controllers/oculus_touch.json
Normal file
23
interface/resources/controllers/oculus_touch.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "Oculus Touch to Standard",
|
||||
"channels": [
|
||||
{ "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" },
|
||||
{ "from": "OculusTouch.LX", "to": "Standard.LX" },
|
||||
{ "from": "OculusTouch.LT", "to": "Standard.LT" },
|
||||
|
||||
{ "from": "OculusTouch.RY", "filters": "invert", "to": "Standard.RY" },
|
||||
{ "from": "OculusTouch.RX", "to": "Standard.RX" },
|
||||
|
||||
{ "from": "OculusTouch.RT", "to": "Standard.RT" },
|
||||
{ "from": "OculusTouch.RB", "to": "Standard.RB" },
|
||||
{ "from": "OculusTouch.RS", "to": "Standard.RS" },
|
||||
|
||||
{ "from": "OculusTouch.LeftApplicationMenu", "to": "Standard.Back" },
|
||||
{ "from": "OculusTouch.RightApplicationMenu", "to": "Standard.Start" },
|
||||
|
||||
{ "from": "OculusTouch.LeftHand", "to": "Standard.LeftHand" },
|
||||
{ "from": "OculusTouch.RightHand", "to": "Standard.RightHand" }
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -44,12 +44,14 @@ bool OculusControllerManager::activate() {
|
|||
|
||||
// register with UserInputMapper
|
||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||
if (_remote) {
|
||||
userInputMapper->registerDevice(_remote);
|
||||
}
|
||||
if (_touch) {
|
||||
userInputMapper->registerDevice(_touch);
|
||||
}
|
||||
_remote = std::make_shared<RemoteDevice>(*this);
|
||||
userInputMapper->registerDevice(_remote);
|
||||
|
||||
#if 0
|
||||
_touch = std::make_shared<TouchDevice>();
|
||||
userInputMapper->registerDevice(_touch);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -74,16 +76,21 @@ void OculusControllerManager::deactivate() {
|
|||
void OculusControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData, bool jointsCaptured) {
|
||||
PerformanceTimer perfTimer("OculusControllerManager::TouchDevice::update");
|
||||
|
||||
if (!OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) {
|
||||
qCWarning(oculus) << "Unable to read oculus input state";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_touch) {
|
||||
_touch->update(deltaTime, inputCalibrationData, jointsCaptured);
|
||||
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) {
|
||||
_touch->update(deltaTime, inputCalibrationData, jointsCaptured);
|
||||
} else {
|
||||
qCWarning(oculus) << "Unable to read Oculus touch input state";
|
||||
}
|
||||
}
|
||||
|
||||
if (_remote) {
|
||||
_remote->update(deltaTime, inputCalibrationData, jointsCaptured);
|
||||
if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Remote, &_inputState))) {
|
||||
_remote->update(deltaTime, inputCalibrationData, jointsCaptured);
|
||||
} else {
|
||||
qCWarning(oculus) << "Unable to read Oculus remote input state";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,6 +106,12 @@ void OculusControllerManager::pluginFocusOutEvent() {
|
|||
using namespace controller;
|
||||
|
||||
static const std::vector<std::pair<ovrButton, StandardButtonChannel>> BUTTON_MAP { {
|
||||
{ ovrButton_Up, DU },
|
||||
{ ovrButton_Down, DD },
|
||||
{ ovrButton_Left, DL },
|
||||
{ ovrButton_Right, DR },
|
||||
{ ovrButton_Enter, START },
|
||||
{ ovrButton_Back, BACK },
|
||||
{ ovrButton_X, X },
|
||||
{ ovrButton_Y, Y },
|
||||
{ ovrButton_A, A },
|
||||
|
@ -124,6 +137,39 @@ static const std::vector<std::pair<ovrTouch, StandardButtonChannel>> TOUCH_MAP {
|
|||
{ ovrTouch_RIndexPointing, RIGHT_INDEX_POINT },
|
||||
} };
|
||||
|
||||
|
||||
controller::Input::NamedVector OculusControllerManager::RemoteDevice::getAvailableInputs() const {
|
||||
using namespace controller;
|
||||
QVector<Input::NamedPair> availableInputs {
|
||||
makePair(DU, "Up"),
|
||||
makePair(DD, "Down"),
|
||||
makePair(DL, "Left"),
|
||||
makePair(DR, "Right"),
|
||||
makePair(START, "Start"),
|
||||
makePair(BACK, "Back"),
|
||||
};
|
||||
return availableInputs;
|
||||
}
|
||||
|
||||
QString OculusControllerManager::RemoteDevice::getDefaultMappingConfig() const {
|
||||
static const QString MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/oculus_remote.json";
|
||||
return MAPPING_JSON;
|
||||
}
|
||||
|
||||
void OculusControllerManager::RemoteDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData, bool jointsCaptured) {
|
||||
_buttonPressedMap.clear();
|
||||
const auto& inputState = _parent._inputState;
|
||||
for (const auto& pair : BUTTON_MAP) {
|
||||
if (inputState.Buttons & pair.first) {
|
||||
_buttonPressedMap.insert(pair.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OculusControllerManager::RemoteDevice::focusOutEvent() {
|
||||
_buttonPressedMap.clear();
|
||||
}
|
||||
|
||||
void OculusControllerManager::TouchDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData, bool jointsCaptured) {
|
||||
_poseStateMap.clear();
|
||||
_buttonPressedMap.clear();
|
||||
|
@ -211,7 +257,7 @@ controller::Input::NamedVector OculusControllerManager::TouchDevice::getAvailabl
|
|||
}
|
||||
|
||||
QString OculusControllerManager::TouchDevice::getDefaultMappingConfig() const {
|
||||
static const QString MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/touch.json";
|
||||
static const QString MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/oculus_touch.json";
|
||||
return MAPPING_JSON;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
class RemoteDevice : public OculusInputDevice {
|
||||
public:
|
||||
using Pointer = std::shared_ptr<RemoteDevice>;
|
||||
RemoteDevice(OculusControllerManager& parent) : OculusInputDevice(parent, "Oculus Remote") {}
|
||||
RemoteDevice(OculusControllerManager& parent) : OculusInputDevice(parent, "OculusRemote") {}
|
||||
|
||||
controller::Input::NamedVector getAvailableInputs() const override;
|
||||
QString getDefaultMappingConfig() const override;
|
||||
|
@ -58,7 +58,7 @@ private:
|
|||
class TouchDevice : public OculusInputDevice {
|
||||
public:
|
||||
using Pointer = std::shared_ptr<TouchDevice>;
|
||||
TouchDevice(OculusControllerManager& parent) : OculusInputDevice(parent, "Oculus Touch") {}
|
||||
TouchDevice(OculusControllerManager& parent) : OculusInputDevice(parent, "OculusTouch") {}
|
||||
|
||||
controller::Input::NamedVector getAvailableInputs() const override;
|
||||
QString getDefaultMappingConfig() const override;
|
||||
|
|
Loading…
Reference in a new issue