Wednesday, 6 July 2011

Joystick test application (Qt + DirectInput8) [Windows]

  This application is provided to test joystick output using DirectInput8. It reports the axis positions, as well as the buttons' state.

  Download link:
       application archive (zip): Public_QtJoystick - version 0.2b [Win32/i386] - 4.53 MiB
       source code (zip): Source_QtJoystick - version 0.2b - 292 KiB

    It will be later used in my OGL6 tank game and robot simulation (which is based on the game's engine). Any suggestions, questions and comments are welcome. It is distributed under the LGPL or MIT license on your choice.

    It is written with Qt SDK 1.1 & QtCreator 2.1. Source code is available for download and use under the LGPLv2 or MIT license.

  Usage:
1) Download Public_QtJoystick .zip archive
2) Unpack it with windows zip unpacker or any archive tool (like 7-zip) to any directory
3) Plug in the joystick (if it isn't plugged yet)
4) Run QtJoystick.exe

4 comments:

  1. hi your program is great, when i run it everything is ok, but when i open the project with Qt run it, it gives me a lot of errors from dinput.h file. Im using linux. Thanks for your answer. Your demo is really great XD.

    ReplyDelete
    Replies
    1. Hello, Luis. Unfortunately, this program shall compile only under Windows, because it makes use of Windows-dependent component: DirectX, for which there isn't cross-platform header file dinput.h.

      Your program could start in Linux inside Windows emulator (Linux can not execute *.exe Win32/PE files natively).

      To solve your problem, you shall probably try to use SFML library (http://www.sfml-dev.org/). Just download and run SFML library for Linux 32/64 bits and follow documentation. Joystick usage is very simple and straightforward with that library.
      Look at C++ class sf::Input (http://www.sfml-dev.org/documentation/1.6/classsf_1_1Input.php).

      I will write small cross-platform demo for Qt+SFML to support Joystick under Linux/Windows within few days.

      Delete
  2. Hi. I tried compiling your code, but I get the following errors:

    line: for (int r = 0; r < std::min(tblAxis.rows(),8); r++)

    ..\QtJoystick\mainwindow.cpp(48) : error C2589: '(' : illegal token on right side of '::'
    ..\QtJoystick\mainwindow.cpp(48) : error C2059: syntax error : '::'
    ..\QtJoystick\mainwindow.cpp(48) : error C2143: syntax error : missing ';' before ')'
    ..\QtJoystick\mainwindow.cpp(48) : error C2143: syntax error : missing ';' before ')'
    ..\QtJoystick\mainwindow.cpp(49) : error C2143: syntax error : missing ';' before '{'

    ReplyDelete
  3. Your code example is excellent and ran straight away. Also, it was very easy to integrate into my test application. Many thanks for sharing!

    ReplyDelete

Locations of visitors to this page