Qt Gamepad with Logitech
-
Hi all,
I am trying to connect my logitech Extreme 3D to a Qt Application employing the code which is provided as reference and example. Code is as follows:
/#include "gamepadmonitor.h" #include <QtGamepad/QGamepad> #include <QDebug> #include <QLoggingCategory> #include <QWindow> GamepadMonitor::GamepadMonitor(QObject *parent) : QObject(parent) , m_gamepad(nullptr) { QLoggingCategory::setFilterRules(QStringLiteral("qt.gamepad.debug=true")); auto gamepads = QGamepadManager::instance()->connectedGamepads(); if (gamepads.isEmpty()) { qDebug() << "gamepads size:" << gamepads.size(); qDebug() << "Did not find any connected gamepads"; //return; } m_gamepad = new QGamepad(*gamepads.begin(), this); /*connect(QGamepadManager::instance(), &QGamepadManager::gamepadButtonReleaseEvent, this, [=](int deviceId, QGamepadManager::GamepadButtons button) { Q_UNUSED(deviceId); qDebug() << "boton pulsado"; });*/ connect(m_gamepad, &QGamepad::axisLeftXChanged, this, [](double value){ qDebug() << "Left X" << value; }); connect(m_gamepad, &QGamepad::axisLeftYChanged, this, [](double value){ qDebug() << "Left Y" << value; }); connect(m_gamepad, &QGamepad::axisRightXChanged, this, [](double value){ qDebug() << "Right X" << value; }); connect(m_gamepad, &QGamepad::axisRightYChanged, this, [](double value){ qDebug() << "Right Y" << value; }); connect(m_gamepad, &QGamepad::buttonAChanged, this, [](bool pressed){ qDebug() << "Button A" << pressed; }); connect(m_gamepad, &QGamepad::buttonBChanged, this, [](bool pressed){ qDebug() << "Button B" << pressed; }); connect(m_gamepad, &QGamepad::buttonXChanged, this, [](bool pressed){ qDebug() << "Button X" << pressed; }); connect(m_gamepad, &QGamepad::buttonYChanged, this, [](bool pressed){ qDebug() << "Button Y" << pressed; }); connect(m_gamepad, &QGamepad::buttonL1Changed, this, [](bool pressed){ qDebug() << "Button L1" << pressed; }); connect(m_gamepad, &QGamepad::buttonR1Changed, this, [](bool pressed){ qDebug() << "Button R1" << pressed; }); connect(m_gamepad, &QGamepad::buttonL2Changed, this, [](double value){ qDebug() << "Button L2: " << value; }); connect(m_gamepad, &QGamepad::buttonR2Changed, this, [](double value){ qDebug() << "Button R2: " << value; }); connect(m_gamepad, &QGamepad::buttonSelectChanged, this, [](bool pressed){ qDebug() << "Button Select" << pressed; }); connect(m_gamepad, &QGamepad::buttonStartChanged, this, [](bool pressed){ qDebug() << "Button Start" << pressed; }); connect(m_gamepad, &QGamepad::buttonGuideChanged, this, [](bool pressed){ qDebug() << "Button Guide" << pressed; }); } GamepadMonitor::~GamepadMonitor() { delete m_gamepad; }
Furthermore, I have been trying another way which employs a friend of mine:
connect(QGamepadManager::instance(), &QGamepadManager::gamepadButtonReleaseEvent, this, [=](int deviceId, QGamepadManager::GamepadButtons button) { Q_UNUSED(deviceId); qDebug() << "boton pulsado";
Both codes are unable to detect the game device.
Would somebody be as kind as to help me with this issue?
Thanks in advance.
-
Hi all,
I am trying to connect my logitech Extreme 3D to a Qt Application employing the code which is provided as reference and example. Code is as follows:
/#include "gamepadmonitor.h" #include <QtGamepad/QGamepad> #include <QDebug> #include <QLoggingCategory> #include <QWindow> GamepadMonitor::GamepadMonitor(QObject *parent) : QObject(parent) , m_gamepad(nullptr) { QLoggingCategory::setFilterRules(QStringLiteral("qt.gamepad.debug=true")); auto gamepads = QGamepadManager::instance()->connectedGamepads(); if (gamepads.isEmpty()) { qDebug() << "gamepads size:" << gamepads.size(); qDebug() << "Did not find any connected gamepads"; //return; } m_gamepad = new QGamepad(*gamepads.begin(), this); /*connect(QGamepadManager::instance(), &QGamepadManager::gamepadButtonReleaseEvent, this, [=](int deviceId, QGamepadManager::GamepadButtons button) { Q_UNUSED(deviceId); qDebug() << "boton pulsado"; });*/ connect(m_gamepad, &QGamepad::axisLeftXChanged, this, [](double value){ qDebug() << "Left X" << value; }); connect(m_gamepad, &QGamepad::axisLeftYChanged, this, [](double value){ qDebug() << "Left Y" << value; }); connect(m_gamepad, &QGamepad::axisRightXChanged, this, [](double value){ qDebug() << "Right X" << value; }); connect(m_gamepad, &QGamepad::axisRightYChanged, this, [](double value){ qDebug() << "Right Y" << value; }); connect(m_gamepad, &QGamepad::buttonAChanged, this, [](bool pressed){ qDebug() << "Button A" << pressed; }); connect(m_gamepad, &QGamepad::buttonBChanged, this, [](bool pressed){ qDebug() << "Button B" << pressed; }); connect(m_gamepad, &QGamepad::buttonXChanged, this, [](bool pressed){ qDebug() << "Button X" << pressed; }); connect(m_gamepad, &QGamepad::buttonYChanged, this, [](bool pressed){ qDebug() << "Button Y" << pressed; }); connect(m_gamepad, &QGamepad::buttonL1Changed, this, [](bool pressed){ qDebug() << "Button L1" << pressed; }); connect(m_gamepad, &QGamepad::buttonR1Changed, this, [](bool pressed){ qDebug() << "Button R1" << pressed; }); connect(m_gamepad, &QGamepad::buttonL2Changed, this, [](double value){ qDebug() << "Button L2: " << value; }); connect(m_gamepad, &QGamepad::buttonR2Changed, this, [](double value){ qDebug() << "Button R2: " << value; }); connect(m_gamepad, &QGamepad::buttonSelectChanged, this, [](bool pressed){ qDebug() << "Button Select" << pressed; }); connect(m_gamepad, &QGamepad::buttonStartChanged, this, [](bool pressed){ qDebug() << "Button Start" << pressed; }); connect(m_gamepad, &QGamepad::buttonGuideChanged, this, [](bool pressed){ qDebug() << "Button Guide" << pressed; }); } GamepadMonitor::~GamepadMonitor() { delete m_gamepad; }
Furthermore, I have been trying another way which employs a friend of mine:
connect(QGamepadManager::instance(), &QGamepadManager::gamepadButtonReleaseEvent, this, [=](int deviceId, QGamepadManager::GamepadButtons button) { Q_UNUSED(deviceId); qDebug() << "boton pulsado";
Both codes are unable to detect the game device.
Would somebody be as kind as to help me with this issue?
Thanks in advance.
-
Hi
This might be a silly question, but have you tested the joystick that its
indeed registered in Windows and works in games? -
Hi
I have not personally used it but been some posts about it here.
but if connectedGamepads() returns nothing im not sure what could be wrong with the detection.
And if your friend also has a logitech Extreme 3D on win 10 with same Qt, then it must be a windows/driver thing on your pc, preventing detection. -
Hi @vicfer89
Only for a test case, can you connect the gamepadConnected signal to check if qt is identifying your device ?
connect(QGamepadManager::instance(), &QGamepadManager::gamepadConnected, this, [](int deviceID){ qDebug() << deviceID << "has been connected"; });
-
Hi @vicfer89
Only for a test case, can you connect the gamepadConnected signal to check if qt is identifying your device ?
connect(QGamepadManager::instance(), &QGamepadManager::gamepadConnected, this, [](int deviceID){ qDebug() << deviceID << "has been connected"; });
@KillerSmath Nothing happens... XInput starts its thread as it have to, but no device is detected when the joystick is connected.