JoyU# ( [port] )
Parameters
| port (optional) - which joystick to read; 0, the first attached stick (default) |
Description
|
Returns the joystick's first extra slider axis as a float from -1.0 to 1.0. Beyond the main x/y/z axes, joystick hardware can carry up to two slider channels, and JoyU reads the first of them. On flight kit that is classically the throttle lever or a trim wheel - an axis that stays where you leave it, unlike a sprung stick. That makes it a natural fit for anything "set and hold": engine power, zoom level, music volume in an options screen. The range runs -1.0 at one end of travel to 1.0 at the other, 0.0 in the middle - identical in spirit to JoyX, so the same scaling code works. JoyV reads the second slider, and JoyUDir gives a digital -1/0/1 version of this axis for menu-style flicks. Most ordinary gamepads have no slider hardware at all and report 0.0 here forever, so treat JoyU as a bonus for players with the right kit, never the only way to reach a feature. The modern Blitz3D+ runtime does not implement joystick input yet: JoyType always reports 0 and JoyU always returns 0.0 there, whatever is plugged in - so for now the example shows its no-joystick screen. See also: JoyV, JoyUDir, JoyX, JoyZ, JoyType. |
Example
; JoyU Example ; ------------ Graphics 640,480,0,2 SetBuffer BackBuffer() While Not KeyDown(1) Cls ; JoyU returns the stick's first extra slider as a float from ; -1.0 to 1.0 - on flight sticks this is often the throttle. ; JoyV reads the second slider the same way. u#=JoyU() v#=JoyV() If JoyType()=0 Then Text 0,0,"Esc: exit" Text 0,60,"No joystick detected - plug in a stick with a throttle slider." Text 0,80,"With one attached, the throttle gauge follows the U slider." Else Text 0,0,"Move the throttle/slider Esc: exit" End If ; A throttle gauge for each slider, filling from the centre For g=0 To 1 gx=260+g*90 If g=0 Then value#=u Else value#=v Color 90,90,90 Rect gx,140,50,240,False Line gx,260,gx+50,260 ; centre (value 0) mark Color 255,220,0 If value>0 Then Rect gx+2,260-value*118,46,value*118 If value<0 Then Rect gx+2,261,46,-value*118 Color 255,255,255 If g=0 Then Text gx+25,390,"U",True Else Text gx+25,390,"V",True Next Text 0,20,"JoyU() = "+u Text 0,40,"(JoyV() = "+v+")" Flip Wend End
Index