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 | #ifndef QT3DINPUT_INPUT_BUTTONAXISINPUT_H |
5 | #define QT3DINPUT_INPUT_BUTTONAXISINPUT_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/private/abstractaxisinput_p.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | namespace Qt3DInput { |
23 | |
24 | namespace Input { |
25 | |
26 | class Q_AUTOTEST_EXPORT ButtonAxisInput : public AbstractAxisInput |
27 | { |
28 | public: |
29 | enum UpdateType { |
30 | Accelerate, |
31 | Decelerate |
32 | }; |
33 | |
34 | ButtonAxisInput(); |
35 | void cleanup() final; |
36 | |
37 | inline float scale() const { return m_scale; } |
38 | inline QList<int> buttons() const { return m_buttons; } |
39 | |
40 | inline float acceleration() const { return m_acceleration < 0.0f ? qInf() : m_acceleration; } |
41 | inline float deceleration() const { return m_deceleration < 0.0f ? qInf() : m_deceleration; } |
42 | inline float speedRatio() const { return m_speedRatio; } |
43 | inline qint64 lastUpdateTime() const { return m_lastUpdateTime; } |
44 | |
45 | void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) final; |
46 | |
47 | float process(InputHandler *inputHandler, qint64 currentTime) override; |
48 | |
49 | private: |
50 | void updateSpeedRatio(qint64 currentTime, UpdateType type); |
51 | |
52 | QList<int> m_buttons; |
53 | float m_scale; |
54 | float m_acceleration; |
55 | float m_deceleration; |
56 | float m_speedRatio; |
57 | qint64 m_lastUpdateTime; |
58 | }; |
59 | |
60 | } // namespace Input |
61 | |
62 | } // namespace Qt3DInput |
63 | |
64 | QT_END_NAMESPACE |
65 | |
66 | #endif // QT3DINPUT_INPUT_BUTTONAXISINPUT_H |
67 | |