=====Accessing two joysticks===== //by Richard Russell, April 2007//\\ \\ The BBC BASIC [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin4.html#adval|ADVAL]] statement allows you to access only one joystick. If you need to access two joysticks you can do that using the **Windows API**. The procedure below allows you to read the **X**, **Y**, **Z** and **button** values for either joystick: DEF PROCjoystick(id%, RETURN x%, RETURN y%, RETURN z%, RETURN b%) LOCAL joyinfo{} DIM joyinfo{wXpos%, wYpos%, wZpos%, wButtons%} SYS "joyGetPos", id%, joyinfo{} x% = joyinfo.wXpos% y% = joyinfo.wYpos% z% = joyinfo.wZpos% b% = joyinfo.wButtons% ENDPROC To access the first joystick set the first parameter **id%** to 0; to access the second joystick set **id%** to **1**.\\ \\ You would call the procedure using code similar to the following: PROCjoystick(0, x1%, y1%, z1%, buttons1%) PROCjoystick(1, x2%, y2%, z2%, buttons2%) This will load the current joystick values into the specified variables.