Joystick axis access

BlitzMax Forums/BlitzMax Programming/Joystick axis access

Shagwana(Posted 2005) [#1]
This might be usefull for some of you ...
'Constants already defined in freejoy.bmx 
'Const JOY_X=0
'Const JOY_Y=1
'Const JOY_Z=2
'Const JOY_R=3
'Const JOY_U=4
'Const JOY_V=5
'Const JOY_YAW=6
'Const JOY_PITCH=7
'Const JOY_ROLL=8
'Const JOY_HAT=9
'Const JOY_WHEEL=10

'Function to access the axis ... returns -1 to 1 depending on the location of that axis
Function JoyAxis#( axis,port=0 )
  SampleJoy port
  Return joy_axis[port*16+axis]
  End Function


Include that in your code, now you can access all joystick axis in a uniformed manner (like with a for loop) much like the buttons of a joystick!. Make sure you check that the axis is available for use (JoyAxisCaps() command).


Oddball(Posted 2005) [#2]
I'd rather have a JoyHit() command, but thanks anyway.