User Tools

Site Tools


accessing_20two_20joysticks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

accessing_20two_20joysticks [2018/03/31 13:19]
127.0.0.1 external edit
accessing_20two_20joysticks [2018/04/13 14:50]
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Accessing two joysticks===== =====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:\\ \\ +//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: 
 + 
 +<code bb4w> ​
         DEF PROCjoystick(id%,​ RETURN x%, RETURN y%, RETURN z%, RETURN b%)         DEF PROCjoystick(id%,​ RETURN x%, RETURN y%, RETURN z%, RETURN b%)
         LOCAL joyinfo{}         LOCAL joyinfo{}
Line 11: Line 13:
         b% = joyinfo.wButtons%         b% = joyinfo.wButtons%
         ENDPROC         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:\\ \\ +</​code>​ 
 + 
 +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: 
 + 
 +<code bb4w>
         PROCjoystick(0,​ x1%, y1%, z1%, buttons1%)         PROCjoystick(0,​ x1%, y1%, z1%, buttons1%)
         PROCjoystick(1,​ x2%, y2%, z2%, buttons2%)         PROCjoystick(1,​ x2%, y2%, z2%, buttons2%)
 +</​code>​
 +
 This will load the current joystick values into the specified variables. This will load the current joystick values into the specified variables.
accessing_20two_20joysticks.txt · Last modified: 2018/04/13 14:50 by richardrussell