diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-12-03 16:10:55 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-12-07 19:06:54 +0000 |
commit | dde3c565835a9ddd0edf980728db4f6ff7393160 (patch) | |
tree | 504e1479d28c66e87b973e6fb74831ba95ab39c1 /src/input/frontend | |
parent | f6ff4023e42bec8cfe088f27c17f7d309f0a9003 (diff) |
QMouseController: converted to QAbstractPhysicalDevice
Change-Id: I532e7378fe459ec201629b3ec3f0c9a69acf691f
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input/frontend')
-rw-r--r-- | src/input/frontend/qmousecontroller.cpp | 52 | ||||
-rw-r--r-- | src/input/frontend/qmousecontroller.h | 25 | ||||
-rw-r--r-- | src/input/frontend/qmousecontroller_p.h | 4 |
3 files changed, 72 insertions, 9 deletions
diff --git a/src/input/frontend/qmousecontroller.cpp b/src/input/frontend/qmousecontroller.cpp index 461296056..1ec91ec9b 100644 --- a/src/input/frontend/qmousecontroller.cpp +++ b/src/input/frontend/qmousecontroller.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DInput { QMouseControllerPrivate::QMouseControllerPrivate() - : QNodePrivate() + : QAbstractPhysicalDevicePrivate() { } @@ -60,7 +60,7 @@ QMouseControllerPrivate::QMouseControllerPrivate() * \sa QMouseInput */ QMouseController::QMouseController(QNode *parent) - : QNode(*new QMouseControllerPrivate, parent) + : QAbstractPhysicalDevice(*new QMouseControllerPrivate, parent) { } @@ -68,7 +68,7 @@ QMouseController::QMouseController(QNode *parent) \internal */ QMouseController::QMouseController(QMouseControllerPrivate &dd, QNode *parent) - : QNode(dd, parent) + : QAbstractPhysicalDevice(dd, parent) { } @@ -80,6 +80,52 @@ QMouseController::~QMouseController() QNode::cleanup(); } +int QMouseController::axisCount() const +{ + // TO DO: we could have mouse wheel later on + return 2; +} + +int QMouseController::buttonCount() const +{ + return 3; +} + +QStringList QMouseController::axisNames() const +{ + return QStringList() + << QStringLiteral("X") + << QStringLiteral("Y"); +} + +QStringList QMouseController::buttonNames() const +{ + return QStringList() + << QStringLiteral("Left") + << QStringLiteral("Right") + << QStringLiteral("Center"); +} + +int QMouseController::axisIdentifier(const QString &name) +{ + if (name == QStringLiteral("X")) + return X; + else if (name == QStringLiteral("Y")) + return Y; + return -1; +} + +int QMouseController::buttonIdentifier(const QString &name) +{ + if (name == QStringLiteral("Left")) + return Left; + else if (name == QStringLiteral("Right")) + return Right; + else if (name == QStringLiteral("Center")) + return Center; + return -1; +} + void QMouseController::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) { Q_UNUSED(change); diff --git a/src/input/frontend/qmousecontroller.h b/src/input/frontend/qmousecontroller.h index a0de94db1..b7be253f8 100644 --- a/src/input/frontend/qmousecontroller.h +++ b/src/input/frontend/qmousecontroller.h @@ -38,7 +38,7 @@ #define QT3DINPUT_QMOUSECONTROLLER_H #include <Qt3DInput/qt3dinput_global.h> -#include <Qt3DCore/qnode.h> +#include <Qt3DInput/qabstractphysicaldevice.h> QT_BEGIN_NAMESPACE @@ -47,16 +47,33 @@ namespace Qt3DInput { class QMouseControllerPrivate; class QMouseInput; -class QT3DINPUTSHARED_EXPORT QMouseController : public Qt3DCore::QNode +class QT3DINPUTSHARED_EXPORT QMouseController : public Qt3DInput::QAbstractPhysicalDevice { Q_OBJECT - public: explicit QMouseController(Qt3DCore::QNode *parent = 0); + ~QMouseController(); + + enum Axis { + X, + Y + }; + + enum Button { + Left, + Center, + Right + }; + + int axisCount() const Q_DECL_FINAL; + int buttonCount() const Q_DECL_FINAL; + QStringList axisNames() const Q_DECL_FINAL; + QStringList buttonNames() const Q_DECL_FINAL; + int axisIdentifier(const QString &name) Q_DECL_FINAL; + int buttonIdentifier(const QString &name) Q_DECL_FINAL; protected: QMouseController(QMouseControllerPrivate &dd, Qt3DCore::QNode *parent = 0); - ~QMouseController(); void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE; diff --git a/src/input/frontend/qmousecontroller_p.h b/src/input/frontend/qmousecontroller_p.h index c04971af3..efffdf51b 100644 --- a/src/input/frontend/qmousecontroller_p.h +++ b/src/input/frontend/qmousecontroller_p.h @@ -48,7 +48,7 @@ // We mean it. // -#include <private/qnode_p.h> +#include <private/qabstractphysicaldevice_p.h> QT_BEGIN_NAMESPACE @@ -56,7 +56,7 @@ namespace Qt3DInput { class QMouseController; -class QMouseControllerPrivate : public Qt3DCore::QNodePrivate +class QMouseControllerPrivate : public Qt3DInput::QAbstractPhysicalDevicePrivate { public: QMouseControllerPrivate(); |