Skip to content

Commit 9c431a1

Browse files
committed
Set up Leap Motion plugin container
1 parent a8501a7 commit 9c431a1

File tree

7 files changed

+141
-4
lines changed

7 files changed

+141
-4
lines changed

interface/external/leapmotion/readme.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Interface has been tested with SDK versions:
1010
1. Copy the LeapSDK folders from the LeapDeveloperKit installation directory (Lib, Include) into the interface/externals/leapmotion folder.
1111
This readme.txt should be there as well.
1212

13-
The files neeeded in the folders are:
13+
The files needed in the folders are:
1414

1515
include/
1616
- Leap.h
@@ -21,13 +21,13 @@ Interface has been tested with SDK versions:
2121
x86/
2222
- Leap.dll
2323
- Leap.lib
24-
- mscvcp120.dll (optional if you already have the Msdev 2012 SDK redistriuable installed)
25-
- mscvcr120.dll (optional if you already have the Msdev 2012 SDK redistriuable installed)
24+
- mscvcp120.dll (optional if you already have the Msdev 2012 SDK redistributable installed)
25+
- mscvcr120.dll (optional if you already have the Msdev 2012 SDK redistributable installed)
2626
- lipLeap.dylib
2727
libc++/
2828
-libLeap.dylib
2929

3030
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).
3131
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).
3232

33-
2. Clear your build directory, run cmake and build, and you should be all set.
33+
2. Clear your build directory, run cmake and build, and you should be all set.

plugins/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ if (NOT SERVER_ONLY AND NOT ANDROID)
3030
add_subdirectory(${DIR})
3131
set(DIR "steamClient")
3232
add_subdirectory(${DIR})
33+
set(DIR "hifiLeapMotion")
34+
add_subdirectory(${DIR})
3335
endif()
3436

3537
# server-side plugins

plugins/hifiLeapMotion/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Created by David Rowe on 15 Jun 2017.
3+
# Copyright 2017 High Fidelity, Inc.
4+
#
5+
# Distributed under the Apache License, Version 2.0.
6+
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
7+
#
8+
9+
if (WIN32)
10+
find_package(LEAPMOTION)
11+
if (LEAPMOTION_FOUND)
12+
set(TARGET_NAME hifiLeapMotion)
13+
setup_hifi_plugin(Script Qml Widgets)
14+
link_hifi_libraries(shared controllers ui plugins input-plugins)
15+
endif()
16+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// LeapMotionPlugin.cpp
3+
//
4+
// Created by David Rowe on 15 Jun 2017.
5+
// Copyright 2017 High Fidelity, Inc.
6+
//
7+
// Distributed under the Apache License, Version 2.0.
8+
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9+
//
10+
11+
#include "LeapMotionPlugin.h"
12+
13+
const char* LeapMotionPlugin::NAME = "Leap Motion";
14+
15+
void LeapMotionPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
16+
// TODO
17+
}
18+
19+
controller::Input::NamedVector LeapMotionPlugin::InputDevice::getAvailableInputs() const {
20+
static controller::Input::NamedVector availableInputs;
21+
22+
// TODO
23+
24+
return availableInputs;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// LeapMotionPlugin.h
3+
//
4+
// Created by David Rowe on 15 Jun 2017.
5+
// Copyright 2017 High Fidelity, Inc.
6+
//
7+
// Distributed under the Apache License, Version 2.0.
8+
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9+
//
10+
11+
#ifndef hifi_LeapMotionPlugin_h
12+
#define hifi_LeapMotionPlugin_h
13+
14+
#include <controllers/InputDevice.h>
15+
#include <plugins/InputPlugin.h>
16+
17+
class LeapMotionPlugin : public InputPlugin {
18+
Q_OBJECT
19+
20+
public:
21+
virtual const QString getName() const override { return NAME; }
22+
23+
virtual void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); }
24+
virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
25+
26+
protected:
27+
static const char* NAME;
28+
29+
class InputDevice : public controller::InputDevice {
30+
public:
31+
friend class LeapMotionPlugin;
32+
33+
InputDevice() : controller::InputDevice("Leap Motion") {}
34+
35+
// Device functions
36+
virtual controller::Input::NamedVector getAvailableInputs() const override;
37+
};
38+
39+
std::shared_ptr<InputDevice> _inputDevice{ std::make_shared<InputDevice>() };
40+
};
41+
42+
#endif // hifi_LeapMotionPlugin_h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// LeapMotionProvider.cpp
3+
//
4+
// Created by David Rowe on 15 Jun 2017.
5+
// Copyright 2017 High Fidelity, Inc.
6+
//
7+
// Distributed under the Apache License, Version 2.0.
8+
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9+
//
10+
11+
#include <mutex>
12+
13+
#include <QtCore/QObject>
14+
#include <QtCore/QtPlugin>
15+
#include <QtCore/QStringList>
16+
17+
#include <plugins/RuntimePlugin.h>
18+
#include <plugins/InputPlugin.h>
19+
20+
#include "LeapMotionPlugin.h"
21+
22+
class LeapMotionProvider : public QObject, public InputProvider
23+
{
24+
Q_OBJECT
25+
Q_PLUGIN_METADATA(IID InputProvider_iid FILE "plugin.json")
26+
Q_INTERFACES(InputProvider)
27+
28+
public:
29+
LeapMotionProvider(QObject* parent = nullptr) : QObject(parent) {}
30+
virtual ~LeapMotionProvider() {}
31+
32+
virtual InputPluginList getInputPlugins() override {
33+
static std::once_flag once;
34+
std::call_once(once, [&] {
35+
InputPluginPointer plugin(new LeapMotionPlugin());
36+
if (plugin->isSupported()) {
37+
_inputPlugins.push_back(plugin);
38+
}
39+
});
40+
return _inputPlugins;
41+
}
42+
43+
virtual void destroyInputPlugins() override {
44+
_inputPlugins.clear();
45+
}
46+
47+
private:
48+
InputPluginList _inputPlugins;
49+
};
50+
51+
#include "LeapMotionProvider.moc"
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Leap Motion"}

0 commit comments

Comments
 (0)