17#include "moc_qgs2dgamepadcontroller.cpp"
21#include <QtGamepad/QGamepad>
23QgsGamepad2DMapController::QgsGamepad2DMapController(
int gamepadDeviceId, QObject *parent )
25 , mGamepadDeviceId( gamepadDeviceId )
27 mGamepad =
new QGamepad( gamepadDeviceId,
this );
30 connect( mGamepad, &QGamepad::connectedChanged,
this, &QgsGamepad2DMapController::connectedChanged );
31 connect( mGamepad, &QGamepad::axisLeftXChanged,
this, &QgsGamepad2DMapController::axisLeftXChanged );
32 connect( mGamepad, &QGamepad::axisLeftYChanged,
this, &QgsGamepad2DMapController::axisLeftYChanged );
33 connect( mGamepad, &QGamepad::axisRightXChanged,
this, &QgsGamepad2DMapController::axisRightXChanged );
34 connect( mGamepad, &QGamepad::axisRightYChanged,
this, &QgsGamepad2DMapController::axisRightYChanged );
35 connect( mGamepad, &QGamepad::buttonAChanged,
this, &QgsGamepad2DMapController::buttonAChanged );
36 connect( mGamepad, &QGamepad::buttonBChanged,
this, &QgsGamepad2DMapController::buttonBChanged );
37 connect( mGamepad, &QGamepad::buttonXChanged,
this, &QgsGamepad2DMapController::buttonXChanged );
38 connect( mGamepad, &QGamepad::buttonYChanged,
this, &QgsGamepad2DMapController::buttonYChanged );
39 connect( mGamepad, &QGamepad::buttonL1Changed,
this, &QgsGamepad2DMapController::buttonL1Changed );
40 connect( mGamepad, &QGamepad::buttonR1Changed,
this, &QgsGamepad2DMapController::buttonR1Changed );
41 connect( mGamepad, &QGamepad::buttonL2Changed,
this, &QgsGamepad2DMapController::buttonL2Changed );
42 connect( mGamepad, &QGamepad::buttonR2Changed,
this, &QgsGamepad2DMapController::buttonR2Changed );
43 connect( mGamepad, &QGamepad::buttonSelectChanged,
this, &QgsGamepad2DMapController::buttonSelectChanged );
44 connect( mGamepad, &QGamepad::buttonStartChanged,
this, &QgsGamepad2DMapController::buttonStartChanged );
45 connect( mGamepad, &QGamepad::buttonL3Changed,
this, &QgsGamepad2DMapController::buttonL3Changed );
46 connect( mGamepad, &QGamepad::buttonR3Changed,
this, &QgsGamepad2DMapController::buttonR3Changed );
47 connect( mGamepad, &QGamepad::buttonUpChanged,
this, &QgsGamepad2DMapController::buttonUpChanged );
48 connect( mGamepad, &QGamepad::buttonDownChanged,
this, &QgsGamepad2DMapController::buttonDownChanged );
49 connect( mGamepad, &QGamepad::buttonLeftChanged,
this, &QgsGamepad2DMapController::buttonLeftChanged );
50 connect( mGamepad, &QGamepad::buttonRightChanged,
this, &QgsGamepad2DMapController::buttonRightChanged );
51 connect( mGamepad, &QGamepad::buttonCenterChanged,
this, &QgsGamepad2DMapController::buttonCenterChanged );
52 connect( mGamepad, &QGamepad::buttonGuideChanged,
this, &QgsGamepad2DMapController::buttonGuideChanged );
57 connect( mGamepad, &QGamepad::axisRightYChanged,
this, [ = ](
double value )
60 emit zoomMap( value + 1 );
66QgsGamepad2DMapController *QgsGamepad2DMapController::clone()
const
68 return new QgsGamepad2DMapController( mGamepadDeviceId );
71QString QgsGamepad2DMapController::deviceId()
const
73 return QStringLiteral(
"gamepad2d:%1" ).arg( mGamepadDeviceId );
76bool QgsGamepad2DMapController::isConnected()
const
78 return mGamepad->isConnected();
81QString QgsGamepad2DMapController::name()
const
83 return mGamepad->name();
86double QgsGamepad2DMapController::axisLeftX()
const
88 return mGamepad->axisLeftX();
91double QgsGamepad2DMapController::axisLeftY()
const
93 return mGamepad->axisLeftY();
96double QgsGamepad2DMapController::axisRightX()
const
98 return mGamepad->axisRightX();
101double QgsGamepad2DMapController::axisRightY()
const
103 return mGamepad->axisRightY();
106bool QgsGamepad2DMapController::buttonA()
const
108 return mGamepad->buttonA();
111bool QgsGamepad2DMapController::buttonB()
const
113 return mGamepad->buttonB();
116bool QgsGamepad2DMapController::buttonX()
const
118 return mGamepad->buttonX();
121bool QgsGamepad2DMapController::buttonY()
const
123 return mGamepad->buttonY();
126bool QgsGamepad2DMapController::buttonL1()
const
128 return mGamepad->buttonL1();
131bool QgsGamepad2DMapController::buttonR1()
const
133 return mGamepad->buttonR1();
136double QgsGamepad2DMapController::buttonL2()
const
138 return mGamepad->buttonL2();
141double QgsGamepad2DMapController::buttonR2()
const
143 return mGamepad->buttonR2();
146bool QgsGamepad2DMapController::buttonSelect()
const
148 return mGamepad->buttonSelect();
151bool QgsGamepad2DMapController::buttonStart()
const
153 return mGamepad->buttonStart();
156bool QgsGamepad2DMapController::buttonL3()
const
158 return mGamepad->buttonL3();
161bool QgsGamepad2DMapController::buttonR3()
const
163 return mGamepad->buttonR3();
166bool QgsGamepad2DMapController::buttonUp()
const
168 return mGamepad->buttonUp();
171bool QgsGamepad2DMapController::buttonDown()
const
173 return mGamepad->buttonDown();
176bool QgsGamepad2DMapController::buttonLeft()
const
178 return mGamepad->buttonLeft();
181bool QgsGamepad2DMapController::buttonRight()
const
183 return mGamepad->buttonRight();
186bool QgsGamepad2DMapController::buttonCenter()
const
188 return mGamepad->buttonCenter();
191bool QgsGamepad2DMapController::buttonGuide()
const
193 return mGamepad->buttonGuide();
Abstract base class for all 2D map controllers.