mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 18:23:57 +02:00
added Plugin interface to ViveControllerManager
mostly I just added this to add the isSupported method, so it wouldn't attempt to initialize if there was no HMD attached.
This commit is contained in:
parent
dcaa294778
commit
0f30da64bc
4 changed files with 68 additions and 6 deletions
|
@ -669,8 +669,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
ddeTracker->init();
|
ddeTracker->init();
|
||||||
connect(ddeTracker.data(), &FaceTracker::muteToggled, this, &Application::faceTrackerMuteToggled);
|
connect(ddeTracker.data(), &FaceTracker::muteToggled, this, &Application::faceTrackerMuteToggled);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ViveControllerManager::getInstance().activate();
|
ViveControllerManager::getInstance().init();
|
||||||
|
if (ViveControllerManager::getInstance().isSupported()) {
|
||||||
|
ViveControllerManager::getInstance().activate();
|
||||||
|
}
|
||||||
|
|
||||||
_oldHandMouseX[0] = -1;
|
_oldHandMouseX[0] = -1;
|
||||||
_oldHandMouseY[0] = -1;
|
_oldHandMouseY[0] = -1;
|
||||||
|
|
|
@ -481,6 +481,7 @@ void SixenseManager::handleButtonEvent(unsigned int buttons, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SixenseManager::handlePoseEvent(glm::vec3 position, glm::quat rotation, int index) {
|
void SixenseManager::handlePoseEvent(glm::vec3 position, glm::quat rotation, int index) {
|
||||||
|
#if HAS_SIXENSE
|
||||||
// Transform the measured position into body frame.
|
// Transform the measured position into body frame.
|
||||||
glm::vec3 neck = _neckBase;
|
glm::vec3 neck = _neckBase;
|
||||||
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
|
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
|
||||||
|
@ -538,6 +539,7 @@ void SixenseManager::handlePoseEvent(glm::vec3 position, glm::quat rotation, int
|
||||||
// palm->setTipPosition(newTipPosition);
|
// palm->setTipPosition(newTipPosition);
|
||||||
|
|
||||||
_poseStateMap[makeInput(JointChannel(index)).getChannel()] = UserInputMapper::PoseValue(position, rotation);
|
_poseStateMap[makeInput(JointChannel(index)).getChannel()] = UserInputMapper::PoseValue(position, rotation);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SixenseManager::registerToUserInputMapper(UserInputMapper& mapper) {
|
void SixenseManager::registerToUserInputMapper(UserInputMapper& mapper) {
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
Q_DECLARE_LOGGING_CATEGORY(inputplugins)
|
Q_DECLARE_LOGGING_CATEGORY(inputplugins)
|
||||||
Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins")
|
Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins")
|
||||||
|
|
||||||
|
const QString ViveControllerManager::NAME("OpenVR (Vive) Hand Controllers");
|
||||||
|
|
||||||
extern vr::IVRSystem *_hmd;
|
extern vr::IVRSystem *_hmd;
|
||||||
extern vr::TrackedDevicePose_t _trackedDevicePose[vr::k_unMaxTrackedDeviceCount];
|
extern vr::TrackedDevicePose_t _trackedDevicePose[vr::k_unMaxTrackedDeviceCount];
|
||||||
extern mat4 _trackedDevicePoseMat4[vr::k_unMaxTrackedDeviceCount];
|
extern mat4 _trackedDevicePoseMat4[vr::k_unMaxTrackedDeviceCount];
|
||||||
|
@ -55,6 +57,40 @@ ViveControllerManager::~ViveControllerManager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString& ViveControllerManager::getName() const {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViveControllerManager::isSupported() const {
|
||||||
|
return vr::VR_IsHmdPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViveControllerManager::init() {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViveControllerManager::deinit() {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViveControllerManager::activate(PluginContainer * container) {
|
||||||
|
activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called when a plugin is no longer being used. May be called multiple times.
|
||||||
|
void ViveControllerManager::deactivate() {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the application during it's idle phase. If the plugin needs to do
|
||||||
|
* CPU intensive work, it should launch a thread for that, rather than trying to
|
||||||
|
* do long operations in the idle call
|
||||||
|
*/
|
||||||
|
void ViveControllerManager::idle() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void ViveControllerManager::activate() {
|
void ViveControllerManager::activate() {
|
||||||
if (!_hmd) {
|
if (!_hmd) {
|
||||||
vr::HmdError eError = vr::HmdError_None;
|
vr::HmdError eError = vr::HmdError_None;
|
||||||
|
|
|
@ -18,11 +18,30 @@
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
|
|
||||||
#include "UserInputMapper.h"
|
#include "UserInputMapper.h"
|
||||||
|
#include "plugins/Plugin.h"
|
||||||
|
|
||||||
class ViveControllerManager : public QObject {
|
class ViveControllerManager : public Plugin {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual const QString& getName() const override;
|
||||||
|
virtual bool isSupported() const override;
|
||||||
|
|
||||||
|
/// Called when plugin is initially loaded, typically at application start
|
||||||
|
virtual void init() override;
|
||||||
|
/// Called when application is shutting down
|
||||||
|
virtual void deinit() override ;
|
||||||
|
|
||||||
|
/// Called when a plugin is being activated for use. May be called multiple times.
|
||||||
|
virtual void activate(PluginContainer * container) override;
|
||||||
|
/// Called when a plugin is no longer being used. May be called multiple times.
|
||||||
|
virtual void deactivate() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the application during it's idle phase. If the plugin needs to do
|
||||||
|
* CPU intensive work, it should launch a thread for that, rather than trying to
|
||||||
|
* do long operations in the idle call
|
||||||
|
*/
|
||||||
|
virtual void idle() override;
|
||||||
|
|
||||||
enum JoystickAxisChannel {
|
enum JoystickAxisChannel {
|
||||||
AXIS_Y_POS = 1U << 1,
|
AXIS_Y_POS = 1U << 1,
|
||||||
AXIS_Y_NEG = 1U << 2,
|
AXIS_Y_NEG = 1U << 2,
|
||||||
|
@ -78,7 +97,9 @@ private:
|
||||||
bool _isInitialized;
|
bool _isInitialized;
|
||||||
bool _isEnabled;
|
bool _isEnabled;
|
||||||
int _trackedControllers;
|
int _trackedControllers;
|
||||||
|
|
||||||
|
static const QString NAME;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _deviceID = 0;
|
int _deviceID = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue