JoyVDir ( [port] )
Parameters
| port (optional) - which joystick to read; 0, the first attached stick (default) |
Description
|
Returns the joystick's second slider axis as a digital -1, 0 or 1. The digital reading of JoyV, and the twin of JoyUDir: -1 once the second slider is pushed past a third of its travel one way, 1 past a third the other way, and 0 around the middle. The generous dead zone swallows drift and off-centre rest positions for you. Reach for it when that slider should behave like a three-position switch - mode selectors, zoom steps, anything flicked rather than eased. For smooth analogue control, read JoyV instead; the same axis can serve both roles in different screens of one game. It reports the state, not the change: a held slider returns -1 or 1 every frame, so one-shot actions should watch for the value changing. And since second sliders are rare hardware - most gamepads and many flight sticks have nothing wired here - it reads 0 forever on kit without one, so always give the feature another binding too. The modern Blitz3D+ runtime does not implement joystick input yet: JoyType always reports 0 and JoyVDir always returns 0 there, whatever is plugged in - so for now the example shows its no-joystick screen. See also: JoyV, JoyUDir, JoyXDir, JoyType. |
Example
; JoyVDir Example ; --------------- Graphics 640,480,0,2 SetBuffer BackBuffer() While Not KeyDown(1) Cls ; JoyVDir boils the V slider down to a digital -1, 0 or 1: ; it reports -1 or 1 once the slider is pushed past a third ; of its travel. JoyUDir does the same for the U slider. dir=JoyVDir() If JoyType()=0 Then Text 0,0,"Esc: exit" Text 0,60,"No joystick detected - plug in a stick with two sliders." Text 0,80,"With one attached, the lamps below follow the V slider." Else Text 0,0,"Push the V slider to its ends Esc: exit" End If ; Three lamps: -1, 0 and 1 - the current reading lights up For lamp=-1 To 1 x=320+lamp*120 If dir=lamp Then Color 255,220,0 Oval x-35,240,70,70,True Else Color 90,90,90 Oval x-35,240,70,70,False End If Color 255,255,255 Text x,330,lamp,True Next Text 0,20,"JoyVDir() = "+dir Text 0,40,"(raw JoyV() = "+JoyV()+")" Flip Wend End
Index