C++ program for Linux that reads controller inputs using SDL2 library.
You'll need SDL2 library: https://wiki.libsdl.org/SDL2/Installation
g++ controller.cpp -o controller -lSDL2
Connect a controller to your pc and run ./controller.
Kudos to @xBogas who made most part of the code.