User Tools

Site Tools


accessing_20two_20joysticks

This is an old revision of the document!


Accessing two joysticks

by Richard Russell, April 2007

The BBC BASIC 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.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
accessing_20two_20joysticks.1522502344.txt.gz · Last modified: 2018/03/31 13:19 by 127.0.0.1