I run jkeys (uses pygame) and bCNC (uses pyserial) on a RPi to map a gamepad’s buttons and axes to keystrokes. All button and axis ids have been previously identified with jstest.
These keys are associated to either standard or custom shortcuts. Look here for more info.
All three components are free and open source.
EDIT:
Reading the whole thread again it seems that you wish your jogging script to be the one talking to the serial port. Is this jogging for the sake of jogging? Don’t you wish to run a job after you jog somewhere?
If yes, it seems best if the gamepad interfaces with the gcode sender and the gcode sender interfaces with the controller via the serial port.