PyGame is a Python library featuring a component (“Joystick“) to read inputs from a GamePad, JoyPad, or similar HID device and cast their values to a tuple for implementation into the program.

One “bug” I noticed is that when the program is first loaded, all analog joysticks must be moved to their maximums for the program to interpolate the intermediate “steps”. Out Of The Box, it assigns any movement outside of (0,0) as (1,1) until the mechanical limit. As the joy is returned to center, it then understands all of the (0.001-0.999,0.001-0.999) increments along the analog map and retains that value map

As such, it may be beneficial to add an initial “Calibration” screen which forces the user to move all joysticks before beginning the rest of the program.

The below linked file, gamepad-test-pygame, was tested with a Logitech F310 gamepad. It reads the D-Pad (“HAT”), both joysticks, and A, B, X, Y, L1, L2, R1, R2 buttons and sends the sterilized data out to a Serial Port.
Note that a deadzone was added to (0,0) on the joysticks and that the data was rounded to 3 decimals and that a TIMEREVENT is used to poll the HID device every 100ms.