testing joystick under Linux environment, support monitoring disconnection state and auto recovery mode

qjoystick

  • This qjoystick class is rewritten based on the library: https://github.com/drewnoakes/joystick. Please look at this library if you want to see more detail and explanation.
  • I create the library and examples in Qt. See the headers for more details of the class functions.

Note that, your gamepad should be recognized under Linux, for example, mine is located at "/dev/input/js0".

This library should work on Linux-based OS. I only tested the library on Ubuntu 18.04. It'll up to you to adapt to other OS.

If your gamepad is not found under Linux, try the xpad driver from https://github.com/paroj/xpad. Good luck!

  • Author: N.D.Quan - 10/2021

New functions added:

  • Auto reconnect to joystick after unplugging / plugging
  • Emit signals including:
    • button / axis values
    • disconnected state

Tested on:

  • Ubuntu 18.04
  • Qt5

Creation and Handle functions:

start(); ">
joystick = new Joystick("/dev/input/js0");
connect(joystick, &Joystick::onButtonChange,this,&JoystickMonitor::onButtonEvent);
connect(joystick, &Joystick::onAxisChange,this,&JoystickMonitor::onAxisEvent);
connect(joystick, &Joystick::onDisconnected,this,&JoystickMonitor::onDisconnectedEvent);
joystick->start();
Example results with x-mode joystick:
Axis  4 : 31341
Axis  4 : 22535
Axis  4 : 0
Button  2 : 1
Button  2 : 0
Button  1 : 1
Button  1 : 0
Button  2 : 1
Button  2 : 0
Button  0 : 1
Button  0 : 0
Axis  1 : -520
Axis  1 : -8549
Axis  1 : -18133
Axis  1 : -28494
Axis  1 : -16061
Axis  1 : -4405
Axis  1 : 0
Joystick is disconnected:  true
Joystick is disconnected:  true
Joystick is disconnected:  true
Joystick is disconnected:  true
Joystick is disconnected:  false
Button  0 : 0
Button  1 : 0
Button  2 : 0
Button  3 : 0
Button  4 : 0
Button  5 : 0
Button  6 : 0
Button  7 : 0
Button  8 : 0
Button  9 : 0
Button  10 : 0
Axis  0 : 0
Axis  1 : 0
Axis  2 : -32767
Axis  3 : 0
Axis  4 : 0
Axis  5 : -32767
Axis  6 : 0
Axis  7 : 0
Similar Resources

c++ testing framework

iutest iutest - iris unit test framework Welcome to the iutest iutest is framework for writing C++ tests. Features An XUnit test framework. Header onl

Sep 12, 2022

UT: C++20 μ(micro)/Unit Testing Framework

UT: C++20 μ(micro)/Unit Testing Framework

"If you liked it then you "should have put a"_test on it", Beyonce rule UT / μt | Motivation | Quick Start | Overview | Tutorial | Examples | User Gui

Dec 3, 2022

A micro unit-testing library for C/C++

µ-test A micro unit testing framework for C/C++ to get you up and running with unit-testing ASAP (even without libc). Usage Simply include the C and h

Dec 8, 2021

A tool to help in testing client/server robustness in the presence of malformed data.

Tool to assist in testing robustness of network-attached services in the presence of malformed data.

Aug 27, 2022

Bayesian A/B testing calculations for C++

BayesTest C++ Bayesian A/B testing calculations for C++ Based on this post by Evan Miller Also available in Rust Installation Include the header in yo

Nov 14, 2022

5G core testing solution

CoreScope CoreScope combines gNodeB and UE components without any radio transmission. It behaves like a UE and exposes an IP interface, but to the cor

Oct 21, 2022

A complete unit testing framework in a header

liblittletest A complete unit testing framework in a header liblittletest is an easy to use all-in-an-header testing framework; all you have to do in

Nov 11, 2021

Simple C testing framework

MrTest Simple C testing framework Usage Copy the mrtest.c and mrtest.h file into your project. In order to use the mrtest main: create a .c file that

Jul 20, 2022

Testing memleaks with /usr/share/bcc/tools/memleak

Testing memleaks with /usr/share/bcc/tools/memleak

Dec 13, 2021
Related tags
C++ Unit Testing Easier: A Header-only C++ unit testing framework

CUTE C++ Unit Testing Easier: A Header-only C++ unit testing framework usually available as part of the Cevelop C++ IDE (http://cevelop.com) Dependenc

Aug 31, 2022
Kernel-mode C++ unit testing framework in BDD-style

There is a lack of unit testing frameworks that work in OS kernel. This library closes that gap and is targeted for windows driver developers.

Oct 19, 2022
Modern c++17 unit testing framework on Microsoft Windows, Apple macOS, Linux, iOS and android.
Modern c++17 unit testing framework on Microsoft Windows, Apple macOS, Linux, iOS and android.

tunit Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android. Continuous Integration build status Operating system Status Windo

Apr 5, 2022
C++ Testing using spies and fakes for isolation and simulation
C++ Testing using spies and fakes for isolation and simulation

ELFspy is a library for linux for writing tests using fakes and spies in C++. For very large call graphs, the testing of the higher nodes can be diffi

Nov 22, 2022
Googletest - Google Testing and Mocking Framework

GoogleTest OSS Builds Status Announcements Release 1.10.x Release 1.10.x is now available. Coming Soon Post 1.10.x googletest will follow Abseil Live

Dec 8, 2022
Practical mutation testing tool for C and C++

Mull Mull is a tool for Mutation Testing based on LLVM/Clang with a strong focus on C and C++ languages. For installation and usage please refer to th

Dec 5, 2022
Header-only C++11 library for property-based testing.

autocheck Header-only C++11 library for QuickCheck (and later, SmallCheck) testing. Please consult the wiki for documentation. Install conan remote ad

Nov 20, 2022
The fastest feature-rich C++11/14/17/20 single-header testing framework
The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch Windows All dev branch Windows All doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of

Dec 1, 2022
C++ xUnit-like testing framework without macros

tst C++ testing framework. Installation, documentation, tutorials See WiKi. Features xUnit-like concepts minimal use of preprocessor macros declarativ

Sep 26, 2022
proftest is a C application for testing the quality of different operating system APIs for profiling.

proftest is a C application for testing the quality of different operating system APIs for profiling.

Jul 23, 2021