This is the procedure I want to follow. I want to go through all the joysticks available on the system and check if button 1 and 3 are pressed. If it is, I want to start using that joystick.
The problem is Purebasic only allows me to use one joystick. I tried a userlib but its example is broken.. it keeps saying Invalid memory access. And tried another method I found on the forum but that is outdated code
Your search is flawed, try searching for joystick in the forum. With this code you can work with multiple joysticks by changing the #JOYSTICKID1 constant. All values possible are in the JOYINFOEX structure
joy_an = joyGetNumDevs_()
joyCaps.JOYCAPS
For u=0 To joy_an ;how many joysticks in the system?
joyGetDevCaps_(u, joyCaps, SizeOf(JOYCAPS))
Debug "Joystick "+Str(u)
Debug joyCaps\szPname
Next u
If joySetCapture_(WindowID(1), #JOYSTICKID1, #Null, #False) = #JOYERR_NOERROR ;should be remplaced by initjoystick() in fullscreen
If joyGetDevCaps_(#JOYSTICKID1, joyCaps, SizeOf(JOYCAPS)) = #JOYERR_NOERROR
JoyXamp.l = joyCaps\wXmax - joyCaps\wXmin ;amplitude du mouvement du joystick en X
JoyYamp.l = joyCaps\wYmax - joyCaps\wYmin
; done
Else
Debug "Joystick error"
EndIf
EndIf
joyInfoEx.JOYINFOEX
joyInfoEx\dwFlags = #JOY_RETURNALL
joyInfoEx\dwSize = SizeOf(JOYINFOEX)
;---
joyGetPosEx_(#JOYSTICKID1, joyInfoEx.JOYINFOEX)
;---
if (joyInfoEx\dwButtons&1) And joystick_switch
blah bla
endif
x = joyInfoEx\dwXpos ;...