Page 1 of 1
Using Multiple Joysticks in Purebasic
Posted: Tue Jul 22, 2008 8:49 pm
by Chirantha
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
Posted: Tue Jul 22, 2008 11:14 pm
by Fred
We added multiple joystick support in 4.30, so we the beta will be out, you could use it.
Posted: Tue Jul 22, 2008 11:45 pm
by Chirantha
Fred wrote:We added multiple joystick support in 4.30, so we the beta will be out, you could use it.
When will it be out?

I have a deadline to meet for my project.
Posted: Tue Jul 22, 2008 11:47 pm
by Fred
We have no date for now. If you have a deadline, just use API then (there is some examples on the forums IIRC).
Posted: Wed Jul 23, 2008 6:31 am
by Chirantha
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
Posted: Wed Jul 23, 2008 7:42 am
by Kaeru Gaman
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.
Posted: Wed Jul 23, 2008 9:14 am
by Chirantha
I'm using 4.20. And I got two joystick libs from purearea. None of them
seem to work at 100%.
Posted: Wed Jul 23, 2008 9:45 am
by Rings
Posted: Wed Jul 23, 2008 9:58 am
by djes
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 ;...