Hi,
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
Can anyone help?
Thanks
Using Multiple Joysticks in Purebasic
Well I look at the tips and tricks section but the code and the code on most user libs are outdated.. I'm getting weird errors when I try to complile.
Can someone help me get those codes to work? I'm so close yet so far
http://www.purebasic.fr/english/viewtop ... =joysticks
Can someone help me get those codes to work? I'm so close yet so far
http://www.purebasic.fr/english/viewtop ... =joysticks
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
it would be helpful to know wich PB-Version you are using.
also, have a look on www.purearea.net
you can find the Code-Archive and the PBOSL there.
both provide sources.
also, have a look on www.purearea.net
you can find the Code-Archive and the PBOSL there.
both provide sources.
oh... and have a nice day.
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
Code: Select all
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 ;...