Here's a little program I wrote a few years ago to test PS2 controllers, handy for detecting stuck or dead buttons.
Wenlock
'*** PS Controller diagnostic by Wenlock Burton 2008
'
'*** Displays buttons pressed on controller 1 and 2
'
' proc_buttons takes buttons and returns names in button$
open window 640,512
setrgb 0,0,20,20
setrgb 1,0,255,255
curbuf=0
buttons=0
buttons1=0
buttons2=0
button$=" "
button1$=" "
button2$=" "
cbuttons=0
fgred=25: fggreen=255: fgblue=255
cbred=105: cbgreen=105: cbblue=105
clear window
gosub disp_result
gosub flip_screen
label loop
gosub read_buttons
rem Process Controller 1 buttons
buttons=buttons1
gosub proc_buttons
button1$=button$
rem process Controller 2 buttons
buttons=buttons2
gosub proc_buttons
button2$=button$
gosub disp_result
gosub flip_screen
goto loop
label flip_screen
setdispbuf curbuf
curbuf=1-curbuf
setdrawbuf curbuf
return
label read_buttons
cbuttons=0
buttons1=0
buttons2=0
label read_kbd
cbuttons=buttons1+buttons2
if cbuttons<1 then
buttons1=peek("port1")
buttons2=peek("port2")
else goto read_kbd
fi
return
label proc_buttons
button$=""
if and (buttons,1)=1 then button$="Select "
fi
if and (buttons,2)=2 then button$=button$+"L3 "
fi
if and (buttons,4)=4 then button$=button$+"R3 "
fi
if and (buttons,8)=8 then button$=button$+"Start "
fi
if and (buttons,16)=16 then button$=button$+"Up "
fi
if and (buttons,32)=32 then button$=button$+"Right "
fi
if and (buttons,64)=64 then button$=button$+"Down "
fi
if and (buttons,128)=128 then button$=button$+"Left "
fi
if and (buttons,256)=256 then button$=button$+"L2 "
fi
if and (buttons,512)=512 then button$=button$+"R2 "
fi
if and (buttons,1024)=1024 then button$=button$+"L1 "
fi
if and (buttons,2048)=2048 then button$=button$+"R1 "
fi
if and (buttons,4096)=4096 then button$=button$+"Triangle "
fi
if and (buttons,8192)=8192 then button$=button$+"Circle "
fi
if and (buttons,16384)=16384 then button$=button$+"Cross "
fi
if and (buttons,32768)=32768 then button$=button$+"Square "
fi
return
label disp_result
clear window
gosub cbars
setrgb 1,fgred, fggreen, fgblue
text 86,50,"Wenlock's Playstation Controller Diagnostic"
text 100,400,"Controller 1 buttons - "+button1$
text 100,420,"Controller 2 buttons - "+button2$
buttons=0
button$=""
button1$=""
button2$=""
return
label cbars
rem White bar
setrgb 1,cbred,cbgreen,cbblue
fill rectangle 0,0 to 80,512
rem Yellow bar
setrgb 1,cbred,cbgreen,0
fill rectangle 80,0 to 160,512
rem Cyan bar
setrgb 1,0,cbgreen,cbblue
fill rectangle 160,0 to 240,512
rem Violet bar
setrgb 1,cbred,0,cbblue
fill rectangle 240,0 to 320,512
rem Green bar
setrgb 1,0,cbgreen,0
fill rectangle 320,0 to 400,512
rem Red bar
setrgb 1,cbred,0,0
fill rectangle 400,0 to 480,512
rem Blue bar
setrgb 1,0,0,cbblue
fill rectangle 480,0 to 560,512
rem Black bar
setrgb 1,0,0,0
fill rectangle 560,0 to 640,512
for r=220 to 224
rem circle
circle 320, 240, r
next r
setrgb 1,25,255,255
return
[/font]