diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-11-06 16:13:45 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-11-16 11:18:01 +0000 |
commit | 5e7b2761f20818459c7fa2960aab74b16dfdb085 (patch) | |
tree | 60919852e8f009eb18ecfc7cce2dc45b34623a86 /src/input | |
parent | 2a434eb4431341d223bed40e75ef5f144446fda4 (diff) |
Qt3DInput: add QInputDeviceFactory and QInputDevicePlugin
Change-Id: Ic137060c4ab37fdff46f97066a3f24b763a7d1ac
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/input.pri | 8 | ||||
-rw-r--r-- | src/input/qinputdevicefactory.cpp | 93 | ||||
-rw-r--r-- | src/input/qinputdevicefactory_p.h | 71 | ||||
-rw-r--r-- | src/input/qinputdeviceplugin.cpp | 61 | ||||
-rw-r--r-- | src/input/qinputdeviceplugin.h | 68 |
5 files changed, 299 insertions, 2 deletions
diff --git a/src/input/input.pri b/src/input/input.pri index b730a4d2b..ec2b1b02e 100644 --- a/src/input/input.pri +++ b/src/input/input.pri @@ -24,7 +24,9 @@ HEADERS += \ $$PWD/mouseinput_p.h \ $$PWD/mouseeventdispatcherjob_p.h \ $$PWD/mouseeventfilter_p.h \ - $$PWD/qabstractinputdevice.h + $$PWD/qabstractinputdevice.h \ + $$PWD/qinputdevicefactory_p.h \ + $$PWD/qinputdeviceplugin.h SOURCES += \ $$PWD/cameracontroller.cpp \ @@ -44,6 +46,8 @@ SOURCES += \ $$PWD/mousecontroller.cpp \ $$PWD/mouseinput.cpp \ $$PWD/mouseeventfilter.cpp \ - $$PWD/mouseeventdispatcherjob.cpp + $$PWD/mouseeventdispatcherjob.cpp \ + $$PWD/qinputdevicefactory.cpp \ + $$PWD/qinputdeviceplugin.cpp INCLUDEPATH += $$PWD diff --git a/src/input/qinputdevicefactory.cpp b/src/input/qinputdevicefactory.cpp new file mode 100644 index 000000000..e5896b4ff --- /dev/null +++ b/src/input/qinputdevicefactory.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qinputdevicefactory_p.h" +#include <Qt3DInput/qabstractinputdevice.h> +#include <Qt3DInput/qinputdeviceplugin.h> +#include <QtCore/private/qfactoryloader_p.h> +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +#ifndef QT_NO_LIBRARY +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QInputDevice_iid, QLatin1String("/inputdevices"), Qt::CaseInsensitive)) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QInputDevice_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif + +QStringList QInputDeviceFactory::keys(const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + QStringList list; + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + list = directLoader()->keyMap().values(); + if (!list.isEmpty()) { + const QString postFix = QStringLiteral(" (from ") + + QDir::toNativeSeparators(pluginPath) + + QLatin1Char(')'); + const QStringList::iterator end = list.end(); + for (QStringList::iterator it = list.begin(); it != end; ++it) + (*it).append(postFix); + } + } + list.append(loader()->keyMap().values()); + return list; +#else + return QStringList(); +#endif +} + +QAbstractInputDevice *QInputDeviceFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + if (QAbstractInputDevice *ret = qLoadPlugin1<QAbstractInputDevice, QInputDevicePlugin>(directLoader(), name, args)) + return ret; + } + if (QAbstractInputDevice *ret = qLoadPlugin1<QAbstractInputDevice, QInputDevicePlugin>(loader(), name, args)) + return ret; +#endif + return Q_NULLPTR; +} + +} // Qt3DInput + +QT_END_NAMESPACE + diff --git a/src/input/qinputdevicefactory_p.h b/src/input/qinputdevicefactory_p.h new file mode 100644 index 000000000..62eef0d18 --- /dev/null +++ b/src/input/qinputdevicefactory_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QINPUTDEVICEFACTORY_P_H +#define QT3DINPUT_QINPUTDEVICEFACTORY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DInput/qt3dinput_global.h> +#include <QtCore/QStringList> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +class QAbstractInputDevice; + +class QInputDeviceFactory +{ +public: + static QStringList keys(const QString &pluginPath = QString()); + static QAbstractInputDevice *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); +}; + +} // Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QINPUTDEVICEFACTORY_P_H diff --git a/src/input/qinputdeviceplugin.cpp b/src/input/qinputdeviceplugin.cpp new file mode 100644 index 000000000..7afdb848e --- /dev/null +++ b/src/input/qinputdeviceplugin.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qinputdeviceplugin.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +QInputDevicePlugin::QInputDevicePlugin(QObject *parent) + : QObject(parent) +{ +} + +QInputDevicePlugin::~QInputDevicePlugin() +{ +} + +QAbstractInputDevice *QInputDevicePlugin::create(const QString &key, const QStringList ¶mList) +{ + Q_UNUSED(key) + Q_UNUSED(paramList) + return Q_NULLPTR; +} + +} // Qt3DInput + +QT_END_NAMESPACE diff --git a/src/input/qinputdeviceplugin.h b/src/input/qinputdeviceplugin.h new file mode 100644 index 000000000..ea73eb312 --- /dev/null +++ b/src/input/qinputdeviceplugin.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QINPUTDEVICEPLUGIN_H +#define QT3DINPUT_QINPUTDEVICEPLUGIN_H + +#include <QtCore/QObject> +#include <QtCore/QtPlugin> +#include <QtCore/QFactoryInterface> + +#include <Qt3DInput/qt3dinput_global.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +#define QInputDevice_iid "org.qt-project.Qt3DInput.QAbstractInputDevice 5.6" + +class QAbstractInputDevice; + +class QT3DINPUTSHARED_EXPORT QInputDevicePlugin : public QObject +{ + Q_OBJECT +public: + explicit QInputDevicePlugin(QObject *parent = Q_NULLPTR); + ~QInputDevicePlugin(); + + virtual QAbstractInputDevice *create(const QString &key, const QStringList ¶mList); +}; + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QINPUTDEVICEPLUGIN_H |