;
; ------------------------------------------------------------
;
; PureBasic - Joystick example file
;
; (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;
If InitJoystick() = 0
MessageRequester("Error", "Can't open DirectX 7 or no joysticks are availables.", 0)
End
EndIf
If OpenWindow(0, 100, 100, 300, 260, "PureBasic - Joystick Demo")
MessageRequester("Information", "This will test the joystick in a window.", 0)
x = WindowWidth(0)/2
y = WindowHeight(0)/2-20
Repeat
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow : Quit = 1 : EndIf
Until Event = 0
Delay(20) ; a little delay (20 milli seconds -> 50 fps)
If ExamineJoystick()
x+JoystickAxisX()
y+JoystickAxisY()
If JoystickButton(1)
MessageRequester("Info", "Button 1 has been pressed", 0)
EndIf
If JoystickButton(2)
MessageRequester("Info", "Button 2 has been pressed", 0)
EndIf
If StartDrawing(WindowOutput(0)) ; Set the drawing output to our window
FrontColor(RGB(255,0,0)) ; Use the RED colour
Box(x, y, 10, 10) ; Draw a little box
StopDrawing() ;
EndIf
EndIf
Until Quit = 1
EndIf
End ä