; GetJoy Example ; -------------- Graphics 640,480,0,2 SetBuffer BackBuffer() last_btn=0 While Not KeyDown(1) Cls ; GetJoy polls ALL the joystick buttons at once and returns the ; number of the one pressed (0 if none) - no need to test each ; button separately as with JoyDown/JoyHit. b=GetJoy() If b>0 Then last_btn=b If JoyType()=0 Then Text 0,0,"Esc: exit" Text 0,60,"No joystick detected - plug in a gamepad to try this example." Text 0,80,"With one attached, pressing any button lights the lamp below." Else Text 0,0,"Press any joystick button Esc: exit" End If ; A big lamp for the most recent button If last_btn>0 Then Color 255,220,0 Oval 295,200,50,50,True Color 255,255,255 Text 320,270,"Button "+last_btn,True End If Text 0,20,"GetJoy() now: "+b+" last button: "+last_btn Flip Wend End