If you use PERFORM CHECKLIST FOR CONTROL DEVICES, you may get a list of the attached controllers using checklist string$().
If so, then like BN2 said, swap between the control devices for input:
perform checklist for control devices
td=checklist quantity()
if td=0 then break "can't find any control devices"
dim dev$(td)
for d=1 to td
dev$(d)=checklist string$()
next d
d=0
do
inc d
if d > td then d=1
set control device dev$(d)
text 0,0,str$(control device name$())
loop
I don't know which commands you'd use to receive the buttons inputs. Maybe once the control device is set you could use the joystick commands. There seem to only be control device x() y and z commands. But after switching the device, see if the joystick commands work for it.
Enjoy your day.