Here is a quick script to test input events from your connected keyboard, mouse and/or joysticks.
It is built on similar scripts found already, but I’ve added handlers here for hats and axes, plus displayed the names of all inputs, so I could easily read what my wireless Xbox 360 controller was doing.

Hopefully this will help mapping of your controllers and joysticks for gameplay programming. This script requires Python and Pygame, and should theoretically run on any platforms they support.
import sys, pygame
from pygame.locals import *
pygame.init()
size = 300, 60
screen = pygame.display.set_mode(size)
njoy = pygame.joystick.get_count()
print "Number of joysticks detected = ",njoy
for j in range(njoy):
gamepad = pygame.joystick.Joystick(j)
gamepad.init()
print "Joystick #",j+1,"(", gamepad.get_name(),")"
print " nb of buttons = ", gamepad.get_numbuttons()
print " nb of mini joysticks = ", gamepad.get_numhats()
print " nb of trackballs = ", gamepad.get_numballs()
print " nb of axes = ", gamepad.get_numaxes()
clock = pygame.time.Clock()
keepGoing = True
while keepGoing:
clock.tick(30)
for event in pygame.event.get():
if event.type == JOYAXISMOTION:
print "Joystick:", event.joy, " axis:", event.axis, " value:", event.value
elif event.type == JOYHATMOTION:
print "Joystick:", event.joy, " hat:", event.hat, " value:", event.value
elif event.type == JOYBUTTONDOWN:
print "Joystick:", event.joy, " button", event.button, "pressed"
elif event.type == JOYBUTTONUP:
print "Joystick:", event.joy, " button", event.button, "released"
elif event.type == pygame.KEYDOWN:
keyName = pygame.key.name(event.key)
print "key pressed:", keyName
if event.key == pygame.K_ESCAPE:
keepGoing = False
elif event.type == pygame.MOUSEBUTTONDOWN:
print "mouse down:", pygame.mouse.get_pos()
elif event.type == pygame.MOUSEBUTTONUP:
print "mouse up:", pygame.mouse.get_pos()
if event.type == pygame.QUIT:
keepGoing = False
pygame.quit()
inputTest.py