1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Gamepad module
7**
8** $QT_BEGIN_LICENSE:LGPL3$
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 http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QGAMEPADKEYNAVIGATION_H
38#define QGAMEPADKEYNAVIGATION_H
39
40#include <QtCore/QObject>
41#include <QtCore/QMap>
42#include <QtGamepad/qtgamepadglobal.h>
43
44#include <QtGamepad/QGamepadManager>
45
46QT_BEGIN_NAMESPACE
47
48class QKeyEvent;
49class QGamepad;
50class QGamepadKeyNavigationPrivate;
51class Q_GAMEPAD_EXPORT QGamepadKeyNavigation : public QObject
52{
53 Q_OBJECT
54 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
55 Q_PROPERTY(QGamepad *gamepad READ gamepad WRITE setGamepad NOTIFY gamepadChanged)
56 Q_PROPERTY(Qt::Key upKey READ upKey WRITE setUpKey NOTIFY upKeyChanged)
57 Q_PROPERTY(Qt::Key downKey READ downKey WRITE setDownKey NOTIFY downKeyChanged)
58 Q_PROPERTY(Qt::Key leftKey READ leftKey WRITE setLeftKey NOTIFY leftKeyChanged)
59 Q_PROPERTY(Qt::Key rightKey READ rightKey WRITE setRightKey NOTIFY rightKeyChanged)
60 Q_PROPERTY(Qt::Key buttonAKey READ buttonAKey WRITE setButtonAKey NOTIFY buttonAKeyChanged)
61 Q_PROPERTY(Qt::Key buttonBKey READ buttonBKey WRITE setButtonBKey NOTIFY buttonBKeyChanged)
62 Q_PROPERTY(Qt::Key buttonXKey READ buttonXKey WRITE setButtonXKey NOTIFY buttonXKeyChanged)
63 Q_PROPERTY(Qt::Key buttonYKey READ buttonYKey WRITE setButtonYKey NOTIFY buttonYKeyChanged)
64 Q_PROPERTY(Qt::Key buttonSelectKey READ buttonSelectKey WRITE setButtonSelectKey NOTIFY buttonSelectKeyChanged)
65 Q_PROPERTY(Qt::Key buttonStartKey READ buttonStartKey WRITE setButtonStartKey NOTIFY buttonStartKeyChanged)
66 Q_PROPERTY(Qt::Key buttonGuideKey READ buttonGuideKey WRITE setButtonGuideKey NOTIFY buttonGuideKeyChanged)
67 Q_PROPERTY(Qt::Key buttonL1Key READ buttonL1Key WRITE setButtonL1Key NOTIFY buttonL1KeyChanged)
68 Q_PROPERTY(Qt::Key buttonR1Key READ buttonR1Key WRITE setButtonR1Key NOTIFY buttonR1KeyChanged)
69 Q_PROPERTY(Qt::Key buttonL2Key READ buttonL2Key WRITE setButtonL2Key NOTIFY buttonL2KeyChanged)
70 Q_PROPERTY(Qt::Key buttonR2Key READ buttonR2Key WRITE setButtonR2Key NOTIFY buttonR2KeyChanged)
71 Q_PROPERTY(Qt::Key buttonL3Key READ buttonL3Key WRITE setButtonL3Key NOTIFY buttonL3KeyChanged)
72 Q_PROPERTY(Qt::Key buttonR3Key READ buttonR3Key WRITE setButtonR3Key NOTIFY buttonR3KeyChanged)
73public:
74 explicit QGamepadKeyNavigation(QObject *parent = nullptr);
75
76 bool active() const;
77 QGamepad *gamepad() const;
78
79 Qt::Key upKey() const;
80 Qt::Key downKey() const;
81 Qt::Key leftKey() const;
82 Qt::Key rightKey() const;
83 Qt::Key buttonAKey() const;
84 Qt::Key buttonBKey() const;
85 Qt::Key buttonXKey() const;
86 Qt::Key buttonYKey() const;
87 Qt::Key buttonSelectKey() const;
88 Qt::Key buttonStartKey() const;
89 Qt::Key buttonGuideKey() const;
90 Qt::Key buttonL1Key() const;
91 Qt::Key buttonR1Key() const;
92 Qt::Key buttonL2Key() const;
93 Qt::Key buttonR2Key() const;
94 Qt::Key buttonL3Key() const;
95 Qt::Key buttonR3Key() const;
96
97Q_SIGNALS:
98 void activeChanged(bool isActive);
99 void gamepadChanged(QGamepad *gamepad);
100
101 void upKeyChanged(Qt::Key key);
102 void downKeyChanged(Qt::Key key);
103 void leftKeyChanged(Qt::Key key);
104 void rightKeyChanged(Qt::Key key);
105 void buttonAKeyChanged(Qt::Key key);
106 void buttonBKeyChanged(Qt::Key key);
107 void buttonXKeyChanged(Qt::Key key);
108 void buttonYKeyChanged(Qt::Key key);
109 void buttonSelectKeyChanged(Qt::Key key);
110 void buttonStartKeyChanged(Qt::Key key);
111 void buttonGuideKeyChanged(Qt::Key key);
112 void buttonL1KeyChanged(Qt::Key key);
113 void buttonR1KeyChanged(Qt::Key key);
114 void buttonL2KeyChanged(Qt::Key key);
115 void buttonR2KeyChanged(Qt::Key key);
116 void buttonL3KeyChanged(Qt::Key key);
117 void buttonR3KeyChanged(Qt::Key key);
118
119public Q_SLOTS:
120 void setActive(bool isActive);
121 void setGamepad(QGamepad *gamepad);
122
123 void setUpKey(Qt::Key key);
124 void setDownKey(Qt::Key key);
125 void setLeftKey(Qt::Key key);
126 void setRightKey(Qt::Key key);
127 void setButtonAKey(Qt::Key key);
128 void setButtonBKey(Qt::Key key);
129 void setButtonXKey(Qt::Key key);
130 void setButtonYKey(Qt::Key key);
131 void setButtonSelectKey(Qt::Key key);
132 void setButtonStartKey(Qt::Key key);
133 void setButtonGuideKey(Qt::Key key);
134 void setButtonL1Key(Qt::Key key);
135 void setButtonR1Key(Qt::Key key);
136 void setButtonL2Key(Qt::Key key);
137 void setButtonR2Key(Qt::Key key);
138 void setButtonL3Key(Qt::Key key);
139 void setButtonR3Key(Qt::Key key);
140
141private:
142 Q_DECLARE_PRIVATE(QGamepadKeyNavigation)
143 Q_DISABLE_COPY(QGamepadKeyNavigation)
144 Q_PRIVATE_SLOT(d_func(), void _q_processGamepadButtonPressEvent(int, QGamepadManager::GamepadButton, double))
145 Q_PRIVATE_SLOT(d_func(), void _q_processGamepadButtonReleaseEvent(int, QGamepadManager::GamepadButton))
146};
147
148QT_END_NAMESPACE
149
150#endif // QGAMEPADKEYNAVIGATION_H
151

source code of qtgamepad/src/gamepad/qgamepadkeynavigation.h