1// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef GENERICDEVICEBACKENDNODE_H
5#define GENERICDEVICEBACKENDNODE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QHash>
19#include <QtCore/QMutex>
20
21#include <Qt3DInput/private/qabstractphysicaldevicebackendnode_p.h>
22
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DInput {
26
27class QAbstractPhysicalDevice;
28
29namespace Input {
30class InputHandler;
31class GenericDeviceBackendNodeData;
32class GenericDeviceBackendNode : public QAbstractPhysicalDeviceBackendNode
33{
34public:
35 explicit GenericDeviceBackendNode(QBackendNode::Mode mode = QBackendNode::ReadWrite);
36 ~GenericDeviceBackendNode();
37 void updateEvents();
38
39 // QAbstractPhysicalDeviceBackendNode interface
40 void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
41 void cleanup() override;
42 float axisValue(int axisIdentifier) const override;
43 bool isButtonPressed(int buttonIdentifier) const override;
44
45private:
46 QHash<int, qreal> m_axesValues;
47 QHash<int, qreal> m_buttonsValues;
48 mutable QMutex m_mutex;
49};
50
51class GenericDeviceBackendFunctor : public Qt3DCore::QBackendNodeMapper
52{
53public:
54 explicit GenericDeviceBackendFunctor(QInputAspect *inputaspect, InputHandler *handler);
55
56 Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const override;
57 Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const override;
58 void destroy(Qt3DCore::QNodeId id) const override;
59
60private:
61 QInputAspect *m_inputAspect;
62 InputHandler *m_handler;
63};
64
65} // namespace Input
66} // namespace Qt3DInput
67
68QT_END_NAMESPACE
69
70#endif // GENERICDEVICEBACKENDNODE_H
71

source code of qt3d/src/input/backend/genericdevicebackendnode_p.h