Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Qt Gamepad with Logitech
Forum Updated to NodeBB v4.3 + New Features

Qt Gamepad with Logitech

Scheduled Pinned Locked Moved Unsolved Game Development
9 Posts 4 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • vicfer89V Offline
    vicfer89V Offline
    vicfer89
    wrote on last edited by vicfer89
    #1

    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.

    aha_1980A 1 Reply Last reply
    0
    • vicfer89V vicfer89

      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.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @vicfer89

      • which Qt version is that?
      • on which operating system?

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • vicfer89V Offline
        vicfer89V Offline
        vicfer89
        wrote on last edited by
        #3

        Hi @aha_1980

        Qt Version is 5.11.2.
        Operating system is Windows 10.

        aha_1980A 1 Reply Last reply
        0
        • vicfer89V vicfer89

          Hi @aha_1980

          Qt Version is 5.11.2.
          Operating system is Windows 10.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @vicfer89 is your friend using the same hard- and software?

          Qt has to stay free or it will die.

          1 Reply Last reply
          1
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            This might be a silly question, but have you tested the joystick that its
            indeed registered in Windows and works in games?

            1 Reply Last reply
            0
            • vicfer89V Offline
              vicfer89V Offline
              vicfer89
              wrote on last edited by
              #6

              @aha_1980

              Same version of Qt, but different computers... Qt version is the same as well.

              @mrjj

              Yes, I fly regularly with X-Plane with the joystick i'm trying to read...

              Has anyone employ this library?

              KillerSmathK 1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                1
                • vicfer89V vicfer89

                  @aha_1980

                  Same version of Qt, but different computers... Qt version is the same as well.

                  @mrjj

                  Yes, I fly regularly with X-Plane with the joystick i'm trying to read...

                  Has anyone employ this library?

                  KillerSmathK Offline
                  KillerSmathK Offline
                  KillerSmath
                  wrote on last edited by KillerSmath
                  #8

                  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";
                  });
                  

                  @Computer Science Student - Brazil
                  Web Developer and Researcher
                  “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                  vicfer89V 1 Reply Last reply
                  2
                  • KillerSmathK KillerSmath

                    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";
                    });
                    
                    vicfer89V Offline
                    vicfer89V Offline
                    vicfer89
                    wrote on last edited by
                    #9

                    @KillerSmath Nothing happens... XInput starts its thread as it have to, but no device is detected when the joystick is connected.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved