| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | |
| 30 | #ifndef TESTDEVICEPROXY_H |
| 31 | #define TESTDEVICEPROXY_H |
| 32 | |
| 33 | #include <Qt3DInput/private/qabstractphysicaldeviceproxy_p.h> |
| 34 | #include <Qt3DInput/private/qabstractphysicaldeviceproxy_p_p.h> |
| 35 | |
| 36 | class TestPhysicalDevice : public Qt3DInput::QAbstractPhysicalDevice |
| 37 | { |
| 38 | Q_OBJECT |
| 39 | public: |
| 40 | explicit TestPhysicalDevice(Qt3DCore::QNode *parent = nullptr) |
| 41 | : Qt3DInput::QAbstractPhysicalDevice(parent) |
| 42 | {} |
| 43 | |
| 44 | ~TestPhysicalDevice() |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | enum AxisValues { |
| 49 | X = 0, |
| 50 | Y, |
| 51 | Z |
| 52 | }; |
| 53 | |
| 54 | enum ButtonValues { |
| 55 | Left = 0, |
| 56 | Right |
| 57 | }; |
| 58 | |
| 59 | int axisCount() const final { return 3; } |
| 60 | int buttonCount() const final { return 2; } |
| 61 | QStringList axisNames() const final { return QStringList() << QStringLiteral("x") << QStringLiteral( "y") << QStringLiteral( "z"); } |
| 62 | QStringList buttonNames() const final { return QStringList() << QStringLiteral("Left") << QStringLiteral( "Right"); } |
| 63 | |
| 64 | int axisIdentifier(const QString &name) const final |
| 65 | { |
| 66 | if (name == QLatin1String("x")) |
| 67 | return TestPhysicalDevice::X; |
| 68 | if (name == QLatin1String("y")) |
| 69 | return TestPhysicalDevice::Y; |
| 70 | if (name == QLatin1String("z")) |
| 71 | return TestPhysicalDevice::Z; |
| 72 | return -1; |
| 73 | } |
| 74 | int buttonIdentifier(const QString &name) const final |
| 75 | { |
| 76 | if (name == QLatin1String("Left")) |
| 77 | return TestPhysicalDevice::Left; |
| 78 | if (name == QLatin1String("Right")) |
| 79 | return TestPhysicalDevice::Right; |
| 80 | return -1; |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | class TestProxyPrivate : public Qt3DInput::QAbstractPhysicalDeviceProxyPrivate |
| 85 | { |
| 86 | public: |
| 87 | explicit TestProxyPrivate(const QString &name) |
| 88 | : Qt3DInput::QAbstractPhysicalDeviceProxyPrivate(name) |
| 89 | {} |
| 90 | }; |
| 91 | |
| 92 | class TestProxy : public Qt3DInput::QAbstractPhysicalDeviceProxy |
| 93 | { |
| 94 | Q_OBJECT |
| 95 | public: |
| 96 | explicit TestProxy(const QString &name = QStringLiteral("TestProxy")) |
| 97 | : Qt3DInput::QAbstractPhysicalDeviceProxy(*new TestProxyPrivate(name)) |
| 98 | {} |
| 99 | |
| 100 | Qt3DInput::QAbstractPhysicalDevice *device() const |
| 101 | { |
| 102 | Q_D(const TestProxy); |
| 103 | return d->m_device; |
| 104 | } |
| 105 | |
| 106 | void setDevice(TestPhysicalDevice *device) |
| 107 | { |
| 108 | Q_D(TestProxy); |
| 109 | d->setDevice(device); |
| 110 | } |
| 111 | |
| 112 | private: |
| 113 | Q_DECLARE_PRIVATE(TestProxy) |
| 114 | }; |
| 115 | |
| 116 | #endif // TESTDEVICEPROXY_H |
| 117 |
