|
| 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" |
0 commit comments