1// Copyright (C) 2014 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 QT3DINPUT_INPUT_INPUTHANDLER_P_H
5#define QT3DINPUT_INPUT_INPUTHANDLER_P_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 <Qt3DInput/QKeyEvent>
19#include <Qt3DInput/qt3dinput_global.h>
20#include <Qt3DCore/qaspectjob.h>
21#include <QtCore/QMutex>
22
23#include <Qt3DInput/private/handle_types_p.h>
24
25QT_BEGIN_NAMESPACE
26
27namespace Qt3DCore {
28class QEventFilterService;
29class QNodeId;
30class QScene;
31}
32
33namespace Qt3DInput {
34
35class QInputDeviceIntegration;
36class QAbstractPhysicalDevice;
37
38namespace Input {
39
40class AbstractActionInput;
41class KeyboardInputManager;
42class KeyboardDeviceManager;
43class MouseDeviceManager;
44class MouseInputManager;
45class InternalEventFilter;
46class AxisManager;
47class AxisAccumulatorManager;
48class ActionManager;
49class AxisSettingManager;
50class ActionInputManager;
51class AnalogAxisInputManager;
52class ButtonAxisInputManager;
53class InputChordManager;
54class InputSequenceManager;
55class LogicalDeviceManager;
56class GenericPhysicalDeviceManager;
57class GenericDeviceBackendNodeManager;
58class PhysicalDeviceProxyManager;
59class InputSettings;
60
61class Q_AUTOTEST_EXPORT InputHandler
62{
63public:
64 InputHandler();
65 ~InputHandler();
66
67 void setScene(Qt3DCore::QScene *scene) { m_scene = scene; }
68
69 inline KeyboardDeviceManager *keyboardDeviceManager() const { return m_keyboardDeviceManager; }
70 inline KeyboardInputManager *keyboardInputManager() const { return m_keyboardInputManager; }
71 inline MouseDeviceManager *mouseDeviceManager() const { return m_mouseDeviceManager; }
72 inline MouseInputManager *mouseInputManager() const { return m_mouseInputManager; }
73 inline AxisManager *axisManager() const { return m_axisManager; }
74 inline AxisAccumulatorManager *axisAccumulatorManager() const { return m_axisAccumulatorManager; }
75 inline ActionManager *actionManager() const { return m_actionManager; }
76 inline AxisSettingManager *axisSettingManager() const { return m_axisSettingManager; }
77 inline ActionInputManager *actionInputManager() const { return m_actionInputManager; }
78 inline AnalogAxisInputManager *analogAxisInputManager() const { return m_analogAxisInputManager; }
79 inline ButtonAxisInputManager *buttonAxisInputManager() const { return m_buttonAxisInputManager; }
80 inline InputChordManager *inputChordManager() const { return m_inputChordManager; }
81 inline InputSequenceManager *inputSequenceManager() const { return m_inputSequenceManager; }
82 inline LogicalDeviceManager *logicalDeviceManager() const { return m_logicalDeviceManager; }
83 inline GenericDeviceBackendNodeManager *genericDeviceBackendNodeManager() const { return m_genericPhysicalDeviceBackendNodeManager; }
84 inline PhysicalDeviceProxyManager *physicalDeviceProxyManager() const { return m_physicalDeviceProxyManager; }
85 inline InputSettings *inputSettings() const { return m_settings; }
86
87 void appendKeyboardDevice(HKeyboardDevice device);
88 void removeKeyboardDevice(HKeyboardDevice device);
89
90 void appendMouseDevice(HMouseDevice device);
91 void removeMouseDevice(HMouseDevice device);
92
93 void appendGenericDevice(HGenericDeviceBackendNode device);
94 void removeGenericDevice(HGenericDeviceBackendNode device);
95
96 void resetMouseAxisState();
97
98 QList<Qt3DInput::QInputDeviceIntegration *> inputDeviceIntegrations() const;
99 void addInputDeviceIntegration(QInputDeviceIntegration *inputIntegration);
100
101 void setInputSettings(InputSettings *settings);
102
103 QAbstractPhysicalDevice *createPhysicalDevice(const QString &name);
104
105 void updateEventSource();
106 void setEventFilterService(Qt3DCore::QEventFilterService *service);
107
108 AbstractActionInput *lookupActionInput(Qt3DCore::QNodeId id) const;
109
110private:
111 friend class InternalEventFilter;
112
113 Qt3DCore::QScene *m_scene;
114 KeyboardDeviceManager *m_keyboardDeviceManager;
115 KeyboardInputManager *m_keyboardInputManager;
116 MouseDeviceManager *m_mouseDeviceManager;
117 MouseInputManager *m_mouseInputManager;
118
119 QList<HKeyboardDevice> m_activeKeyboardDevices;
120 QList<HMouseDevice> m_activeMouseDevices;
121 QList<HGenericDeviceBackendNode> m_activeGenericPhysicalDevices;
122 InternalEventFilter *m_eventFilter;
123
124 AxisManager *m_axisManager;
125 AxisAccumulatorManager *m_axisAccumulatorManager;
126 ActionManager *m_actionManager;
127 AxisSettingManager *m_axisSettingManager;
128 ActionInputManager *m_actionInputManager;
129 AnalogAxisInputManager *m_analogAxisInputManager;
130 ButtonAxisInputManager *m_buttonAxisInputManager;
131 InputChordManager *m_inputChordManager;
132 InputSequenceManager *m_inputSequenceManager;
133 LogicalDeviceManager *m_logicalDeviceManager;
134 GenericDeviceBackendNodeManager *m_genericPhysicalDeviceBackendNodeManager;
135 PhysicalDeviceProxyManager *m_physicalDeviceProxyManager;
136 QList<Qt3DInput::QInputDeviceIntegration *> m_inputDeviceIntegrations;
137 InputSettings *m_settings;
138 Qt3DCore::QEventFilterService *m_service;
139 QObject *m_lastEventSource;
140
141 void registerEventFilters();
142 void unregisterEventFilters();
143};
144
145} // namespace Input
146} // namespace Qt3DInput
147
148QT_END_NAMESPACE
149
150#endif // QT3DINPUT_INPUT_INPUTHANDLER_P_H
151

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