diff --git a/interface/external/leapmotion/readme.txt b/interface/external/leapmotion/readme.txt index 51a65caf22..97502d694c 100644 --- a/interface/external/leapmotion/readme.txt +++ b/interface/external/leapmotion/readme.txt @@ -10,7 +10,7 @@ Interface has been tested with SDK versions: 1. Copy the LeapSDK folders from the LeapDeveloperKit installation directory (Lib, Include) into the interface/externals/leapmotion folder. This readme.txt should be there as well. - The files neeeded in the folders are: + The files needed in the folders are: include/ - Leap.h @@ -21,8 +21,8 @@ Interface has been tested with SDK versions: x86/ - Leap.dll - Leap.lib - - mscvcp120.dll (optional if you already have the Msdev 2012 SDK redistriuable installed) - - mscvcr120.dll (optional if you already have the Msdev 2012 SDK redistriuable installed) + - mscvcp120.dll (optional if you already have the Msdev 2012 SDK redistributable installed) + - mscvcr120.dll (optional if you already have the Msdev 2012 SDK redistributable installed) - lipLeap.dylib libc++/ -libLeap.dylib @@ -30,4 +30,4 @@ Interface has been tested with SDK versions: You may optionally choose to copy the SDK folders to a location outside the repository (so you can re-use with different checkouts and different projects). If so our CMake find module expects you to set the ENV variable 'HIFI_LIB_DIR' to a directory containing a subfolder 'leapmotion' that contains the 2 folders mentioned above (Include, Lib). -2. Clear your build directory, run cmake and build, and you should be all set. \ No newline at end of file +2. Clear your build directory, run cmake and build, and you should be all set. diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 82ca2a7d38..06cf929368 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -30,6 +30,8 @@ if (NOT SERVER_ONLY AND NOT ANDROID) add_subdirectory(${DIR}) set(DIR "steamClient") add_subdirectory(${DIR}) + set(DIR "hifiLeapMotion") + add_subdirectory(${DIR}) endif() # server-side plugins diff --git a/plugins/hifiLeapMotion/CMakeLists.txt b/plugins/hifiLeapMotion/CMakeLists.txt new file mode 100644 index 0000000000..ee2fb22f0e --- /dev/null +++ b/plugins/hifiLeapMotion/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Created by David Rowe on 15 Jun 2017. +# Copyright 2017 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html +# + +if (WIN32) + find_package(LEAPMOTION) + if (LEAPMOTION_FOUND) + set(TARGET_NAME hifiLeapMotion) + setup_hifi_plugin(Script Qml Widgets) + link_hifi_libraries(shared controllers ui plugins input-plugins) + endif() +endif() diff --git a/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp b/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp new file mode 100644 index 0000000000..412ff492f9 --- /dev/null +++ b/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp @@ -0,0 +1,25 @@ +// +// LeapMotionPlugin.cpp +// +// Created by David Rowe on 15 Jun 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "LeapMotionPlugin.h" + +const char* LeapMotionPlugin::NAME = "Leap Motion"; + +void LeapMotionPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { + // TODO +} + +controller::Input::NamedVector LeapMotionPlugin::InputDevice::getAvailableInputs() const { + static controller::Input::NamedVector availableInputs; + + // TODO + + return availableInputs; +} diff --git a/plugins/hifiLeapMotion/src/LeapMotionPlugin.h b/plugins/hifiLeapMotion/src/LeapMotionPlugin.h new file mode 100644 index 0000000000..f8a4aae173 --- /dev/null +++ b/plugins/hifiLeapMotion/src/LeapMotionPlugin.h @@ -0,0 +1,42 @@ +// +// LeapMotionPlugin.h +// +// Created by David Rowe on 15 Jun 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_LeapMotionPlugin_h +#define hifi_LeapMotionPlugin_h + +#include +#include + +class LeapMotionPlugin : public InputPlugin { + Q_OBJECT + +public: + virtual const QString getName() const override { return NAME; } + + virtual void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); } + virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override; + +protected: + static const char* NAME; + + class InputDevice : public controller::InputDevice { + public: + friend class LeapMotionPlugin; + + InputDevice() : controller::InputDevice("Leap Motion") {} + + // Device functions + virtual controller::Input::NamedVector getAvailableInputs() const override; + }; + + std::shared_ptr _inputDevice{ std::make_shared() }; +}; + +#endif // hifi_LeapMotionPlugin_h diff --git a/plugins/hifiLeapMotion/src/LeapMotionProvider.cpp b/plugins/hifiLeapMotion/src/LeapMotionProvider.cpp new file mode 100644 index 0000000000..62517439c3 --- /dev/null +++ b/plugins/hifiLeapMotion/src/LeapMotionProvider.cpp @@ -0,0 +1,51 @@ +// +// LeapMotionProvider.cpp +// +// Created by David Rowe on 15 Jun 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +#include +#include +#include + +#include +#include + +#include "LeapMotionPlugin.h" + +class LeapMotionProvider : public QObject, public InputProvider +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID InputProvider_iid FILE "plugin.json") + Q_INTERFACES(InputProvider) + +public: + LeapMotionProvider(QObject* parent = nullptr) : QObject(parent) {} + virtual ~LeapMotionProvider() {} + + virtual InputPluginList getInputPlugins() override { + static std::once_flag once; + std::call_once(once, [&] { + InputPluginPointer plugin(new LeapMotionPlugin()); + if (plugin->isSupported()) { + _inputPlugins.push_back(plugin); + } + }); + return _inputPlugins; + } + + virtual void destroyInputPlugins() override { + _inputPlugins.clear(); + } + +private: + InputPluginList _inputPlugins; +}; + +#include "LeapMotionProvider.moc" diff --git a/plugins/hifiLeapMotion/src/plugin.json b/plugins/hifiLeapMotion/src/plugin.json new file mode 100644 index 0000000000..2e867d96e4 --- /dev/null +++ b/plugins/hifiLeapMotion/src/plugin.json @@ -0,0 +1 @@ +{"name":"Leap Motion"}