17#include "moc_qgsinputcontrollermanager.cpp"
22#include <QRegularExpression>
23#include <QRegularExpressionMatch>
28#include <QtGamepad/QGamepadManager>
43 qDeleteAll( m2DMapControllers );
44 qDeleteAll( m3DMapControllers );
52 if ( m2DMapControllers.contains( controller->
deviceId() ) )
58 m2DMapControllers.insert( controller->
deviceId(), controller );
67 if ( m3DMapControllers.contains( controller->
deviceId() ) )
73 m3DMapControllers.insert( controller->
deviceId(), controller );
79 QStringList devices = m2DMapControllers.keys();
82 const QList< int > gamepadIds = QGamepadManager::instance()->connectedGamepads();
83 for (
int id : gamepadIds )
85 devices.append( QStringLiteral(
"gamepad2d:%1" ).arg(
id ) );
95 const thread_local QRegularExpression gamepadRx( QStringLiteral(
"^gamepad2d:(\\d+)$" ) );
96 const QRegularExpressionMatch gamepadMatch = gamepadRx.match( deviceId );
97 if ( gamepadMatch.hasMatch() )
99 const int gamepadId = gamepadMatch.captured( 1 ).toInt();
100 return new QgsGamepad2DMapController( gamepadId );
104 auto it = m2DMapControllers.constFind( deviceId );
105 if ( it == m2DMapControllers.constEnd() )
108 return qgis::down_cast< QgsAbstract2DMapController *>( it.value()->clone() );
113 QStringList devices = m3DMapControllers.keys();
116 const QList< int > gamepadIds = QGamepadManager::instance()->connectedGamepads();
117 for (
int id : gamepadIds )
119 devices.append( QStringLiteral(
"gamepad3d:%1" ).arg(
id ) );
129 const thread_local QRegularExpression gamepadRx( QStringLiteral(
"^gamepad3d:(\\d+)$" ) );
130 const QRegularExpressionMatch gamepadMatch = gamepadRx.match( deviceId );
131 if ( gamepadMatch.hasMatch() )
133 const int gamepadId = gamepadMatch.captured( 1 ).toInt();
134 return new QgsGamepad3DMapController( gamepadId );
138 auto it = m3DMapControllers.constFind( deviceId );
139 if ( it == m3DMapControllers.constEnd() )
142 return qgis::down_cast< QgsAbstract3DMapController *>( it.value()->clone() );
Abstract base class for all 2D map controllers.
Abstract base class for all 3D map controllers.