Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57078

QGamepad and QGamepadManager doesn't detect the disconnection of a gamepad

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • None
    • 5.7.0
    • GamePad
    • None
    • Linux, Ubuntu 64Bit 16.04

    Description

      Dear guy's,

      I am running my software in ubuntu 16.04

      I am using QGamepad and QGamepadManager for get the state of the joysticks & button of a gamepad and it works well: http://doc.qt.io/qt-5/qgamepad.html

      But i have some troubles for detect the disconnection of the gamepad:

      • With QGamepad: if i remove the gamepad, "m_gamepad->isConnected()" still have the "true" value
      • With QGamepad: The event connectedChanged is never trigered when i disconnect the gamepad
      • With QGamepadManager: The event QGamepadManager::connectedGamepadsChanged is never trigered when i connect/disconnect a gamepad
      • With QGamepadManager: The event QGamepadManager::gamepadConnected is never trigered when i connect/disconnect a gamepad
      • With QGamepadManager: The event QGamepadManager::gamepadDisconnected is never trigered when i connect/disconnect a gamepad
      • With QGamepad or QGamepadManager: When my gamepad is disconnected I see this message in the console "Gamepad: Could not read from input device (Aucun périphérique de ce type)",

      Other events of QGamepadManager and QGamepad works well.

      The problem is for detect the "disconnection" of a gamepad.

      Maybe QGamepad use an external software/tool/lib, and when a gamepad is disconnected, this tool is stoped. Because if i disconnect and reconnect the gamepad, with QGamepadManager I will no more get the axis and button events (QGamepadManager events are triggered for all gamepads, so not just one)

      You can reproduce it with this code:
      QT += gamepad

      #include <QtGamepad/QGamepad>

      connect(QGamepadManager::instance(), &QGamepadManager::connectedGamepadsChanged, this,[]()

      { qDebug() << "connected gamepads changed:"; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::gamepadConnected, this,[](int deviceId)

      { qDebug() << "gamepad connected:" << deviceId; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::gamepadDisconnected, this,[](int deviceId)

      { qDebug() << "gamepad disconnected:" << deviceId; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::gamepadButtonPressEvent, this,[](int deviceId, QGamepadManager::GamepadButton button, double value)

      { qDebug() << "button press event:" << deviceId << button << value; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::gamepadButtonReleaseEvent, this,[](int deviceId, QGamepadManager::GamepadButton button)

      { qDebug() << "button release event:" << deviceId << button; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::gamepadAxisEvent, this,[](int deviceId, QGamepadManager::GamepadAxis axis, double value)

      { qDebug() << "axis event:" << deviceId << axis << value; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::buttonConfigured, this,[](int deviceId, QGamepadManager::GamepadButton button)

      { qDebug() << "button configured:" << deviceId << button; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::axisConfigured, this,[](int deviceId, QGamepadManager::GamepadAxis axis)

      { qDebug() << "axis configured:" << deviceId << axis; }

      );
      connect(QGamepadManager::instance(), &QGamepadManager::configurationCanceled, this,[](int deviceId)

      { qDebug() << "configuration canceled:" << deviceId; }

      );

      Output example:
      axis event: 654 0 -0.275959
      axis event: 654 1 0.370932
      axis event: 654 3 -0.0213169
      axis event: 654 0 -0.279225
      axis event: 654 1 0.361257
      axis event: 654 0 -0.246754
      axis event: 654 1 0.280629
      axis event: 654 0 -0.15584
      axis event: 654 1 0.13225
      axis event: 654 3 -0.0248569
      axis event: 654 0 -0.090898
      axis event: 654 1 0.0515908
      Gamepad: Could not read from input device (Aucun périphérique de ce type)

      Atached you will find a software draft, using the two methods for detect gamepad disconnection

      Attachments

        Activity

          People

            janichol Andy Nichols
            caipiblack Mathieu Caldeira
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: