In examples for DarkBasicPro there is a code
Rem Project: TwoControlDevicesThatFire
Rem Created: 21/03/2009 18:26:28
rem simple program to demonstrate using TWO controllers
rem for movement and firing
rem Init app
sync on : sync rate 60
rem Detect second controller (joystick autoselects first one)
perform checklist for control devices
if checklist quantity()>1
set control device index 1
set control device checklist string$(2)
endif
rem Position players
dim x(2) : x(1)=200 : x(2)=440
dim y(2) : y(1)=200 : y(2)=200
dim s(2) : s(1)=0 : s(2)=0
rem Main loop
do
`
rem Move players and detect fire buttons
for i=1 to 2
set control device index i-1
x(i)=x(i)+(joystick x()/900)
y(i)=y(i)+(joystick y()/900)
for n=0 to 32 : if joystick fire x(n)=1 : s(i)=n : endif : next n
next i
`
rem Keep players in screen
for n=1 to 2
if x(n)<0 then x(n)=0
if y(n)<0 then y(n)=0
if x(n)>640 then x(n)=640
if y(n)>480 then y(n)=480
next n
`
rem Draw players
cls 0
ink rgb(255,0,0),0 : circle x(1),y(1),9+(s(1)*3) : center text x(1),y(1)-6,str$(s(1))
ink rgb(0,255,0),0 : circle x(2),y(2),9+(s(2)*3) : center text x(2),y(2)-6,str$(s(2))
`
rem User prompt
ink rgb(255,255,0),0
if checklist quantity()<2
center text 320,20,\"ONLY ONE CONTROLLER DETECTED\"
else
center text 320,20,checklist string$(1)+\" AND \"+checklist string$(2)
endif
`
rem Update screen
sync
`
rem End loop
loop
All works, if control devices have the different names.
If the names identical, then works only one.
Noticed yet, if a control device has the name GAMEPAD, then commands work not correctly:
Return Integer=JOYSTICK UP()
Return Integer=JOYSTICK DOWN()
Return Integer=JOYSTICK LEFT()
Return Integer=JOYSTICK RIGHT()
I need two devices.
That to do?