QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgs3dgamepadcontroller.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dgamepadcontroller.cpp
3 ---------------------
4 begin : March 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgs3dgamepadcontroller.cpp"
18
19#ifdef HAVE_QTGAMEPAD
20
21#include <QtGamepad/QGamepad>
22
23QgsGamepad3DMapController::QgsGamepad3DMapController( int gamepadDeviceId, QObject *parent )
25 , mGamepadDeviceId( gamepadDeviceId )
26{
27 mGamepad = new QGamepad( gamepadDeviceId, this );
28
29 // proxy raw signals for interested PyQGIS
30 connect( mGamepad, &QGamepad::connectedChanged, this, &QgsGamepad3DMapController::connectedChanged );
31 connect( mGamepad, &QGamepad::axisLeftXChanged, this, &QgsGamepad3DMapController::axisLeftXChanged );
32 connect( mGamepad, &QGamepad::axisLeftYChanged, this, &QgsGamepad3DMapController::axisLeftYChanged );
33 connect( mGamepad, &QGamepad::axisRightXChanged, this, &QgsGamepad3DMapController::axisRightXChanged );
34 connect( mGamepad, &QGamepad::axisRightYChanged, this, &QgsGamepad3DMapController::axisRightYChanged );
35 connect( mGamepad, &QGamepad::buttonAChanged, this, &QgsGamepad3DMapController::buttonAChanged );
36 connect( mGamepad, &QGamepad::buttonBChanged, this, &QgsGamepad3DMapController::buttonBChanged );
37 connect( mGamepad, &QGamepad::buttonXChanged, this, &QgsGamepad3DMapController::buttonXChanged );
38 connect( mGamepad, &QGamepad::buttonYChanged, this, &QgsGamepad3DMapController::buttonYChanged );
39 connect( mGamepad, &QGamepad::buttonL1Changed, this, &QgsGamepad3DMapController::buttonL1Changed );
40 connect( mGamepad, &QGamepad::buttonR1Changed, this, &QgsGamepad3DMapController::buttonR1Changed );
41 connect( mGamepad, &QGamepad::buttonL2Changed, this, &QgsGamepad3DMapController::buttonL2Changed );
42 connect( mGamepad, &QGamepad::buttonR2Changed, this, &QgsGamepad3DMapController::buttonR2Changed );
43 connect( mGamepad, &QGamepad::buttonSelectChanged, this, &QgsGamepad3DMapController::buttonSelectChanged );
44 connect( mGamepad, &QGamepad::buttonStartChanged, this, &QgsGamepad3DMapController::buttonStartChanged );
45 connect( mGamepad, &QGamepad::buttonL3Changed, this, &QgsGamepad3DMapController::buttonL3Changed );
46 connect( mGamepad, &QGamepad::buttonR3Changed, this, &QgsGamepad3DMapController::buttonR3Changed );
47 connect( mGamepad, &QGamepad::buttonUpChanged, this, &QgsGamepad3DMapController::buttonUpChanged );
48 connect( mGamepad, &QGamepad::buttonDownChanged, this, &QgsGamepad3DMapController::buttonDownChanged );
49 connect( mGamepad, &QGamepad::buttonLeftChanged, this, &QgsGamepad3DMapController::buttonLeftChanged );
50 connect( mGamepad, &QGamepad::buttonRightChanged, this, &QgsGamepad3DMapController::buttonRightChanged );
51 connect( mGamepad, &QGamepad::buttonCenterChanged, this, &QgsGamepad3DMapController::buttonCenterChanged );
52 connect( mGamepad, &QGamepad::buttonGuideChanged, this, &QgsGamepad3DMapController::buttonGuideChanged );
53
54 // also here we would make connections to the 2D map controller signals like zoomMap, depending on some
55 // reasonable defaults and user defined QSettings
56}
57
58QgsGamepad3DMapController *QgsGamepad3DMapController::clone() const
59{
60 return new QgsGamepad3DMapController( mGamepadDeviceId );
61}
62
63QString QgsGamepad3DMapController::deviceId() const
64{
65 return QStringLiteral( "gamepad3d:%1" ).arg( mGamepadDeviceId );
66}
67
68bool QgsGamepad3DMapController::isConnected() const
69{
70 return mGamepad->isConnected();
71}
72
73QString QgsGamepad3DMapController::name() const
74{
75 return mGamepad->name();
76}
77
78double QgsGamepad3DMapController::axisLeftX() const
79{
80 return mGamepad->axisLeftX();
81}
82
83double QgsGamepad3DMapController::axisLeftY() const
84{
85 return mGamepad->axisLeftY();
86}
87
88double QgsGamepad3DMapController::axisRightX() const
89{
90 return mGamepad->axisRightX();
91}
92
93double QgsGamepad3DMapController::axisRightY() const
94{
95 return mGamepad->axisRightY();
96}
97
98bool QgsGamepad3DMapController::buttonA() const
99{
100 return mGamepad->buttonA();
101}
102
103bool QgsGamepad3DMapController::buttonB() const
104{
105 return mGamepad->buttonB();
106}
107
108bool QgsGamepad3DMapController::buttonX() const
109{
110 return mGamepad->buttonX();
111}
112
113bool QgsGamepad3DMapController::buttonY() const
114{
115 return mGamepad->buttonY();
116}
117
118bool QgsGamepad3DMapController::buttonL1() const
119{
120 return mGamepad->buttonL1();
121}
122
123bool QgsGamepad3DMapController::buttonR1() const
124{
125 return mGamepad->buttonR1();
126}
127
128double QgsGamepad3DMapController::buttonL2() const
129{
130 return mGamepad->buttonL2();
131}
132
133double QgsGamepad3DMapController::buttonR2() const
134{
135 return mGamepad->buttonR2();
136}
137
138bool QgsGamepad3DMapController::buttonSelect() const
139{
140 return mGamepad->buttonSelect();
141}
142
143bool QgsGamepad3DMapController::buttonStart() const
144{
145 return mGamepad->buttonStart();
146}
147
148bool QgsGamepad3DMapController::buttonL3() const
149{
150 return mGamepad->buttonL3();
151}
152
153bool QgsGamepad3DMapController::buttonR3() const
154{
155 return mGamepad->buttonR3();
156}
157
158bool QgsGamepad3DMapController::buttonUp() const
159{
160 return mGamepad->buttonUp();
161}
162
163bool QgsGamepad3DMapController::buttonDown() const
164{
165 return mGamepad->buttonDown();
166}
167
168bool QgsGamepad3DMapController::buttonLeft() const
169{
170 return mGamepad->buttonLeft();
171}
172
173bool QgsGamepad3DMapController::buttonRight() const
174{
175 return mGamepad->buttonRight();
176}
177
178bool QgsGamepad3DMapController::buttonCenter() const
179{
180 return mGamepad->buttonCenter();
181}
182
183bool QgsGamepad3DMapController::buttonGuide() const
184{
185 return mGamepad->buttonGuide();
186}
187
188#endif
Abstract base class for all 3D map controllers.