Important: Please read the Qt Code of Conduct -

QJoysticks - A simple way to use joysticks with your project

  • Hello,

    Recently, I needed to use joystick input for one of my projects. After I finished, I thought that creating a library to handle joystick input could be beneficial for the Qt community.

    The library uses SDL to obtain joystick input from real devices, but it also implements a way to use the computer's keyboard as a joystick, with no additional code or hacks.

    As a side note, the QMake config files allow you to use this library with no additional fiddling under OS X and Windows. Under Linux, you may need to install libsdl2-dev in order to be able to compile and link the library.

    Finally, you are welcome to try it and (if you want) contribute to the project.

    Project repository:

    --Alex Spataru

  • Lifetime Qt Champion


    Thanks for sharing your work !

    Since you are working on game related inputs, you might also be interested by the qtgamepad module.

  • hi @alex_spataru , you have done a great job, i'm interested in integrating your project to my qt projects, i need to read position and other data from a joystick and display them in my qt gui, but i didn't know how to do that using your code, could youd please guide me though this process.

  • Hi Alex, the new QGamePad introduced in Qt5.7 up to Qt5.10 isn't detecting the most common XBox 360 Controller (Win7 to Win10). I stumbled over SDL which seems to have a working interface for controllers and then Google showed me your post. QJoysticks is working prefectly!

    Thank you very much for your invested time - it's golden.


    PS: I only needed to add

    #undef main //before int main() to avoid interferences with SDL and Qt

  • hi,i'm new in qt and i want to run this example with qt creator,but i get these errors:

    1.error: skipping incompatible QJoysticks-master\QJoysticks-master\lib\SDL\bin\windows\mingw/SDL2.dll when searching for -lSDL2

    2.error: skipping incompatible QJoysticks-master\QJoysticks-master\lib\SDL\bin\windows\mingw/SDL2.dll when searching for -lSDL2

    3.error: collect2.exe: error: ld returned 1 exit status

    I do not know how to solve these

  • Lifetime Qt Champion

    @masoomehsn hi and welcome to devnet,

    Which version of Qt are you using ?
    With which compiler ?
    How did you get the QJoysticks .dll ?
    Which architecture are they ?