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 );
65QgsGamepad2DMapController *QgsGamepad2DMapController::clone()
const
67 return new QgsGamepad2DMapController( mGamepadDeviceId );
70QString QgsGamepad2DMapController::deviceId()
const
72 return QStringLiteral(
"gamepad2d:%1" ).arg( mGamepadDeviceId );
75bool QgsGamepad2DMapController::isConnected()
const
77 return mGamepad->isConnected();
80QString QgsGamepad2DMapController::name()
const
82 return mGamepad->name();
85double QgsGamepad2DMapController::axisLeftX()
const
87 return mGamepad->axisLeftX();
90double QgsGamepad2DMapController::axisLeftY()
const
92 return mGamepad->axisLeftY();
95double QgsGamepad2DMapController::axisRightX()
const
97 return mGamepad->axisRightX();
100double QgsGamepad2DMapController::axisRightY()
const
102 return mGamepad->axisRightY();
105bool QgsGamepad2DMapController::buttonA()
const
107 return mGamepad->buttonA();
110bool QgsGamepad2DMapController::buttonB()
const
112 return mGamepad->buttonB();
115bool QgsGamepad2DMapController::buttonX()
const
117 return mGamepad->buttonX();
120bool QgsGamepad2DMapController::buttonY()
const
122 return mGamepad->buttonY();
125bool QgsGamepad2DMapController::buttonL1()
const
127 return mGamepad->buttonL1();
130bool QgsGamepad2DMapController::buttonR1()
const
132 return mGamepad->buttonR1();
135double QgsGamepad2DMapController::buttonL2()
const
137 return mGamepad->buttonL2();
140double QgsGamepad2DMapController::buttonR2()
const
142 return mGamepad->buttonR2();
145bool QgsGamepad2DMapController::buttonSelect()
const
147 return mGamepad->buttonSelect();
150bool QgsGamepad2DMapController::buttonStart()
const
152 return mGamepad->buttonStart();
155bool QgsGamepad2DMapController::buttonL3()
const
157 return mGamepad->buttonL3();
160bool QgsGamepad2DMapController::buttonR3()
const
162 return mGamepad->buttonR3();
165bool QgsGamepad2DMapController::buttonUp()
const
167 return mGamepad->buttonUp();
170bool QgsGamepad2DMapController::buttonDown()
const
172 return mGamepad->buttonDown();
175bool QgsGamepad2DMapController::buttonLeft()
const
177 return mGamepad->buttonLeft();
180bool QgsGamepad2DMapController::buttonRight()
const
182 return mGamepad->buttonRight();
185bool QgsGamepad2DMapController::buttonCenter()
const
187 return mGamepad->buttonCenter();
190bool QgsGamepad2DMapController::buttonGuide()
const
192 return mGamepad->buttonGuide();
Abstract base class for all 2D map controllers.