experimenting with input plugins

This commit is contained in:
Brad Davis 2015-06-30 09:52:54 -07:00
parent cdb6620703
commit e421141ec5
17 changed files with 173 additions and 68 deletions

60
cmake/externals/sixense/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,60 @@
include(ExternalProject)
include(SelectLibraryConfigurations)
set(EXTERNAL_NAME Sixense)
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
ExternalProject_Add(
${EXTERNAL_NAME}
URL ./SixenseSDK_062612.zip
URL_MD5 10cc8dc470d2ac1244a88cf04bc549cc
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
)
if (APPLE)
find_library(SIXENSE_LIBRARY_RELEASE lib/osx_x64/release_dll/libsixense_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS})
find_library(SIXENSE_LIBRARY_DEBUG lib/osx_x64/debug_dll/libsixensed_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS})
elseif (UNIX)
find_library(SIXENSE_LIBRARY_RELEASE lib/linux_x64/release/libsixense_x64.so HINTS ${SIXENSE_SEARCH_DIRS})
# find_library(SIXENSE_LIBRARY_DEBUG lib/linux_x64/debug/libsixensed_x64.so HINTS ${SIXENSE_SEARCH_DIRS})
elseif (WIN32)
endif ()
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE TYPE INTERNAL)
if (WIN32)
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(ARCH_DIR "x64")
set(ARCH_SUFFIX "_x64")
else()
set(ARCH_DIR "Win32")
set(ARCH_SUFFIX "")
endif()
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARIES "${SOURCE_DIR}/lib/${ARCH_DIR}/release_dll/sixense${ARCH_SUFFIX}.lib" CACHE TYPE INTERNAL)
add_paths_to_fixup_libs(${SOURCE_DIR}/bin/win32)
elseif(APPLE)
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/osx32/libopenvr_api.dylib CACHE TYPE INTERNAL)
add_paths_to_fixup_libs(${SOURCE_DIR}/bin/osx32)
elseif(NOT ANDROID)
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/linux32/libopenvr_api.so CACHE TYPE INTERNAL)
add_paths_to_fixup_libs(${SOURCE_DIR}/bin/linux32)
endif()

View file

@ -2,7 +2,7 @@ set(TARGET_NAME interface)
project(${TARGET_NAME})
# set a default root dir for each of our optional externals if it was not passed
set(OPTIONAL_EXTERNALS "Faceshift" "Sixense" "LeapMotion" "RtMidi" "SDL2" "RSSDK")
set(OPTIONAL_EXTERNALS "Faceshift" "LeapMotion" "RtMidi" "SDL2" "RSSDK")
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE)
if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR)
@ -128,7 +128,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
# link required hifi libraries
link_hifi_libraries(shared octree environment gpu model render fbx networking entities avatars
audio audio-client auto-updater animation script-engine physics
render-utils entities-renderer ui plugins display-plugins)
render-utils entities-renderer ui plugins display-plugins input-plugins)
add_dependency_external_projects(sdl2)

View file

@ -73,6 +73,7 @@
#include <gpu/GLBackend.h>
#include <HFActionEvent.h>
#include <HFBackEvent.h>
#include <input-plugins/sixense/SixenseManager.h>
#include <InfoView.h>
#include <LogHandler.h>
#include <MainWindow.h>
@ -98,6 +99,7 @@
#include <Tooltip.h>
#include <UserActivityLogger.h>
#include <UUID.h>
#include <input-plugins/UserInputMapper.h>
#include <VrMenu.h>
#include "Application.h"
@ -312,6 +314,7 @@ bool setupEssentials(int& argc, char** argv) {
auto autoUpdater = DependencyManager::set<AutoUpdater>();
auto pathUtils = DependencyManager::set<PathUtils>();
auto actionFactory = DependencyManager::set<InterfaceActionFactory>();
auto userInputMapper = DependencyManager::set<UserInputMapper>();
return true;
}
@ -607,9 +610,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
this, &Application::checkSkeleton, Qt::QueuedConnection);
// Setup the userInputMapper with the actions
auto userInputMapper = DependencyManager::get<UserInputMapper>();
connect(userInputMapper.data(), &UserInputMapper::actionEvent, &_controllerScriptingInterface, &AbstractControllerScriptingInterface::actionEvent);
// Setup the keyboardMouseDevice and the user input mapper with the default bindings
_keyboardMouseDevice.registerToUserInputMapper(_userInputMapper);
_keyboardMouseDevice.assignDefaultInputMapping(_userInputMapper);
_keyboardMouseDevice.registerToUserInputMapper(*userInputMapper);
_keyboardMouseDevice.assignDefaultInputMapping(*userInputMapper);
// check first run...
if (_firstRun.get()) {
@ -2505,7 +2511,8 @@ void Application::update(float deltaTime) {
SDL2Manager::getInstance()->update();
}
_userInputMapper.update(deltaTime);
auto userInputMapper = DependencyManager::get<UserInputMapper>();
userInputMapper->update(deltaTime);
_keyboardMouseDevice.update();
// Dispatch input events
@ -2515,19 +2522,19 @@ void Application::update(float deltaTime) {
_myAvatar->clearDriveKeys();
if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
if (!_controllerScriptingInterface.areActionsCaptured()) {
_myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD));
_myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD));
_myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP));
_myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN));
_myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT));
_myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT));
_myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP));
_myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN));
_myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT));
_myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT));
_myAvatar->setDriveKeys(FWD, userInputMapper->getActionState(UserInputMapper::LONGITUDINAL_FORWARD));
_myAvatar->setDriveKeys(BACK, userInputMapper->getActionState(UserInputMapper::LONGITUDINAL_BACKWARD));
_myAvatar->setDriveKeys(UP, userInputMapper->getActionState(UserInputMapper::VERTICAL_UP));
_myAvatar->setDriveKeys(DOWN, userInputMapper->getActionState(UserInputMapper::VERTICAL_DOWN));
_myAvatar->setDriveKeys(LEFT, userInputMapper->getActionState(UserInputMapper::LATERAL_LEFT));
_myAvatar->setDriveKeys(RIGHT, userInputMapper->getActionState(UserInputMapper::LATERAL_RIGHT));
_myAvatar->setDriveKeys(ROT_UP, userInputMapper->getActionState(UserInputMapper::PITCH_UP));
_myAvatar->setDriveKeys(ROT_DOWN, userInputMapper->getActionState(UserInputMapper::PITCH_DOWN));
_myAvatar->setDriveKeys(ROT_LEFT, userInputMapper->getActionState(UserInputMapper::YAW_LEFT));
_myAvatar->setDriveKeys(ROT_RIGHT, userInputMapper->getActionState(UserInputMapper::YAW_RIGHT));
}
_myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN));
_myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT));
_myAvatar->setDriveKeys(BOOM_IN, userInputMapper->getActionState(UserInputMapper::BOOM_IN));
_myAvatar->setDriveKeys(BOOM_OUT, userInputMapper->getActionState(UserInputMapper::BOOM_OUT));
}
updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...

View file

@ -54,7 +54,7 @@
#include "Stars.h"
#include "avatar/Avatar.h"
#include "avatar/MyAvatar.h"
#include "devices/SixenseManager.h"
//#include "devices/SixenseManager.h"
#include "scripting/ControllerScriptingInterface.h"
#include "scripting/WebWindowClass.h"
#include "ui/BandwidthDialog.h"
@ -69,7 +69,6 @@
#include "ui/ApplicationCompositor.h"
#include "ui/RunningScriptsWidget.h"
#include "ui/ToolWindow.h"
#include "ui/UserInputMapper.h"
#include "devices/KeyboardMouseDevice.h"
#include "octree/OctreeFade.h"
#include "octree/OctreePacketProcessor.h"
@ -149,7 +148,6 @@ public:
static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); }
static glm::vec3 getPositionForAudio() { return getInstance()->_myAvatar->getHead()->getPosition(); }
static glm::quat getOrientationForAudio() { return getInstance()->_myAvatar->getHead()->getFinalOrientationInWorldFrame(); }
static UserInputMapper* getUserInputMapper() { return &getInstance()->_userInputMapper; }
static void initPlugins();
static void shutdownPlugins();
@ -556,7 +554,6 @@ private:
OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers
KeyboardMouseDevice _keyboardMouseDevice; // Default input device, the good old keyboard mouse and maybe touchpad
UserInputMapper _userInputMapper; // User input mapper allowing to mapp different real devices to the action channels that the application has to offer
MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be)
Camera _myCamera; // My view onto the world
Camera _mirrorCamera; // Cammera for mirror view

View file

@ -30,7 +30,7 @@
#include "devices/DdeFaceTracker.h"
#include "devices/Faceshift.h"
#include "devices/RealSense.h"
#include "devices/SixenseManager.h"
//#include "devices/SixenseManager.h"
#include "MainWindow.h"
#include "scripting/MenuScriptingInterface.h"
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
@ -468,6 +468,7 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
#if 0
MenuWrapper* sixenseOptionsMenu = handOptionsMenu->addMenu("Sixense");
#ifdef __APPLE__
addCheckableActionToQMenuAndActionHash(sixenseOptionsMenu,
@ -490,6 +491,7 @@ Menu::Menu() {
SLOT(setLowVelocityFilter(bool)));
addCheckableActionToQMenuAndActionHash(sixenseOptionsMenu, MenuOption::SixenseMouseInput, 0, true);
addCheckableActionToQMenuAndActionHash(sixenseOptionsMenu, MenuOption::SixenseLasers, 0, false);
#endif
MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);

View file

@ -20,7 +20,7 @@
#undef main
#endif
#include "ui/UserInputMapper.h"
#include <input-plugins/UserInputMapper.h>
class Joystick : public QObject {
Q_OBJECT

View file

@ -14,7 +14,7 @@
#include <QTouchEvent>
#include <chrono>
#include "ui/UserInputMapper.h"
#include <input-plugins/UserInputMapper.h>
class KeyboardMouseDevice {
public:

View file

@ -46,8 +46,9 @@ _isInitialized(false)
if (!_openJoysticks.contains(id)) {
Joystick* joystick = new Joystick(id, SDL_GameControllerName(controller), controller);
_openJoysticks[id] = joystick;
joystick->registerToUserInputMapper(*Application::getUserInputMapper());
joystick->assignDefaultInputMapping(*Application::getUserInputMapper());
auto userInputMapper = DependencyManager::get<UserInputMapper>();
joystick->registerToUserInputMapper(*userInputMapper);
joystick->assignDefaultInputMapping(*userInputMapper);
emit joystickAdded(joystick);
}
}
@ -84,6 +85,7 @@ void SDL2Manager::focusOutEvent() {
void SDL2Manager::update() {
#ifdef HAVE_SDL2
if (_isInitialized) {
auto userInputMapper = DependencyManager::get<UserInputMapper>();
for (auto joystick : _openJoysticks) {
joystick->update();
}
@ -132,14 +134,14 @@ void SDL2Manager::update() {
if (!_openJoysticks.contains(id)) {
Joystick* joystick = new Joystick(id, SDL_GameControllerName(controller), controller);
_openJoysticks[id] = joystick;
joystick->registerToUserInputMapper(*Application::getUserInputMapper());
joystick->assignDefaultInputMapping(*Application::getUserInputMapper());
joystick->registerToUserInputMapper(*userInputMapper);
joystick->assignDefaultInputMapping(*userInputMapper);
emit joystickAdded(joystick);
}
} else if (event.type == SDL_CONTROLLERDEVICEREMOVED) {
Joystick* joystick = _openJoysticks[event.cdevice.which];
_openJoysticks.remove(event.cdevice.which);
Application::getUserInputMapper()->removeDevice(joystick->getDeviceID());
userInputMapper->removeDevice(joystick->getDeviceID());
emit joystickRemoved(joystick);
}
}

View file

@ -16,7 +16,7 @@
#include <SDL.h>
#endif
#include "ui/UserInputMapper.h"
#include <input-plugins/UserInputMapper.h>
#include "devices/Joystick.h"

View file

@ -17,7 +17,7 @@
#include "Application.h"
#include "devices/MotionTracker.h"
#include "devices/SixenseManager.h"
//#include "devices/SixenseManager.h"
#include "ControllerScriptingInterface.h"
@ -81,13 +81,14 @@ void inputChannelFromScriptValue(const QScriptValue& object, UserInputMapper::In
QScriptValue actionToScriptValue(QScriptEngine* engine, const UserInputMapper::Action& action) {
QScriptValue obj = engine->newObject();
QVector<UserInputMapper::InputChannel> inputChannels = Application::getUserInputMapper()->getInputChannelsForAction(action);
auto userInputMapper = DependencyManager::get<UserInputMapper>();
QVector<UserInputMapper::InputChannel> inputChannels = userInputMapper->getInputChannelsForAction(action);
QScriptValue _inputChannels = engine->newArray(inputChannels.size());
for (int i = 0; i < inputChannels.size(); i++) {
_inputChannels.setProperty(i, inputChannelToScriptValue(engine, inputChannels[i]));
}
obj.setProperty("action", (int) action);
obj.setProperty("actionName", Application::getUserInputMapper()->getActionName(action));
obj.setProperty("actionName", userInputMapper->getActionName(action));
obj.setProperty("inputChannels", _inputChannels);
return obj;
}
@ -427,43 +428,43 @@ void ControllerScriptingInterface::updateInputControllers() {
}
QVector<UserInputMapper::Action> ControllerScriptingInterface::getAllActions() {
return Application::getUserInputMapper()->getAllActions();
return DependencyManager::get<UserInputMapper>()->getAllActions();
}
QVector<UserInputMapper::InputChannel> ControllerScriptingInterface::getInputChannelsForAction(UserInputMapper::Action action) {
return Application::getUserInputMapper()->getInputChannelsForAction(action);
return DependencyManager::get<UserInputMapper>()->getInputChannelsForAction(action);
}
QString ControllerScriptingInterface::getDeviceName(unsigned int device) {
return Application::getUserInputMapper()->getDeviceName((unsigned short) device);
return DependencyManager::get<UserInputMapper>()->getDeviceName((unsigned short)device);
}
QVector<UserInputMapper::InputChannel> ControllerScriptingInterface::getAllInputsForDevice(unsigned int device) {
return Application::getUserInputMapper()->getAllInputsForDevice(device);
return DependencyManager::get<UserInputMapper>()->getAllInputsForDevice(device);
}
bool ControllerScriptingInterface::addInputChannel(UserInputMapper::InputChannel inputChannel) {
return Application::getUserInputMapper()->addInputChannel(inputChannel._action, inputChannel._input, inputChannel._modifier, inputChannel._scale);
return DependencyManager::get<UserInputMapper>()->addInputChannel(inputChannel._action, inputChannel._input, inputChannel._modifier, inputChannel._scale);
}
bool ControllerScriptingInterface::removeInputChannel(UserInputMapper::InputChannel inputChannel) {
return Application::getUserInputMapper()->removeInputChannel(inputChannel);
return DependencyManager::get<UserInputMapper>()->removeInputChannel(inputChannel);
}
QVector<UserInputMapper::InputPair> ControllerScriptingInterface::getAvailableInputs(unsigned int device) {
return Application::getUserInputMapper()->getAvailableInputs((unsigned short) device);
return DependencyManager::get<UserInputMapper>()->getAvailableInputs((unsigned short)device);
}
void ControllerScriptingInterface::resetAllDeviceBindings() {
Application::getUserInputMapper()->resetAllDeviceBindings();
DependencyManager::get<UserInputMapper>()->resetAllDeviceBindings();
}
void ControllerScriptingInterface::resetDevice(unsigned int device) {
Application::getUserInputMapper()->resetDevice(device);
DependencyManager::get<UserInputMapper>()->resetDevice(device);
}
int ControllerScriptingInterface::findDevice(QString name) {
return Application::getUserInputMapper()->findDevice(name);
return DependencyManager::get<UserInputMapper>()->findDevice(name);
}
InputController::InputController(int deviceTrackerId, int subTrackerId, QObject* parent) :

View file

@ -14,7 +14,7 @@
#include <QtCore/QObject>
#include "ui/UserInputMapper.h"
#include <input-plugins/UserInputMapper.h>
#include <AbstractControllerScriptingInterface.h>
class PalmData;

View file

@ -0,0 +1,22 @@
set(TARGET_NAME input-plugins)
setup_hifi_library()
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
link_hifi_libraries(shared plugins)
GroupSources("src/input-plugins")
add_dependency_external_projects(glm)
find_package(GLM REQUIRED)
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
add_dependency_external_projects(OpenVR)
find_package(OpenVR REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${OPENVR_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${OPENVR_LIBRARIES})
add_dependency_external_projects(Sixense)
find_package(Sixense REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${SIXENSE_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${SIXENSE_LIBRARIES})

View file

@ -8,15 +8,9 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <algorithm>
#include "Application.h"
#include "UserInputMapper.h"
// UserInputMapper Class
// Default contruct allocate the poutput size with the current hardcoded action channels
UserInputMapper::UserInputMapper() {
assignDefaulActionScales();
@ -211,7 +205,7 @@ void UserInputMapper::update(float deltaTime) {
for (auto i = 0; i < NUM_ACTIONS; i++) {
_actionStates[i] *= _actionScales[i];
if (_actionStates[i] > 0) {
emit Application::getInstance()->getControllerScriptingInterface()->actionEvent(i, _actionStates[i]);
emit actionEvent(i, _actionStates[i]);
}
}
}

View file

@ -13,14 +13,17 @@
#define hifi_UserInputMapper_h
#include <glm/glm.hpp>
#include <RegisteredMetaTypes.h>
#include <unordered_set>
#include <functional>
#include <memory>
#include <DependencyManager.h>
#include <RegisteredMetaTypes.h>
class UserInputMapper : public QObject {
class UserInputMapper : public QObject, public Dependency {
Q_OBJECT
SINGLETON_DEPENDENCY
Q_ENUMS(Action)
public:
typedef unsigned short uint16;
@ -208,6 +211,10 @@ public:
UserInputMapper();
signals:
void actionEvent(int action, float state);
protected:
typedef std::map<int, DeviceProxy::Pointer> DevicesMap;
DevicesMap _registeredDevices;

View file

@ -10,14 +10,18 @@
//
#include <vector>
#include <QLoggingCategory>
#include <avatar/AvatarManager.h>
#include <PerfStat.h>
#include <NumericalConstants.h>
#include "Application.h"
#include "SixenseManager.h"
#include "UserActivityLogger.h"
#include "InterfaceLogging.h"
#include "../UserInputMapper.h"
Q_DECLARE_LOGGING_CATEGORY(sixense)
Q_LOGGING_CATEGORY(sixense, "hifi.devices.sixense")
// These bits aren't used for buttons, so they can be used as masks:
const unsigned int LEFT_MASK = 0;
@ -152,8 +156,10 @@ void SixenseManager::setFilter(bool filter) {
}
void SixenseManager::update(float deltaTime) {
#if 0
#ifdef HAVE_SIXENSE
Hand* hand = DependencyManager::get<AvatarManager>()->getMyAvatar()->getHand();
auto userInputMapper = DependencyManager::get<UserInputMapper>();
if (_isInitialized && _isEnabled) {
_buttonPressedMap.clear();
#ifdef __APPLE__
@ -164,7 +170,8 @@ void SixenseManager::update(float deltaTime) {
if (sixenseGetNumActiveControllers() == 0) {
_hydrasConnected = false;
if (_deviceID != 0) {
Application::getUserInputMapper()->removeDevice(_deviceID);
userInputMapper->removeDevice(_deviceID);
_deviceID = 0;
if (_prevPalms[0]) {
_prevPalms[0]->setActive(false);
@ -179,8 +186,8 @@ void SixenseManager::update(float deltaTime) {
PerformanceTimer perfTimer("sixense");
if (!_hydrasConnected) {
_hydrasConnected = true;
registerToUserInputMapper(*Application::getUserInputMapper());
getInstance().assignDefaultInputMapping(*Application::getUserInputMapper());
registerToUserInputMapper(*userInputMapper);
getInstance().assignDefaultInputMapping(*userInputMapper);
UserActivityLogger::getInstance().connectedDevice("spatial_controller", "hydra");
}
@ -335,6 +342,7 @@ void SixenseManager::update(float deltaTime) {
}
}
#endif // HAVE_SIXENSE
#endif
}
//Constants for getCursorPixelRangeMultiplier()
@ -351,8 +359,10 @@ float SixenseManager::getCursorPixelRangeMult() const {
void SixenseManager::toggleSixense(bool shouldEnable) {
if (shouldEnable && !isInitialized()) {
initialize();
#if 0
setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
setLowVelocityFilter(Menu::getInstance()->isOptionChecked(MenuOption::LowVelocityFilter));
#endif
}
setIsEnabled(shouldEnable);
}
@ -395,11 +405,11 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
glm::vec3 zAxis = glm::normalize(glm::cross(xAxis, yAxis));
xAxis = glm::normalize(glm::cross(yAxis, zAxis));
_orbRotation = glm::inverse(glm::quat_cast(glm::mat3(xAxis, yAxis, zAxis)));
qCDebug(interfaceapp, "succeess: sixense calibration");
qCDebug(sixense, "succeess: sixense calibration");
}
break;
default:
qCDebug(interfaceapp, "failed: sixense calibration");
qCDebug(sixense, "failed: sixense calibration");
break;
}
@ -418,7 +428,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
if (_calibrationState == CALIBRATION_STATE_IDLE) {
float reach = glm::distance(positionLeft, positionRight);
if (reach > 2.0f * MINIMUM_ARM_REACH) {
qCDebug(interfaceapp, "started: sixense calibration");
qCDebug(sixense, "started: sixense calibration");
_averageLeft = positionLeft;
_averageRight = positionRight;
_reachLeft = _averageLeft;
@ -451,7 +461,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
_lastDistance = 0.0f;
_reachUp = 0.5f * (_reachLeft + _reachRight);
_calibrationState = CALIBRATION_STATE_Y;
qCDebug(interfaceapp, "success: sixense calibration: left");
qCDebug(sixense, "success: sixense calibration: left");
}
}
else if (_calibrationState == CALIBRATION_STATE_Y) {
@ -470,7 +480,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
_lastDistance = 0.0f;
_lockExpiry = now + LOCK_DURATION;
_calibrationState = CALIBRATION_STATE_Z;
qCDebug(interfaceapp, "success: sixense calibration: up");
qCDebug(sixense, "success: sixense calibration: up");
}
}
}
@ -492,7 +502,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
if (fabsf(_lastDistance) > 0.05f * MINIMUM_ARM_REACH) {
// lock has expired so clamp the data and move on
_calibrationState = CALIBRATION_STATE_COMPLETE;
qCDebug(interfaceapp, "success: sixense calibration: forward");
qCDebug(sixense, "success: sixense calibration: forward");
// TODO: it is theoretically possible to detect that the controllers have been
// accidentally switched (left hand is holding right controller) and to swap the order.
}
@ -502,6 +512,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
//Injecting mouse movements and clicks
void SixenseManager::emulateMouse(PalmData* palm, int index) {
#if 0
MyAvatar* avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
QPoint pos;
@ -616,6 +627,7 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) {
_triggerPressed[index] = false;
}
#endif
}
#endif // HAVE_SIXENSE

View file

@ -14,11 +14,14 @@
#include <QObject>
#include <unordered_set>
#include "../UserInputMapper.h"
#define HAVE_SIXENSE
#ifdef HAVE_SIXENSE
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include "sixense.h"
#include <sixense.h>
#ifdef __APPLE__
#include <qlibrary.h>
@ -26,8 +29,6 @@
#endif
#include "ui/UserInputMapper.h"
class PalmData;
const unsigned int BUTTON_0 = 1U << 0; // the skinny button between 1 and 2