What you should be doing is selecting a controller index and initialising the device to a different controller each time.
Here's code I wrote for testing multiple controllers with force-feedback:
sync on
sync rate 0
dim EffectNames(9) as string
for i = 1 to 9
read EffectNames(i)
next
perform checklist for control devices
Quantity = checklist quantity()
if Quantity > 8 then Quantity = 8
for i = 1 to Quantity
set control device index i-1
set control device checklist string$(i), checklist value b(i)
set joystick deadzone 10
next
set control device index 0
global Angle as integer
global Effect as integer = 1
do
cls
Key$ = lower$( inkey$() )
if Key$ <> ""
if Key$ >= "1" and Key$ <= str$(checklist quantity())
` Select device
set control device index val(Key$)-1
else
` or select effect
for i = 1 to len("qwertyuio")
if Key$ = mid$("qwertyuio", i)
Effect = i
exit
endif
next
endif
endif
Angle = wrapvalue( Angle + 1 ) ` Continually changing angle for angle effect
print "Controller count: ", Quantity
print "Controller index: ", control device index(), " - ", control device name$()
TextToLeft(160, 48, "Joystick Up:", joystick up() )
TextToLeft(160, 64, "Joystick Down:", joystick down() )
TextToLeft(160, 80, "Joystick Left:", joystick left() )
TextToLeft(160, 96, "Joystick Right:", joystick right() )
TextToLeft(160, 128, "Joystick X:", joystick x() )
TextToLeft(160, 144, "Joystick Y:", joystick y() )
TextToLeft(160, 160, "Joystick Z:", joystick z() )
TextToLeft(160, 208, "Joystick Slider A:", joystick slider a() )
TextToLeft(160, 224, "Joystick Slider B:", joystick slider b() )
TextToLeft(160, 240, "Joystick Slider C:", joystick slider c() )
TextToLeft(160, 256, "Joystick Slider D:", joystick slider d() )
TextToLeft(160, 288, "Joystick Twist X:", joystick twist x() )
TextToLeft(160, 304, "Joystick Twist Y:", joystick twist y() )
TextToLeft(160, 320, "Joystick Twist Z:", joystick twist z() )
` Display Fire Details()
TextToLeft(400, 48, "Joystick Fire A:", joystick fire a() )
TextToLeft(400, 64, "Joystick Fire B:", joystick fire b() )
TextToLeft(400, 80, "Joystick Fire C:", joystick fire c() )
TextToLeft(400, 96, "Joystick Fire D:", joystick fire d() )
for Button=0 to 15
TextToLeft(520, 48+(Button*16), "Fire " + str$(Button) + ":", joystick fire x( Button ) )
TextToLeft(610, 48+(Button*16), "Fire " + str$(Button+16) + ":", joystick fire x( Button + 16 ) )
next Button
` Display HAT Details
for Hat=0 to 3
TextToLeft(400, 128+(16*Hat), "Joystick Hat Angle " + str$(Hat)+ ":", joystick hat angle(Hat) )
next Hat
TextToLeft(160, 352, "Buttons:", joystick information(0))
TextToLeft(160, 368, "Force Feedback:", joystick information(1))
TextToLeft(160, 384, "Z Axis:", joystick information(2))
TextToLeft(320, 352, "TX Axis:", joystick information(3))
TextToLeft(320, 368, "TY Axis:", joystick information(4))
TextToLeft(320, 384, "TZ Axis:", joystick information(5))
TextToLeft(480, 352, "Sliders:", joystick information(6))
TextToLeft(480, 368, "Hats:", joystick information(7))
TextToLeft(480, 384, "Deadzone:", joystick information(8))
text 0, 416, " Effect: " + EffectNames(Effect) + " (use letters qwertyuio to select)"
text 0, 448, "* Use number keys to select the controller"
text 0, 464, "* Use the spacebar to trigger the current effect"
if spacekey() = 1 and joystick information(1) = 1
if Effect = 1 then force shoot 100, 100
if Effect = 2 then force chainsaw 100, 100 ` *
if Effect = 3 then force impact 100, 100 ` *
if Effect = 4 then force up 100
if Effect = 5 then force down 100
if Effect = 6 then force left 100
if Effect = 7 then force right 100
if Effect = 8 then force angle 100, Angle, 100
if Effect = 9 then force water effect 100, 100 ` *
endif
sync
loop
function TextToLeft(x as integer, y as integer, t as string, v as integer)
text x-text width(t), y, t + str$(v)
endfunction
` effect names
data "shoot", "chainsaw", "impact", "up", "down", "left", "right", "angle", "water"
The for-loop near the beginning loads and initialises up to 8 controllers simultaneously, and then allows you to switch between them using the numbers on your keyboard.
The command used to switch between controllers is the SET CONTROL DEVICE INDEX command, while the SET CONTROL DEVICE command is used to set each individual controller up against each index. Once the device has been set up once, it is never touched again (unless you decide you need to refresh the controllers for some reason, eg someone removed or added or both to the available controllers).