| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef TESTDEVICEPROXY_H |
| 6 |
#define TESTDEVICEPROXY_H |
| 7 |
|
| 8 |
#include <Qt3DInput/private/qabstractphysicaldeviceproxy_p.h> |
| 9 |
#include <Qt3DInput/private/qabstractphysicaldeviceproxy_p_p.h> |
| 10 |
|
| 11 |
class TestPhysicalDevice : public Qt3DInput::QAbstractPhysicalDevice |
| 12 |
{ |
| 13 |
Q_OBJECT |
| 14 |
public: |
| 15 |
explicit TestPhysicalDevice(Qt3DCore::QNode *parent = nullptr) |
| 16 |
: Qt3DInput::QAbstractPhysicalDevice(parent) |
| 17 |
{} |
| 18 |
|
| 19 |
~TestPhysicalDevice() |
| 20 |
{ |
| 21 |
} |
| 22 |
|
| 23 |
enum AxisValues { |
| 24 |
X = 0, |
| 25 |
Y, |
| 26 |
Z |
| 27 |
}; |
| 28 |
|
| 29 |
enum ButtonValues { |
| 30 |
Left = 0, |
| 31 |
Right |
| 32 |
}; |
| 33 |
|
| 34 |
int axisCount() const final { return 3; } |
| 35 |
int buttonCount() const final { return 2; } |
| 36 |
QStringList axisNames() const final { return QStringList() << QStringLiteral("x") << QStringLiteral("y") << QStringLiteral("z"); } |
| 37 |
QStringList buttonNames() const final { return QStringList() << QStringLiteral("Left") << QStringLiteral("Right"); } |
| 38 |
|
| 39 |
int axisIdentifier(const QString &name) const final |
| 40 |
{ |
| 41 |
if (name == QLatin1String("x")) |
| 42 |
return TestPhysicalDevice::X; |
| 43 |
if (name == QLatin1String("y")) |
| 44 |
return TestPhysicalDevice::Y; |
| 45 |
if (name == QLatin1String("z")) |
| 46 |
return TestPhysicalDevice::Z; |
| 47 |
return -1; |
| 48 |
} |
| 49 |
int buttonIdentifier(const QString &name) const final |
| 50 |
{ |
| 51 |
if (name == QLatin1String("Left")) |
| 52 |
return TestPhysicalDevice::Left; |
| 53 |
if (name == QLatin1String("Right")) |
| 54 |
return TestPhysicalDevice::Right; |
| 55 |
return -1; |
| 56 |
} |
| 57 |
}; |
| 58 |
|
| 59 |
class TestProxyPrivate : public Qt3DInput::QAbstractPhysicalDeviceProxyPrivate |
| 60 |
{ |
| 61 |
public: |
| 62 |
explicit TestProxyPrivate(const QString &name) |
| 63 |
: Qt3DInput::QAbstractPhysicalDeviceProxyPrivate(name) |
| 64 |
{} |
| 65 |
}; |
| 66 |
|
| 67 |
class TestProxy : public Qt3DInput::QAbstractPhysicalDeviceProxy |
| 68 |
{ |
| 69 |
Q_OBJECT |
| 70 |
public: |
| 71 |
explicit TestProxy(const QString &name = QStringLiteral("TestProxy")) |
| 72 |
: Qt3DInput::QAbstractPhysicalDeviceProxy(*new TestProxyPrivate(name)) |
| 73 |
{} |
| 74 |
|
| 75 |
Qt3DInput::QAbstractPhysicalDevice *device() const |
| 76 |
{ |
| 77 |
Q_D(const TestProxy); |
| 78 |
return d->m_device; |
| 79 |
} |
| 80 |
|
| 81 |
void setDevice(TestPhysicalDevice *device) |
| 82 |
{ |
| 83 |
Q_D(TestProxy); |
| 84 |
d->setDevice(device); |
| 85 |
} |
| 86 |
|
| 87 |
private: |
| 88 |
Q_DECLARE_PRIVATE(TestProxy) |
| 89 |
}; |
| 90 |
|
| 91 |
#endif |