QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
18#ifdef HAVE_QTGAMEPAD
19
20#include <QtGamepad/QGamepad>
21
22QgsGamepad3DMapController::QgsGamepad3DMapController( int gamepadDeviceId, QObject *parent )
24 , mGamepadDeviceId( gamepadDeviceId )
25{
26 mGamepad = new QGamepad( gamepadDeviceId, this );
27
28 // proxy raw signals for interested PyQGIS
29 connect( mGamepad, &QGamepad::connectedChanged, this, &QgsGamepad3DMapController::connectedChanged );
30 connect( mGamepad, &QGamepad::axisLeftXChanged, this, &QgsGamepad3DMapController::axisLeftXChanged );
31 connect( mGamepad, &QGamepad::axisLeftYChanged, this, &QgsGamepad3DMapController::axisLeftYChanged );
32 connect( mGamepad, &QGamepad::axisRightXChanged, this, &QgsGamepad3DMapController::axisRightXChanged );
33 connect( mGamepad, &QGamepad::axisRightYChanged, this, &QgsGamepad3DMapController::axisRightYChanged );
34 connect( mGamepad, &QGamepad::buttonAChanged, this, &QgsGamepad3DMapController::buttonAChanged );
35 connect( mGamepad, &QGamepad::buttonBChanged, this, &QgsGamepad3DMapController::buttonBChanged );
36 connect( mGamepad, &QGamepad::buttonXChanged, this, &QgsGamepad3DMapController::buttonXChanged );
37 connect( mGamepad, &QGamepad::buttonYChanged, this, &QgsGamepad3DMapController::buttonYChanged );
38 connect( mGamepad, &QGamepad::buttonL1Changed, this, &QgsGamepad3DMapController::buttonL1Changed );
39 connect( mGamepad, &QGamepad::buttonR1Changed, this, &QgsGamepad3DMapController::buttonR1Changed );
40 connect( mGamepad, &QGamepad::buttonL2Changed, this, &QgsGamepad3DMapController::buttonL2Changed );
41 connect( mGamepad, &QGamepad::buttonR2Changed, this, &QgsGamepad3DMapController::buttonR2Changed );
42 connect( mGamepad, &QGamepad::buttonSelectChanged, this, &QgsGamepad3DMapController::buttonSelectChanged );
43 connect( mGamepad, &QGamepad::buttonStartChanged, this, &QgsGamepad3DMapController::buttonStartChanged );
44 connect( mGamepad, &QGamepad::buttonL3Changed, this, &QgsGamepad3DMapController::buttonL3Changed );
45 connect( mGamepad, &QGamepad::buttonR3Changed, this, &QgsGamepad3DMapController::buttonR3Changed );
46 connect( mGamepad, &QGamepad::buttonUpChanged, this, &QgsGamepad3DMapController::buttonUpChanged );
47 connect( mGamepad, &QGamepad::buttonDownChanged, this, &QgsGamepad3DMapController::buttonDownChanged );
48 connect( mGamepad, &QGamepad::buttonLeftChanged, this, &QgsGamepad3DMapController::buttonLeftChanged );
49 connect( mGamepad, &QGamepad::buttonRightChanged, this, &QgsGamepad3DMapController::buttonRightChanged );
50 connect( mGamepad, &QGamepad::buttonCenterChanged, this, &QgsGamepad3DMapController::buttonCenterChanged );
51 connect( mGamepad, &QGamepad::buttonGuideChanged, this, &QgsGamepad3DMapController::buttonGuideChanged );
52
53 // also here we would make connections to the 2D map controller signals like zoomMap, depending on some
54 // reasonable defaults and user defined QSettings
55}
56
57QgsGamepad3DMapController *QgsGamepad3DMapController::clone() const
58{
59 return new QgsGamepad3DMapController( mGamepadDeviceId );
60}
61
62QString QgsGamepad3DMapController::deviceId() const
63{
64 return QStringLiteral( "gamepad3d:%1" ).arg( mGamepadDeviceId );
65}
66
67bool QgsGamepad3DMapController::isConnected() const
68{
69 return mGamepad->isConnected();
70}
71
72QString QgsGamepad3DMapController::name() const
73{
74 return mGamepad->name();
75}
76
77double QgsGamepad3DMapController::axisLeftX() const
78{
79 return mGamepad->axisLeftX();
80}
81
82double QgsGamepad3DMapController::axisLeftY() const
83{
84 return mGamepad->axisLeftY();
85}
86
87double QgsGamepad3DMapController::axisRightX() const
88{
89 return mGamepad->axisRightX();
90}
91
92double QgsGamepad3DMapController::axisRightY() const
93{
94 return mGamepad->axisRightY();
95}
96
97bool QgsGamepad3DMapController::buttonA() const
98{
99 return mGamepad->buttonA();
100}
101
102bool QgsGamepad3DMapController::buttonB() const
103{
104 return mGamepad->buttonB();
105}
106
107bool QgsGamepad3DMapController::buttonX() const
108{
109 return mGamepad->buttonX();
110}
111
112bool QgsGamepad3DMapController::buttonY() const
113{
114 return mGamepad->buttonY();
115}
116
117bool QgsGamepad3DMapController::buttonL1() const
118{
119 return mGamepad->buttonL1();
120}
121
122bool QgsGamepad3DMapController::buttonR1() const
123{
124 return mGamepad->buttonR1();
125}
126
127double QgsGamepad3DMapController::buttonL2() const
128{
129 return mGamepad->buttonL2();
130}
131
132double QgsGamepad3DMapController::buttonR2() const
133{
134 return mGamepad->buttonR2();
135}
136
137bool QgsGamepad3DMapController::buttonSelect() const
138{
139 return mGamepad->buttonSelect();
140}
141
142bool QgsGamepad3DMapController::buttonStart() const
143{
144 return mGamepad->buttonStart();
145}
146
147bool QgsGamepad3DMapController::buttonL3() const
148{
149 return mGamepad->buttonL3();
150}
151
152bool QgsGamepad3DMapController::buttonR3() const
153{
154 return mGamepad->buttonR3();
155}
156
157bool QgsGamepad3DMapController::buttonUp() const
158{
159 return mGamepad->buttonUp();
160}
161
162bool QgsGamepad3DMapController::buttonDown() const
163{
164 return mGamepad->buttonDown();
165}
166
167bool QgsGamepad3DMapController::buttonLeft() const
168{
169 return mGamepad->buttonLeft();
170}
171
172bool QgsGamepad3DMapController::buttonRight() const
173{
174 return mGamepad->buttonRight();
175}
176
177bool QgsGamepad3DMapController::buttonCenter() const
178{
179 return mGamepad->buttonCenter();
180}
181
182bool QgsGamepad3DMapController::buttonGuide() const
183{
184 return mGamepad->buttonGuide();
185}
186
187#endif
Abstract base class for all 3D map controllers.