Sunday 17 June 2012

Joystick test application (Qt + SFML) [Windows/Linux]

Previously, a demonstration for joystick control was published. It was a demo that made use of Windows DirectInput COM-library with Qt to retrieve the data from joystick - buttons' state and axes positions. Since DirectInput is not a cross-platform library, a new cross-platform demo, based on SFML library is prepared (library has a very liberate license).

How demo works.
The main class of this demo is XInput (include header xinputGamepad.h). It is instantiated and then initialization method initInput(joystick_id) is called, where joystick_id is the index of a joystick in the system starting from zero. Then a timer is set up to generate timeout event every 15 milliseconds (smaller values increases refresh rate and responsiveness), where update() method is called, and joystick state is retrieved using getHorizontal(), getVertical(), isKeyPressed(key_id)getRawAxis(axis_id) and other class functions. 



  Download link:
       application demo (zip): Public_QtJoystick-SFML-Win32-386 - version 0.3a [Win32/i386] - 5.91 MiB
       source code (zip): Source_QtJoystick-SFML - version 0.3a - 233 KiB

    It is written with Qt 4.8.1 for Desktop. Source code is available for download and use under the LGPLv2 or MIT license.

  Usage:
1) Download Public_QtJoystick-SFML.zip archive
2) Unpack it with zip extractor
3) Plug in the joystick (if it isn't plugged in yet)
4) Run QtJoystick-SFML

If you don't have a joystick yet, but want to test the application, there is a joystick emulator for Windows PPJoy (download link, git repository). If you know keyboard/mouse-to-joystick emulator for Linux, please post it in the comments.






Locations of visitors to this page