1 | // Copyright (C) 2015 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 | #include "logicaldevice_p.h" |
5 | |
6 | #include <Qt3DInput/qaction.h> |
7 | #include <Qt3DInput/qaxis.h> |
8 | #include <Qt3DInput/qlogicaldevice.h> |
9 | |
10 | #include <Qt3DInput/private/inputmanagers_p.h> |
11 | #include <Qt3DInput/private/qlogicaldevice_p.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | namespace Qt3DInput { |
16 | |
17 | namespace Input { |
18 | |
19 | LogicalDevice::LogicalDevice() |
20 | : BackendNode() |
21 | { |
22 | } |
23 | |
24 | void LogicalDevice::cleanup() |
25 | { |
26 | QBackendNode::setEnabled(false); |
27 | m_actions.clear(); |
28 | m_axes.clear(); |
29 | } |
30 | |
31 | void LogicalDevice::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
32 | { |
33 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
34 | const QLogicalDevice *node = qobject_cast<const QLogicalDevice *>(object: frontEnd); |
35 | if (!node) |
36 | return; |
37 | |
38 | m_actions = Qt3DCore::qIdsForNodes(nodes: node->actions()); |
39 | m_axes = Qt3DCore::qIdsForNodes(nodes: node->axes()); |
40 | } |
41 | |
42 | LogicalDeviceNodeFunctor::LogicalDeviceNodeFunctor(LogicalDeviceManager *manager) |
43 | : m_manager(manager) |
44 | { |
45 | } |
46 | |
47 | Qt3DCore::QBackendNode *LogicalDeviceNodeFunctor::create(Qt3DCore::QNodeId id) const |
48 | { |
49 | HLogicalDevice handle = m_manager->getOrAcquireHandle(id); |
50 | LogicalDevice *backend = m_manager->data(handle); |
51 | m_manager->addActiveDevice(device: handle); |
52 | return backend; |
53 | } |
54 | |
55 | Qt3DCore::QBackendNode *LogicalDeviceNodeFunctor::get(Qt3DCore::QNodeId id) const |
56 | { |
57 | return m_manager->lookupResource(id); |
58 | } |
59 | |
60 | void LogicalDeviceNodeFunctor::destroy(Qt3DCore::QNodeId id) const |
61 | { |
62 | HLogicalDevice handle = m_manager->lookupHandle(id); |
63 | m_manager->releaseResource(id); |
64 | m_manager->removeActiveDevice(device: handle); |
65 | } |
66 | |
67 | } // namespace Input |
68 | |
69 | } // namespace Qt3DInput |
70 | |
71 | QT_END_NAMESPACE |
72 |