moved controllers to input-plugins, they work now

This commit is contained in:
Sam Gondelman 2015-07-01 18:46:57 -07:00
parent e54060d6bb
commit 0333adb95b
4 changed files with 17 additions and 16 deletions

View file

@ -64,7 +64,6 @@
#include <DeferredLightingEffect.h> #include <DeferredLightingEffect.h>
#include <DependencyManager.h> #include <DependencyManager.h>
#include <display-plugins/DisplayPlugin.h> #include <display-plugins/DisplayPlugin.h>
#include <display-plugins/openvr/ViveControllerManager.h>
#include <EntityScriptingInterface.h> #include <EntityScriptingInterface.h>
#include <ErrorDialog.h> #include <ErrorDialog.h>
#include <GlowEffect.h> #include <GlowEffect.h>
@ -124,6 +123,7 @@
#include "devices/RealSense.h" #include "devices/RealSense.h"
#include "devices/SDL2Manager.h" #include "devices/SDL2Manager.h"
#include "devices/MIDIManager.h" #include "devices/MIDIManager.h"
#include <input-plugins/ViveControllerManager.h>
#include "RenderDeferredTask.h" #include "RenderDeferredTask.h"
#include "scripting/AccountScriptingInterface.h" #include "scripting/AccountScriptingInterface.h"
#include "scripting/AudioDeviceScriptingInterface.h" #include "scripting/AudioDeviceScriptingInterface.h"

View file

@ -29,10 +29,10 @@ const QString & OpenVrDisplayPlugin::getName() const {
return NAME; return NAME;
} }
static vr::IVRSystem *_hmd{ nullptr }; vr::IVRSystem *_hmd{ nullptr };
static vr::IVRCompositor* _compositor{ nullptr }; static vr::IVRCompositor* _compositor{ nullptr };
static vr::TrackedDevicePose_t _trackedDevicePose[vr::k_unMaxTrackedDeviceCount]; vr::TrackedDevicePose_t _trackedDevicePose[vr::k_unMaxTrackedDeviceCount];
static mat4 _trackedDevicePoseMat4[vr::k_unMaxTrackedDeviceCount]; mat4 _trackedDevicePoseMat4[vr::k_unMaxTrackedDeviceCount];
static uvec2 _windowSize; static uvec2 _windowSize;
static ivec2 _windowPosition; static ivec2 _windowPosition;
static uvec2 _renderTargetSize; static uvec2 _renderTargetSize;
@ -158,7 +158,9 @@ void OpenVrDisplayPlugin::finishFrame() {
// swapBuffers(); // swapBuffers();
doneCurrent(); doneCurrent();
_compositor->WaitGetPoses(_trackedDevicePose, vr::k_unMaxTrackedDeviceCount); _compositor->WaitGetPoses(_trackedDevicePose, vr::k_unMaxTrackedDeviceCount);
_trackedDevicePoseMat4[0] = toGlm(_trackedDevicePose[0].mDeviceToAbsoluteTracking); for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {
_trackedDevicePoseMat4[i] = toGlm(_trackedDevicePose[i].mDeviceToAbsoluteTracking);
}
openvr_for_each_eye([&](vr::Hmd_Eye eye) { openvr_for_each_eye([&](vr::Hmd_Eye eye) {
_eyesData[eye]._pose = _trackedDevicePoseMat4[0]; _eyesData[eye]._pose = _trackedDevicePoseMat4[0];
}); });

View file

@ -11,11 +11,10 @@
#include "ViveControllerManager.h" #include "ViveControllerManager.h"
#include <avatar/AvatarManager.h>
#include <PerfStat.h> #include <PerfStat.h>
#include "OpenVrDisplayPlugin.h" //#include <display-plugins\openvr\OpenVrDisplayPlugin.h>
#include "OpenVrHelpers.h" #include <display-plugins\openvr\OpenVrHelpers.h>
#include "UserActivityLogger.h" #include "UserActivityLogger.h"
extern vr::IVRSystem *_hmd; extern vr::IVRSystem *_hmd;
@ -74,14 +73,14 @@ void ViveControllerManager::update() {
} }
const mat4& mat = _trackedDevicePoseMat4[unTrackedDevice]; const mat4& mat = _trackedDevicePoseMat4[unTrackedDevice];
handlePoseEvent(mat, trackedControllerCount - 1); handlePoseEvent(mat, trackedControllerCount - 1);
// handle inputs // handle inputs
vr::VRControllerState_t* controllerState; //vr::VRControllerState_t* controllerState;
if(_hmd->GetControllerState(unTrackedDevice, controllerState)) { //if(_hmd->GetControllerState(unTrackedDevice, controllerState)) {
//
} //}
} }
@ -130,7 +129,7 @@ void ViveControllerManager::handleButtonEvent(unsigned int buttons, int index) {
void ViveControllerManager::handlePoseEvent(const mat4& mat, int index) { void ViveControllerManager::handlePoseEvent(const mat4& mat, int index) {
glm::vec3 position(mat[3][0], mat[3][1], mat[3][2]); glm::vec3 position(mat[3][0], mat[3][1], mat[3][2]);
glm::quat rotation = glm::quat_cast(mat); glm::quat rotation = glm::quat_cast(mat);
rotation = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f)) * rotation; //rotation = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f)) * rotation;
_poseStateMap[makeInput(JointChannel(index)).getChannel()] = UserInputMapper::PoseValue(position, rotation); _poseStateMap[makeInput(JointChannel(index)).getChannel()] = UserInputMapper::PoseValue(position, rotation);
} }
@ -141,7 +140,7 @@ void ViveControllerManager::registerToUserInputMapper(UserInputMapper& mapper) {
auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy("SteamVR Controller")); auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy("SteamVR Controller"));
proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); };
proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); };
proxy->getPose = [this] (const UserInputMapper::Input& input, int timestamp) -> UserInputMapper::PoseValue { return this->getPose(input.getChannel()); } proxy->getPose = [this](const UserInputMapper::Input& input, int timestamp) -> UserInputMapper::PoseValue { return this->getPose(input.getChannel()); };
proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> { proxy->getAvailabeInputs = [this] () -> QVector<UserInputMapper::InputPair> {
QVector<UserInputMapper::InputPair> availableInputs; QVector<UserInputMapper::InputPair> availableInputs;
// availableInputs.append(UserInputMapper::InputPair(makeInput(BUTTON_0, 0), "Left Start")); // availableInputs.append(UserInputMapper::InputPair(makeInput(BUTTON_0, 0), "Left Start"));

View file

@ -17,7 +17,7 @@
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <input-plugins/UserInputMapper.h> #include "UserInputMapper.h"
class ViveControllerManager : public QObject { class ViveControllerManager : public QObject {
Q_OBJECT Q_OBJECT