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_KEYBOARDHANDLER_P_H
5#define QT3DINPUT_INPUT_KEYBOARDHANDLER_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.h>
19#include <Qt3DInput/private/backendnode_p.h>
20#include <Qt3DCore/qnodeid.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace Qt3DInput {
25
26namespace Input {
27
28class InputHandler;
29
30class Q_AUTOTEST_EXPORT KeyboardHandler : public BackendNode
31{
32public:
33 KeyboardHandler();
34
35 Qt3DCore::QNodeId keyboardDevice() const;
36 void setInputHandler(InputHandler *handler);
37 void setFocus(bool focus);
38
39 inline bool focus() const { return m_focus; }
40
41 void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
42
43protected:
44 void requestFocus();
45 void setSourcerDevice(Qt3DCore::QNodeId device);
46
47private:
48 InputHandler *m_inputHandler;
49 Qt3DCore::QNodeId m_keyboardDevice;
50 bool m_focus;
51};
52
53class KeyboardHandlerFunctor : public Qt3DCore::QBackendNodeMapper
54{
55public:
56 explicit KeyboardHandlerFunctor(InputHandler *handler);
57
58 Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const override;
59 Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const override;
60 void destroy(Qt3DCore::QNodeId id) const override;
61
62private:
63 InputHandler *m_handler;
64};
65
66} // namespace Input
67} // namespace Qt3DInput
68
69QT_END_NAMESPACE
70
71#endif // QT3DINPUT_INPUT_KEYBOARDHANDLER_P_H
72

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