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#include "inputsettings_p.h"
5
6#include <Qt3DInput/qinputsettings.h>
7
8#include <Qt3DInput/private/inputhandler_p.h>
9#include <Qt3DInput/private/qinputsettings_p.h>
10
11QT_BEGIN_NAMESPACE
12
13namespace Qt3DInput {
14
15namespace Input {
16
17InputSettings::InputSettings()
18 : BackendNode(QBackendNode::ReadOnly)
19 , m_eventSource(nullptr)
20{
21}
22
23void InputSettings::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
24{
25 BackendNode::syncFromFrontEnd(frontEnd, firstTime);
26 const QInputSettings *node = qobject_cast<const QInputSettings *>(object: frontEnd);
27 if (!node)
28 return;
29
30 m_eventSource = node->eventSource();
31}
32
33InputSettingsFunctor::InputSettingsFunctor(InputHandler *handler)
34 : m_handler(handler)
35{
36}
37
38Qt3DCore::QBackendNode *InputSettingsFunctor::create(Qt3DCore::QNodeId id) const
39{
40 Q_UNUSED(id);
41 if (m_handler->inputSettings() != nullptr) {
42 qWarning() << "Input settings already specified";
43 return nullptr;
44 }
45
46 InputSettings *settings = new InputSettings();
47 m_handler->setInputSettings(settings);
48 return settings;
49}
50
51Qt3DCore::QBackendNode *InputSettingsFunctor::get(Qt3DCore::QNodeId id) const
52{
53 InputSettings *settings = m_handler->inputSettings();
54 if (settings != nullptr && settings->peerId() == id)
55 return settings;
56 return nullptr;
57}
58
59void InputSettingsFunctor::destroy(Qt3DCore::QNodeId id) const
60{
61 InputSettings *settings = m_handler->inputSettings();
62 if (settings != nullptr && settings->peerId() == id) {
63 m_handler->setInputSettings(nullptr);
64 delete settings;
65 }
66}
67
68} // Input
69
70} // Qt3DInput
71
72QT_END_NAMESPACE
73

source code of qt3d/src/input/backend/inputsettings.cpp