mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 14:54:29 +02:00
Add "enabled" setting for Sixense; bail in update if note enabled
This commit is contained in:
parent
31714675c3
commit
72d712ac76
4 changed files with 46 additions and 12 deletions
|
@ -17,7 +17,7 @@ PreferencesDialog {
|
||||||
id: root
|
id: root
|
||||||
objectName: "GeneralPreferencesDialog"
|
objectName: "GeneralPreferencesDialog"
|
||||||
title: "General Settings"
|
title: "General Settings"
|
||||||
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "SDL2 Joystick", "Perception Neuron", "Kinect"]
|
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "SDL2 Joystick", "Sixense Controllers", "Perception Neuron", "Kinect"]
|
||||||
property var settings: Settings {
|
property var settings: Settings {
|
||||||
category: root.objectName
|
category: root.objectName
|
||||||
property alias x: root.x
|
property alias x: root.x
|
||||||
|
|
|
@ -32,6 +32,6 @@ StackView {
|
||||||
TabletPreferencesDialog {
|
TabletPreferencesDialog {
|
||||||
id: root
|
id: root
|
||||||
objectName: "TabletGeneralPreferences"
|
objectName: "TabletGeneralPreferences"
|
||||||
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "SDL2 Joystick", "Perception Neuron", "Kinect", "Vive Pucks Configuration"]
|
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "SDL2 Joystick", "Sixense Controllers", "Perception Neuron", "Kinect", "Vive Pucks Configuration"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <ui-plugins/PluginContainer.h>
|
#include <ui-plugins/PluginContainer.h>
|
||||||
|
#include <Preferences.h>
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
@ -46,19 +47,26 @@ static const unsigned int BUTTON_TRIGGER = 1U << 8;
|
||||||
|
|
||||||
const glm::vec3 SixenseManager::DEFAULT_AVATAR_POSITION { -0.25f, -0.35f, -0.3f }; // in hydra frame
|
const glm::vec3 SixenseManager::DEFAULT_AVATAR_POSITION { -0.25f, -0.35f, -0.3f }; // in hydra frame
|
||||||
const float SixenseManager::CONTROLLER_THRESHOLD { 0.35f };
|
const float SixenseManager::CONTROLLER_THRESHOLD { 0.35f };
|
||||||
|
|
||||||
|
bool SixenseManager::_isEnabled = false;
|
||||||
bool SixenseManager::_sixenseLoaded = false;
|
bool SixenseManager::_sixenseLoaded = false;
|
||||||
|
|
||||||
|
#define BAIL_IF_NOT_ENABLED \
|
||||||
|
if (!_isEnabled) { \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define BAIL_IF_NOT_LOADED \
|
#define BAIL_IF_NOT_LOADED \
|
||||||
if (!_sixenseLoaded) { \
|
if (!_sixenseLoaded) { \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* SixenseManager::NAME { "Sixense" };
|
const char* SixenseManager::NAME { "Sixense" };
|
||||||
const char* SixenseManager::HYDRA_ID_STRING { "Razer Hydra" };
|
const char* SixenseManager::SIXENSE_ID_STRING { "Sixense" };
|
||||||
|
|
||||||
const char* MENU_PARENT { "Developer" };
|
const bool DEFAULT_ENABLED = false;
|
||||||
|
|
||||||
|
const char* MENU_PARENT{ "Developer" };
|
||||||
const char* MENU_NAME { "Sixense" };
|
const char* MENU_NAME { "Sixense" };
|
||||||
const char* MENU_PATH { "Developer" ">" "Sixense" };
|
const char* MENU_PATH { "Developer" ">" "Sixense" };
|
||||||
const char* TOGGLE_SMOOTH { "Smooth Sixense Movement" };
|
const char* TOGGLE_SMOOTH { "Smooth Sixense Movement" };
|
||||||
|
@ -73,6 +81,22 @@ bool SixenseManager::isSupported() const {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SixenseManager::init() {
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
|
auto preferences = DependencyManager::get<Preferences>();
|
||||||
|
static const QString SIXENSE_PLUGIN { "Sixense Controllers" };
|
||||||
|
{
|
||||||
|
auto getter = [this]()->bool { return _isEnabled; };
|
||||||
|
auto setter = [this](bool value) {
|
||||||
|
_isEnabled = value;
|
||||||
|
saveSettings();
|
||||||
|
};
|
||||||
|
auto preference = new CheckPreference(SIXENSE_PLUGIN, "Enabled", getter, setter);
|
||||||
|
preferences->addPreference(preference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SixenseManager::activate() {
|
bool SixenseManager::activate() {
|
||||||
InputPlugin::activate();
|
InputPlugin::activate();
|
||||||
|
|
||||||
|
@ -133,6 +157,7 @@ void SixenseManager::setSixenseFilter(bool filter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SixenseManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void SixenseManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
|
BAIL_IF_NOT_ENABLED
|
||||||
BAIL_IF_NOT_LOADED
|
BAIL_IF_NOT_LOADED
|
||||||
|
|
||||||
#ifdef HAVE_SIXENSE
|
#ifdef HAVE_SIXENSE
|
||||||
|
@ -553,14 +578,19 @@ QString SixenseManager::InputDevice::getDefaultMappingConfig() const {
|
||||||
return MAPPING_JSON;
|
return MAPPING_JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* SETTINGS_ENABLED_KEY = "enabled";
|
||||||
|
const char* SETTINGS_AVATAR_POSITION_KEY = "avatarPosition";
|
||||||
|
const char* SETTINGS_AVATAR_ROTATION_KEY = "avatarPosition";
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
void SixenseManager::saveSettings() const {
|
void SixenseManager::saveSettings() const {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
QString idString = getID();
|
QString idString = getID();
|
||||||
settings.beginGroup(idString);
|
settings.beginGroup(idString);
|
||||||
{
|
{
|
||||||
settings.setVec3Value(QString("avatarPosition"), _inputDevice->_avatarPosition);
|
settings.setValue(QString(SETTINGS_ENABLED_KEY), _isEnabled);
|
||||||
settings.setQuatValue(QString("avatarRotation"), _inputDevice->_avatarRotation);
|
settings.setVec3Value(QString(SETTINGS_AVATAR_POSITION_KEY), _inputDevice->_avatarPosition);
|
||||||
|
settings.setQuatValue(QString(SETTINGS_AVATAR_ROTATION_KEY), _inputDevice->_avatarRotation);
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -570,8 +600,9 @@ void SixenseManager::loadSettings() {
|
||||||
QString idString = getID();
|
QString idString = getID();
|
||||||
settings.beginGroup(idString);
|
settings.beginGroup(idString);
|
||||||
{
|
{
|
||||||
settings.getVec3ValueIfValid(QString("avatarPosition"), _inputDevice->_avatarPosition);
|
_isEnabled = settings.value(SETTINGS_ENABLED_KEY, QVariant(DEFAULT_ENABLED)).toBool();
|
||||||
settings.getQuatValueIfValid(QString("avatarRotation"), _inputDevice->_avatarRotation);
|
settings.getVec3ValueIfValid(QString(SETTINGS_AVATAR_POSITION_KEY), _inputDevice->_avatarPosition);
|
||||||
|
settings.getQuatValueIfValid(QString(SETTINGS_AVATAR_ROTATION_KEY), _inputDevice->_avatarRotation);
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,14 @@ public:
|
||||||
// Plugin functions
|
// Plugin functions
|
||||||
virtual bool isSupported() const override;
|
virtual bool isSupported() const override;
|
||||||
virtual const QString getName() const override { return NAME; }
|
virtual const QString getName() const override { return NAME; }
|
||||||
virtual const QString getID() const override { return HYDRA_ID_STRING; }
|
virtual const QString getID() const override { return SIXENSE_ID_STRING; }
|
||||||
|
|
||||||
// Sixense always seems to initialize even if the hydras are not present. Is there
|
// Sixense always seems to initialize even if the hydras are not present. Is there
|
||||||
// a way we can properly detect whether the hydras are present?
|
// a way we can properly detect whether the hydras are present?
|
||||||
// bool isHandController() const override { return true; }
|
// bool isHandController() const override { return true; }
|
||||||
|
|
||||||
|
virtual void init() override;
|
||||||
|
|
||||||
virtual bool activate() override;
|
virtual bool activate() override;
|
||||||
virtual void deactivate() override;
|
virtual void deactivate() override;
|
||||||
|
|
||||||
|
@ -93,8 +95,9 @@ private:
|
||||||
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };
|
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };
|
||||||
|
|
||||||
static const char* NAME;
|
static const char* NAME;
|
||||||
static const char* HYDRA_ID_STRING;
|
static const char* SIXENSE_ID_STRING;
|
||||||
|
|
||||||
|
static bool _isEnabled;
|
||||||
static bool _sixenseLoaded;
|
static bool _sixenseLoaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue