1/****************************************************************************
2**
3** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QT3DINPUT_INPUT_INPUTHANDLER_P_H
41#define QT3DINPUT_INPUT_INPUTHANDLER_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists for the convenience
48// of other Qt classes. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <Qt3DInput/QKeyEvent>
55#include <Qt3DInput/qt3dinput_global.h>
56#include <Qt3DCore/qaspectjob.h>
57#include <QtCore/QMutex>
58
59#include <Qt3DInput/private/handle_types_p.h>
60
61QT_BEGIN_NAMESPACE
62
63namespace Qt3DCore {
64class QEventFilterService;
65class QNodeId;
66}
67
68namespace Qt3DInput {
69
70class QInputDeviceIntegration;
71class QAbstractPhysicalDevice;
72
73namespace Input {
74
75class AbstractActionInput;
76class KeyboardInputManager;
77class KeyboardDeviceManager;
78class KeyboardEventFilter;
79class MouseDeviceManager;
80class MouseInputManager;
81class MouseEventFilter;
82class AxisManager;
83class AxisAccumulatorManager;
84class ActionManager;
85class AxisSettingManager;
86class ActionInputManager;
87class AnalogAxisInputManager;
88class ButtonAxisInputManager;
89class InputChordManager;
90class InputSequenceManager;
91class LogicalDeviceManager;
92class GenericPhysicalDeviceManager;
93class GenericDeviceBackendNodeManager;
94class PhysicalDeviceProxyManager;
95class InputSettings;
96class EventSourceSetterHelper;
97
98class Q_AUTOTEST_EXPORT InputHandler
99{
100public:
101 InputHandler();
102 ~InputHandler();
103
104 inline KeyboardDeviceManager *keyboardDeviceManager() const { return m_keyboardDeviceManager; }
105 inline KeyboardInputManager *keyboardInputManager() const { return m_keyboardInputManager; }
106 inline MouseDeviceManager *mouseDeviceManager() const { return m_mouseDeviceManager; }
107 inline MouseInputManager *mouseInputManager() const { return m_mouseInputManager; }
108 inline AxisManager *axisManager() const { return m_axisManager; }
109 inline AxisAccumulatorManager *axisAccumulatorManager() const { return m_axisAccumulatorManager; }
110 inline ActionManager *actionManager() const { return m_actionManager; }
111 inline AxisSettingManager *axisSettingManager() const { return m_axisSettingManager; }
112 inline ActionInputManager *actionInputManager() const { return m_actionInputManager; }
113 inline AnalogAxisInputManager *analogAxisInputManager() const { return m_analogAxisInputManager; }
114 inline ButtonAxisInputManager *buttonAxisInputManager() const { return m_buttonAxisInputManager; }
115 inline InputChordManager *inputChordManager() const { return m_inputChordManager; }
116 inline InputSequenceManager *inputSequenceManager() const { return m_inputSequenceManager; }
117 inline LogicalDeviceManager *logicalDeviceManager() const { return m_logicalDeviceManager; }
118 inline GenericDeviceBackendNodeManager *genericDeviceBackendNodeManager() const { return m_genericPhysicalDeviceBackendNodeManager; }
119 inline PhysicalDeviceProxyManager *physicalDeviceProxyManager() const { return m_physicalDeviceProxyManager; }
120 inline InputSettings *inputSettings() const { return m_settings; }
121
122 void appendKeyEvent(const QT_PREPEND_NAMESPACE(QKeyEvent) &event);
123 QList<QT_PREPEND_NAMESPACE(QKeyEvent)> pendingKeyEvents();
124 void clearPendingKeyEvents();
125
126 void appendMouseEvent(const QT_PREPEND_NAMESPACE(QMouseEvent) &event);
127 QList<QT_PREPEND_NAMESPACE(QMouseEvent)> pendingMouseEvents();
128 void clearPendingMouseEvents();
129
130#if QT_CONFIG(wheelevent)
131 void appendWheelEvent(const QT_PREPEND_NAMESPACE(QWheelEvent) &event);
132 QList<QT_PREPEND_NAMESPACE(QWheelEvent)> pendingWheelEvents();
133 void clearPendingWheelEvents();
134#endif
135
136 void appendKeyboardDevice(HKeyboardDevice device);
137 void removeKeyboardDevice(HKeyboardDevice device);
138
139 void appendMouseDevice(HMouseDevice device);
140 void removeMouseDevice(HMouseDevice device);
141
142 void appendGenericDevice(HGenericDeviceBackendNode device);
143 void removeGenericDevice(HGenericDeviceBackendNode device);
144
145 QVector<Qt3DCore::QAspectJobPtr> keyboardJobs();
146 QVector<Qt3DCore::QAspectJobPtr> mouseJobs();
147
148 QVector<Qt3DInput::QInputDeviceIntegration *> inputDeviceIntegrations() const;
149 void addInputDeviceIntegration(QInputDeviceIntegration *inputIntegration);
150
151 void setInputSettings(InputSettings *settings);
152 void setEventSourceHelper(EventSourceSetterHelper *helper);
153 EventSourceSetterHelper *eventSourceHelper() const;
154
155 QAbstractPhysicalDevice *createPhysicalDevice(const QString &name);
156
157 void updateEventSource();
158
159 AbstractActionInput *lookupActionInput(Qt3DCore::QNodeId id) const;
160
161private:
162 KeyboardDeviceManager *m_keyboardDeviceManager;
163 KeyboardInputManager *m_keyboardInputManager;
164 MouseDeviceManager *m_mouseDeviceManager;
165 MouseInputManager *m_mouseInputManager;
166
167 QVector<HKeyboardDevice> m_activeKeyboardDevices;
168 QVector<HMouseDevice> m_activeMouseDevices;
169 QVector<HGenericDeviceBackendNode> m_activeGenericPhysicalDevices;
170 KeyboardEventFilter *m_keyboardEventFilter;
171 MouseEventFilter *m_mouseEventFilter;
172
173 QList<QT_PREPEND_NAMESPACE(QKeyEvent)> m_pendingKeyEvents;
174 QList<QT_PREPEND_NAMESPACE(QMouseEvent)> m_pendingMouseEvents;
175#if QT_CONFIG(wheelevent)
176 QList<QT_PREPEND_NAMESPACE(QWheelEvent)> m_pendingWheelEvents;
177#endif
178 mutable QMutex m_mutex;
179
180 AxisManager *m_axisManager;
181 AxisAccumulatorManager *m_axisAccumulatorManager;
182 ActionManager *m_actionManager;
183 AxisSettingManager *m_axisSettingManager;
184 ActionInputManager *m_actionInputManager;
185 AnalogAxisInputManager *m_analogAxisInputManager;
186 ButtonAxisInputManager *m_buttonAxisInputManager;
187 InputChordManager *m_inputChordManager;
188 InputSequenceManager *m_inputSequenceManager;
189 LogicalDeviceManager *m_logicalDeviceManager;
190 GenericDeviceBackendNodeManager *m_genericPhysicalDeviceBackendNodeManager;
191 PhysicalDeviceProxyManager *m_physicalDeviceProxyManager;
192 QVector<Qt3DInput::QInputDeviceIntegration *> m_inputDeviceIntegrations;
193 InputSettings *m_settings;
194 QScopedPointer<EventSourceSetterHelper> m_eventSourceSetter;
195
196 void registerEventFilters(Qt3DCore::QEventFilterService *service);
197 void unregisterEventFilters(Qt3DCore::QEventFilterService *service);
198 friend class EventSourceSetterHelper;
199};
200
201} // namespace Input
202} // namespace Qt3DInput
203
204QT_END_NAMESPACE
205
206#endif // QT3DINPUT_INPUT_INPUTHANDLER_P_H
207