Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trying Qt Gamepad Simple example with a wheel steering gamepad

Trying Qt Gamepad Simple example with a wheel steering gamepad

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 654 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.
  • I Offline
    I Offline
    iodev
    wrote on last edited by
    #1

    Hi,

    I tried Qt Gamepad Simple example with a wheel steering gamepad( Thrustmaster T80) on Linux. It gets a good communication with that except some buttons don't work.

    I can see Qt uses evdev as backend. I tested it with evtest and it recognizes every button. I saw it gives 8 Axes and 14 buttons on jtest-gtk and the structure is a bit different in qgamepadmanager.h. I tried to add more values to that but it was for nothing. Any idea about what would I have to change? Thanks

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      when interfacing with gamepads in linux I recommend using the system level event interface evdev (/dev/input/inputxx) instead of QtGamepad. It's lower level but gives more control. As long as the kernel driver correctly supports the gamepad then you can trap whatever events you wish.

      If you meet the AI on the road, kill it.

      I 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        when interfacing with gamepads in linux I recommend using the system level event interface evdev (/dev/input/inputxx) instead of QtGamepad. It's lower level but gives more control. As long as the kernel driver correctly supports the gamepad then you can trap whatever events you wish.

        I Offline
        I Offline
        iodev
        wrote on last edited by
        #3

        @Kent-Dorfman That idea sounds very interesting, using evdev instead of QtGamepad. Would you have any example of it to learn how to do it?

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by Kent-Dorfman
          #4

          There is programmimg information via google search.

          You open the correct /dev/input/ device file in blocking mode (if you are using a separater polling thread), or nonblocking from your main thread event loop. read(2) calls return available events from the device, containing timestamp, event type, and value. There are also ioctl calls to filter noise and make axis less jittery, and increase center dead-zones.

          livevdev is a higher level wrapper library available...YMMV

          The main header of interest in linux is: /usr/include/linux/input.h

          I generally register callback lambda functions to execute when an axist of interest value changes, or a button state changes. There are many options what you do with the raw events from your read() calls.

          If you meet the AI on the road, kill it.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            iodev
            wrote on last edited by iodev
            #5

            I answer myself about this question because the documentation about QtGamepad is very brief. After some investigation this is what you have to do to get every button working with QtGamepad. I used these sentences of code:

            m_gamepad = new QGamepad(*gamepads.begin(), this);
            QGamepadManager* manager = QGamepadManager::instance();
            manager->configureButton(m_gamepad->deviceId(),  QGamepadManager::ButtonX);
            

            You need to start your program and press which button you want as button X. I did that changing "QGamepadManager::ButtonX" for every button I had in my gamepad. It saved that configuration in this PC.
            If you want to reset the configuration you registered:

            manager->resetConfiguration(m_gamepad->deviceId());
            

            That's all.

            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