JoyYaw# ( [port] )
Parameters
| port (optional) - which joystick to read; 0, the first attached stick (default) |
Description
|
Returns the joystick's rotation-y axis scaled to degrees, from -180.0 to 180.0. One of the flight-stick trio alongside JoyPitch (rotation-x) and JoyRoll (rotation-z): extra rotation axes some hardware carries beyond the basic x/y/z, here the rotation about y - nose left/right on kit that provides it. In a flight sim JoyX/JoyY bank and climb while these three complete the attitude controls. The "degrees" are a convenience dressing, not a measured angle: the engine takes the axis's raw -1 to 1 travel and multiplies by 180, so centred rest is 0.0 and the extremes are +/-180.0. Treat it like any other axis value, just on a bigger scale. Most controllers don't have this axis at all - ordinary gamepads report 0.0 here forever - and sticks that do have a rudder twist more often wire it to rotation-z (JoyRoll). Axis layouts vary enough between makes that a control-settings screen with live readouts, like this family's examples, beats hard-wiring any one layout. The modern Blitz3D+ runtime does not implement joystick input yet: JoyType always reports 0 and JoyYaw always returns 0.0 there, whatever is plugged in - so for now the example shows its no-joystick screen. See also: JoyPitch, JoyRoll, JoyX, JoyHat, JoyType. |
Example
; JoyYaw Example ; -------------- Graphics 640,480,0,2 SetBuffer BackBuffer() While Not KeyDown(1) Cls ; JoyYaw returns the stick's rotation-y axis scaled to ; degrees, from -180.0 to 180.0. On a flight stick this is ; the nose left/right (rudder) attitude axis. yaw#=JoyYaw() If JoyType()=0 Then Text 0,0,"Esc: exit" Text 0,60,"No joystick detected - plug in a flight stick to try this example." Text 0,80,"With one attached, the heading needle below turns with the axis." Else Text 0,0,"Work the stick's yaw (rotation) axis Esc: exit" End If ; Top-down view: a heading dial, 0 degrees straight ahead cx=320 cy=280 Color 90,90,90 Oval cx-90,cy-90,180,180,False Line cx,cy-90,cx,cy-100 ; straight-ahead marker Text cx,cy-115,"ahead",True ; The needle swings right for positive yaw Color 255,220,0 Line cx,cy,cx+Sin(yaw)*85,cy-Cos(yaw)*85 Oval cx+Sin(yaw)*85-4,cy-Cos(yaw)*85-4,8,8,True Color 255,255,255 Text 0,20,"JoyYaw() = "+yaw+" degrees" Text 0,40,"(JoyPitch() = "+JoyPitch()+" JoyRoll() = "+JoyRoll()+")" Flip Wend End
Index