21#include <QRegularExpression>
22#include <QRegularExpressionMatch>
27#include <QtGamepad/QGamepadManager>
42 qDeleteAll( m2DMapControllers );
43 qDeleteAll( m3DMapControllers );
51 if ( m2DMapControllers.contains( controller->
deviceId() ) )
57 m2DMapControllers.insert( controller->
deviceId(), controller );
66 if ( m3DMapControllers.contains( controller->
deviceId() ) )
72 m3DMapControllers.insert( controller->
deviceId(), controller );
78 QStringList devices = m2DMapControllers.keys();
81 const QList< int > gamepadIds = QGamepadManager::instance()->connectedGamepads();
82 for (
int id : gamepadIds )
84 devices.append( QStringLiteral(
"gamepad2d:%1" ).arg(
id ) );
94 const thread_local QRegularExpression gamepadRx( QStringLiteral(
"^gamepad2d:(\\d+)$" ) );
95 const QRegularExpressionMatch gamepadMatch = gamepadRx.match( deviceId );
96 if ( gamepadMatch.hasMatch() )
98 const int gamepadId = gamepadMatch.captured( 1 ).toInt();
99 return new QgsGamepad2DMapController( gamepadId );
103 auto it = m2DMapControllers.constFind( deviceId );
104 if ( it == m2DMapControllers.constEnd() )
107 return qgis::down_cast< QgsAbstract2DMapController *>( it.value()->clone() );
112 QStringList devices = m3DMapControllers.keys();
115 const QList< int > gamepadIds = QGamepadManager::instance()->connectedGamepads();
116 for (
int id : gamepadIds )
118 devices.append( QStringLiteral(
"gamepad3d:%1" ).arg(
id ) );
128 const thread_local QRegularExpression gamepadRx( QStringLiteral(
"^gamepad3d:(\\d+)$" ) );
129 const QRegularExpressionMatch gamepadMatch = gamepadRx.match( deviceId );
130 if ( gamepadMatch.hasMatch() )
132 const int gamepadId = gamepadMatch.captured( 1 ).toInt();
133 return new QgsGamepad3DMapController( gamepadId );
137 auto it = m3DMapControllers.constFind( deviceId );
138 if ( it == m3DMapControllers.constEnd() )
141 return qgis::down_cast< QgsAbstract3DMapController *>( it.value()->clone() );
Abstract base class for all 2D map controllers.
Abstract base class for all 3D map controllers.