mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:29:03 +02:00
Merge pull request #14118 from luiscuenca/handTouchLMFix
Disable Hand Touch when Leap Motion is running
This commit is contained in:
commit
8bd8d05409
13 changed files with 92 additions and 19 deletions
|
@ -1061,6 +1061,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
auto controllerScriptingInterface = DependencyManager::get<controller::ScriptingInterface>().data();
|
auto controllerScriptingInterface = DependencyManager::get<controller::ScriptingInterface>().data();
|
||||||
_controllerScriptingInterface = dynamic_cast<ControllerScriptingInterface*>(controllerScriptingInterface);
|
_controllerScriptingInterface = dynamic_cast<ControllerScriptingInterface*>(controllerScriptingInterface);
|
||||||
|
connect(PluginManager::getInstance().data(), &PluginManager::inputDeviceRunningChanged,
|
||||||
|
controllerScriptingInterface, &controller::ScriptingInterface::updateRunningInputDevices);
|
||||||
|
|
||||||
_entityClipboard->createRootElement();
|
_entityClipboard->createRootElement();
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,17 @@ namespace controller {
|
||||||
return inputRecorder->getSaveDirectory();
|
return inputRecorder->getSaveDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ScriptingInterface::getRunningInputDeviceNames() {
|
||||||
|
QMutexLocker locker(&_runningDevicesMutex);
|
||||||
|
return _runningInputDeviceNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptingInterface::updateRunningInputDevices(const QString& deviceName, bool isRunning, const QStringList& runningDevices) {
|
||||||
|
QMutexLocker locker(&_runningDevicesMutex);
|
||||||
|
_runningInputDeviceNames = runningDevices;
|
||||||
|
emit inputDeviceRunningChanged(deviceName, isRunning);
|
||||||
|
}
|
||||||
|
|
||||||
bool ScriptingInterface::triggerHapticPulseOnDevice(unsigned int device, float strength, float duration, controller::Hand hand) const {
|
bool ScriptingInterface::triggerHapticPulseOnDevice(unsigned int device, float strength, float duration, controller::Hand hand) const {
|
||||||
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, hand);
|
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, hand);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
#include <QtQml/QJSValue>
|
#include <QtQml/QJSValue>
|
||||||
#include <QtScript/QScriptValue>
|
#include <QtScript/QScriptValue>
|
||||||
|
@ -431,6 +432,13 @@ namespace controller {
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE QString getInputRecorderSaveDirectory();
|
Q_INVOKABLE QString getInputRecorderSaveDirectory();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Get all the active and enabled (running) input devices
|
||||||
|
* @function Controller.getRunningInputDevices
|
||||||
|
* @returns {string[]} An array of strings with the names
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QStringList getRunningInputDeviceNames();
|
||||||
|
|
||||||
bool isMouseCaptured() const { return _mouseCaptured; }
|
bool isMouseCaptured() const { return _mouseCaptured; }
|
||||||
bool isTouchCaptured() const { return _touchCaptured; }
|
bool isTouchCaptured() const { return _touchCaptured; }
|
||||||
bool isWheelCaptured() const { return _wheelCaptured; }
|
bool isWheelCaptured() const { return _wheelCaptured; }
|
||||||
|
@ -531,6 +539,8 @@ namespace controller {
|
||||||
*/
|
*/
|
||||||
virtual void releaseActionEvents() { _actionsCaptured = false; }
|
virtual void releaseActionEvents() { _actionsCaptured = false; }
|
||||||
|
|
||||||
|
void updateRunningInputDevices(const QString& deviceName, bool isRunning, const QStringList& runningDevices);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when an action occurs.
|
* Triggered when an action occurs.
|
||||||
|
@ -590,6 +600,17 @@ namespace controller {
|
||||||
*/
|
*/
|
||||||
void hardwareChanged();
|
void hardwareChanged();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when a device is enabled/disabled
|
||||||
|
* Enabling/Disabling Leapmotion on settings/controls will trigger this signal.
|
||||||
|
* @function Controller.deviceRunningChanged
|
||||||
|
* @param {string} deviceName - The name of the device that is getting enabled/disabled
|
||||||
|
* @param {boolean} isEnabled - Return if the device is enabled.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void inputDeviceRunningChanged(QString deviceName, bool isRunning);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Update the exposed variant maps reporting active hardware
|
// Update the exposed variant maps reporting active hardware
|
||||||
void updateMaps();
|
void updateMaps();
|
||||||
|
@ -598,10 +619,14 @@ namespace controller {
|
||||||
QVariantMap _actions;
|
QVariantMap _actions;
|
||||||
QVariantMap _standard;
|
QVariantMap _standard;
|
||||||
|
|
||||||
|
QStringList _runningInputDeviceNames;
|
||||||
|
|
||||||
std::atomic<bool> _mouseCaptured{ false };
|
std::atomic<bool> _mouseCaptured{ false };
|
||||||
std::atomic<bool> _touchCaptured { false };
|
std::atomic<bool> _touchCaptured { false };
|
||||||
std::atomic<bool> _wheelCaptured { false };
|
std::atomic<bool> _wheelCaptured { false };
|
||||||
std::atomic<bool> _actionsCaptured { false };
|
std::atomic<bool> _actionsCaptured { false };
|
||||||
|
|
||||||
|
QMutex _runningDevicesMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,11 @@ public:
|
||||||
|
|
||||||
virtual void saveSettings() const {}
|
virtual void saveSettings() const {}
|
||||||
virtual void loadSettings() {}
|
virtual void loadSettings() {}
|
||||||
|
virtual bool isRunning() const { return _active; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void deviceStatusChanged(const QString& deviceName, bool isRunning) const;
|
||||||
|
|
||||||
// These signals should be emitted when a device is first known to be available. In some cases this will
|
// These signals should be emitted when a device is first known to be available. In some cases this will
|
||||||
// be in `init()`, in other cases, like Neuron, this isn't known until activation.
|
// be in `init()`, in other cases, like Neuron, this isn't known until activation.
|
||||||
// SDL2 isn't a device itself, but can have 0+ subdevices. subdeviceConnected is used in this case.
|
// SDL2 isn't a device itself, but can have 0+ subdevices. subdeviceConnected is used in this case.
|
||||||
|
@ -85,6 +88,7 @@ signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _active { false };
|
bool _active { false };
|
||||||
|
bool _enabled { false };
|
||||||
bool _sessionStatus { false };
|
bool _sessionStatus { false };
|
||||||
PluginContainer* _container { nullptr };
|
PluginContainer* _container { nullptr };
|
||||||
static const char* UNKNOWN_PLUGIN_ID;
|
static const char* UNKNOWN_PLUGIN_ID;
|
||||||
|
|
|
@ -225,8 +225,11 @@ void PluginManager::disableDisplayPlugin(const QString& name) {
|
||||||
|
|
||||||
const InputPluginList& PluginManager::getInputPlugins() {
|
const InputPluginList& PluginManager::getInputPlugins() {
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
static auto deviceAddedCallback = [](QString deviceName) {
|
static auto deviceAddedCallback = [&](QString deviceName) {
|
||||||
qCDebug(plugins) << "Added device: " << deviceName;
|
qCDebug(plugins) << "Added device: " << deviceName;
|
||||||
|
QStringList runningDevices = getRunningInputDeviceNames();
|
||||||
|
bool isDeviceRunning = runningDevices.indexOf(deviceName) >= 0;
|
||||||
|
emit inputDeviceRunningChanged(deviceName, isDeviceRunning, runningDevices);
|
||||||
UserActivityLogger::getInstance().connectedDevice("input", deviceName);
|
UserActivityLogger::getInstance().connectedDevice("input", deviceName);
|
||||||
};
|
};
|
||||||
static auto subdeviceAddedCallback = [](QString pluginName, QString deviceName) {
|
static auto subdeviceAddedCallback = [](QString pluginName, QString deviceName) {
|
||||||
|
@ -252,6 +255,9 @@ const InputPluginList& PluginManager::getInputPlugins() {
|
||||||
for (auto plugin : _inputPlugins) {
|
for (auto plugin : _inputPlugins) {
|
||||||
connect(plugin.get(), &Plugin::deviceConnected, this, deviceAddedCallback, Qt::QueuedConnection);
|
connect(plugin.get(), &Plugin::deviceConnected, this, deviceAddedCallback, Qt::QueuedConnection);
|
||||||
connect(plugin.get(), &Plugin::subdeviceConnected, this, subdeviceAddedCallback, Qt::QueuedConnection);
|
connect(plugin.get(), &Plugin::subdeviceConnected, this, subdeviceAddedCallback, Qt::QueuedConnection);
|
||||||
|
connect(plugin.get(), &Plugin::deviceStatusChanged, this, [&](const QString& deviceName, bool isRunning) {
|
||||||
|
emit inputDeviceRunningChanged(deviceName, isRunning, getRunningInputDeviceNames());
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
plugin->setContainer(_container);
|
plugin->setContainer(_container);
|
||||||
plugin->init();
|
plugin->init();
|
||||||
}
|
}
|
||||||
|
@ -259,6 +265,16 @@ const InputPluginList& PluginManager::getInputPlugins() {
|
||||||
return _inputPlugins;
|
return _inputPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList PluginManager::getRunningInputDeviceNames() const {
|
||||||
|
QStringList runningDevices;
|
||||||
|
for (auto plugin: _inputPlugins) {
|
||||||
|
if (plugin->isRunning()) {
|
||||||
|
runningDevices << plugin->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return runningDevices;
|
||||||
|
}
|
||||||
|
|
||||||
void PluginManager::setPreferredDisplayPlugins(const QStringList& displays) {
|
void PluginManager::setPreferredDisplayPlugins(const QStringList& displays) {
|
||||||
preferredDisplayPlugins = displays;
|
preferredDisplayPlugins = displays;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ using PluginManagerPointer = QSharedPointer<PluginManager>;
|
||||||
|
|
||||||
class PluginManager : public QObject, public Dependency {
|
class PluginManager : public QObject, public Dependency {
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PluginManagerPointer getInstance();
|
static PluginManagerPointer getInstance();
|
||||||
|
@ -44,6 +45,10 @@ public:
|
||||||
void setInputPluginProvider(const InputPluginProvider& provider);
|
void setInputPluginProvider(const InputPluginProvider& provider);
|
||||||
void setCodecPluginProvider(const CodecPluginProvider& provider);
|
void setCodecPluginProvider(const CodecPluginProvider& provider);
|
||||||
void setInputPluginSettingsPersister(const InputPluginSettingsPersister& persister);
|
void setInputPluginSettingsPersister(const InputPluginSettingsPersister& persister);
|
||||||
|
QStringList getRunningInputDeviceNames() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void inputDeviceRunningChanged(const QString& pluginName, bool isRunning, const QStringList& runningDevices);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginManager() = default;
|
PluginManager() = default;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
Q_DECLARE_LOGGING_CATEGORY(inputplugins)
|
Q_DECLARE_LOGGING_CATEGORY(inputplugins)
|
||||||
Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins")
|
Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins")
|
||||||
|
|
||||||
const char* LeapMotionPlugin::NAME = "Leap Motion";
|
const char* LeapMotionPlugin::NAME = "LeapMotion";
|
||||||
const char* LeapMotionPlugin::LEAPMOTION_ID_STRING = "Leap Motion";
|
const char* LeapMotionPlugin::LEAPMOTION_ID_STRING = "Leap Motion";
|
||||||
|
|
||||||
const bool DEFAULT_ENABLED = false;
|
const bool DEFAULT_ENABLED = false;
|
||||||
|
@ -203,7 +203,6 @@ static const char* getControllerJointName(controller::StandardPoseChannel i) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LeapMotionPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void LeapMotionPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -312,13 +311,13 @@ void LeapMotionPlugin::InputDevice::update(float deltaTime, const controller::In
|
||||||
|
|
||||||
void LeapMotionPlugin::init() {
|
void LeapMotionPlugin::init() {
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
auto preferences = DependencyManager::get<Preferences>();
|
auto preferences = DependencyManager::get<Preferences>();
|
||||||
static const QString LEAPMOTION_PLUGIN { "Leap Motion" };
|
static const QString LEAPMOTION_PLUGIN { "Leap Motion" };
|
||||||
{
|
{
|
||||||
auto getter = [this]()->bool { return _enabled; };
|
auto getter = [this]()->bool { return _enabled; };
|
||||||
auto setter = [this](bool value) {
|
auto setter = [this](bool value) {
|
||||||
_enabled = value;
|
_enabled = value;
|
||||||
|
emit deviceStatusChanged(getName(), isRunning());
|
||||||
saveSettings();
|
saveSettings();
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
@ -406,6 +405,7 @@ void LeapMotionPlugin::loadSettings() {
|
||||||
settings.beginGroup(idString);
|
settings.beginGroup(idString);
|
||||||
{
|
{
|
||||||
_enabled = settings.value(SETTINGS_ENABLED_KEY, QVariant(DEFAULT_ENABLED)).toBool();
|
_enabled = settings.value(SETTINGS_ENABLED_KEY, QVariant(DEFAULT_ENABLED)).toBool();
|
||||||
|
emit deviceStatusChanged(getName(), isRunning());
|
||||||
_sensorLocation = settings.value(SETTINGS_SENSOR_LOCATION_KEY, QVariant(DEFAULT_SENSOR_LOCATION)).toString();
|
_sensorLocation = settings.value(SETTINGS_SENSOR_LOCATION_KEY, QVariant(DEFAULT_SENSOR_LOCATION)).toString();
|
||||||
_desktopHeightOffset =
|
_desktopHeightOffset =
|
||||||
settings.value(SETTINGS_DESKTOP_HEIGHT_OFFSET_KEY, QVariant(DEFAULT_DESKTOP_HEIGHT_OFFSET)).toFloat();
|
settings.value(SETTINGS_DESKTOP_HEIGHT_OFFSET_KEY, QVariant(DEFAULT_DESKTOP_HEIGHT_OFFSET)).toFloat();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
// Plugin methods
|
// Plugin methods
|
||||||
virtual const QString getName() const override { return NAME; }
|
virtual const QString getName() const override { return NAME; }
|
||||||
const QString getID() const override { return LEAPMOTION_ID_STRING; }
|
const QString getID() const override { return LEAPMOTION_ID_STRING; }
|
||||||
|
bool isRunning() const override { return _active && _enabled; }
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
|
|
||||||
virtual bool activate() override;
|
virtual bool activate() override;
|
||||||
|
@ -43,8 +43,6 @@ protected:
|
||||||
static const char* NAME;
|
static const char* NAME;
|
||||||
static const char* LEAPMOTION_ID_STRING;
|
static const char* LEAPMOTION_ID_STRING;
|
||||||
const float DEFAULT_DESKTOP_HEIGHT_OFFSET = 0.2f;
|
const float DEFAULT_DESKTOP_HEIGHT_OFFSET = 0.2f;
|
||||||
|
|
||||||
bool _enabled { false };
|
|
||||||
QString _sensorLocation;
|
QString _sensorLocation;
|
||||||
float _desktopHeightOffset { DEFAULT_DESKTOP_HEIGHT_OFFSET };
|
float _desktopHeightOffset { DEFAULT_DESKTOP_HEIGHT_OFFSET };
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,11 @@ void NeuronPlugin::init() {
|
||||||
static const QString NEURON_PLUGIN { "Perception Neuron" };
|
static const QString NEURON_PLUGIN { "Perception Neuron" };
|
||||||
{
|
{
|
||||||
auto getter = [this]()->bool { return _enabled; };
|
auto getter = [this]()->bool { return _enabled; };
|
||||||
auto setter = [this](bool value) { _enabled = value; saveSettings(); };
|
auto setter = [this](bool value) {
|
||||||
|
_enabled = value;
|
||||||
|
saveSettings();
|
||||||
|
emit deviceStatusChanged(getName(), _enabled && _active);
|
||||||
|
};
|
||||||
auto preference = new CheckPreference(NEURON_PLUGIN, "Enabled", getter, setter);
|
auto preference = new CheckPreference(NEURON_PLUGIN, "Enabled", getter, setter);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
@ -493,7 +497,7 @@ void NeuronPlugin::loadSettings() {
|
||||||
{
|
{
|
||||||
// enabled
|
// enabled
|
||||||
_enabled = settings.value("enabled", QVariant(DEFAULT_ENABLED)).toBool();
|
_enabled = settings.value("enabled", QVariant(DEFAULT_ENABLED)).toBool();
|
||||||
|
emit deviceStatusChanged(getName(), _enabled && _active);
|
||||||
// serverAddress
|
// serverAddress
|
||||||
_serverAddress = settings.value("serverAddress", QVariant(DEFAULT_SERVER_ADDRESS)).toString();
|
_serverAddress = settings.value("serverAddress", QVariant(DEFAULT_SERVER_ADDRESS)).toString();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
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; }
|
||||||
const QString getID() const override { return NEURON_ID_STRING; }
|
const QString getID() const override { return NEURON_ID_STRING; }
|
||||||
|
bool isRunning() const override { return _active && _enabled; }
|
||||||
virtual bool activate() override;
|
virtual bool activate() override;
|
||||||
virtual void deactivate() override;
|
virtual void deactivate() override;
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ protected:
|
||||||
static const char* NAME;
|
static const char* NAME;
|
||||||
static const char* NEURON_ID_STRING;
|
static const char* NEURON_ID_STRING;
|
||||||
|
|
||||||
bool _enabled;
|
|
||||||
QString _serverAddress;
|
QString _serverAddress;
|
||||||
int _serverPort;
|
int _serverPort;
|
||||||
void* _socketRef;
|
void* _socketRef;
|
||||||
|
|
|
@ -79,10 +79,11 @@ bool SDL2Manager::activate() {
|
||||||
auto preferences = DependencyManager::get<Preferences>();
|
auto preferences = DependencyManager::get<Preferences>();
|
||||||
static const QString SDL2_PLUGIN { "Game Controller" };
|
static const QString SDL2_PLUGIN { "Game Controller" };
|
||||||
{
|
{
|
||||||
auto getter = [this]()->bool { return _isEnabled; };
|
auto getter = [this]()->bool { return _enabled; };
|
||||||
auto setter = [this](bool value) {
|
auto setter = [this](bool value) {
|
||||||
_isEnabled = value;
|
_enabled = value;
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
emit deviceStatusChanged(getName(), isRunning());
|
||||||
};
|
};
|
||||||
auto preference = new CheckPreference(SDL2_PLUGIN, "Enabled", getter, setter);
|
auto preference = new CheckPreference(SDL2_PLUGIN, "Enabled", getter, setter);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
|
@ -147,7 +148,7 @@ void SDL2Manager::saveSettings() const {
|
||||||
QString idString = getID();
|
QString idString = getID();
|
||||||
settings.beginGroup(idString);
|
settings.beginGroup(idString);
|
||||||
{
|
{
|
||||||
settings.setValue(QString(SETTINGS_ENABLED_KEY), _isEnabled);
|
settings.setValue(QString(SETTINGS_ENABLED_KEY), _enabled);
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -157,7 +158,8 @@ void SDL2Manager::loadSettings() {
|
||||||
QString idString = getID();
|
QString idString = getID();
|
||||||
settings.beginGroup(idString);
|
settings.beginGroup(idString);
|
||||||
{
|
{
|
||||||
_isEnabled = settings.value(SETTINGS_ENABLED_KEY, QVariant(DEFAULT_ENABLED)).toBool();
|
_enabled = settings.value(SETTINGS_ENABLED_KEY, QVariant(DEFAULT_ENABLED)).toBool();
|
||||||
|
emit deviceStatusChanged(getName(), isRunning());
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -173,7 +175,7 @@ void SDL2Manager::pluginFocusOutEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL2Manager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void SDL2Manager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
if (!_isEnabled) {
|
if (!_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
bool isSupported() const override;
|
bool isSupported() const override;
|
||||||
const QString getName() const override { return NAME; }
|
const QString getName() const override { return NAME; }
|
||||||
const QString getID() const override { return SDL2_ID_STRING; }
|
const QString getID() const override { return SDL2_ID_STRING; }
|
||||||
|
bool isRunning() const override { return _active && _enabled; }
|
||||||
QStringList getSubdeviceNames() override;
|
QStringList getSubdeviceNames() override;
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
|
@ -81,7 +81,6 @@ private:
|
||||||
int buttonRelease() const { return SDL_RELEASED; }
|
int buttonRelease() const { return SDL_RELEASED; }
|
||||||
|
|
||||||
QMap<SDL_JoystickID, Joystick::Pointer> _openJoysticks;
|
QMap<SDL_JoystickID, Joystick::Pointer> _openJoysticks;
|
||||||
bool _isEnabled { false };
|
|
||||||
bool _isInitialized { false };
|
bool _isInitialized { false };
|
||||||
static const char* NAME;
|
static const char* NAME;
|
||||||
static const char* SDL2_ID_STRING;
|
static const char* SDL2_ID_STRING;
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
|
var LEAP_MOTION_NAME = "LeapMotion";
|
||||||
var handTouchEnabled = true;
|
var handTouchEnabled = true;
|
||||||
|
var leapMotionEnabled = Controller.getRunningInputDeviceNames().indexOf(LEAP_MOTION_NAME) >= 0;
|
||||||
var MSECONDS_AFTER_LOAD = 2000;
|
var MSECONDS_AFTER_LOAD = 2000;
|
||||||
var updateFingerWithIndex = 0;
|
var updateFingerWithIndex = 0;
|
||||||
var untouchableEntities = [];
|
var untouchableEntities = [];
|
||||||
|
@ -870,6 +872,12 @@
|
||||||
handTouchEnabled = !shouldDisable;
|
handTouchEnabled = !shouldDisable;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Controller.inputDeviceRunningChanged.connect(function (deviceName, isEnabled) {
|
||||||
|
if (deviceName == LEAP_MOTION_NAME) {
|
||||||
|
leapMotionEnabled = isEnabled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
MyAvatar.disableHandTouchForIDChanged.connect(function (entityID, disable) {
|
MyAvatar.disableHandTouchForIDChanged.connect(function (entityID, disable) {
|
||||||
var entityIndex = untouchableEntities.indexOf(entityID);
|
var entityIndex = untouchableEntities.indexOf(entityID);
|
||||||
if (disable) {
|
if (disable) {
|
||||||
|
@ -902,7 +910,7 @@
|
||||||
|
|
||||||
Script.update.connect(function () {
|
Script.update.connect(function () {
|
||||||
|
|
||||||
if (!handTouchEnabled) {
|
if (!handTouchEnabled || leapMotionEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue