'********************************************************************************* '* This program shows what the QBASIC source is for getting the '* joysticks actions (moves and buttonpresses) '* Jakob Krarup - Jake@post5.tele.dk '* http://www.welcome.to/QBASIC '********************************************************************************* DECLARE SUB PrintJoystickStatus () DECLARE SUB GetJoystick () TYPE JoystickType 'Here we declare the joystick type XKoordinate AS INTEGER YKoordinate AS INTEGER Button1 AS INTEGER Button2 AS INTEGER Button3 AS INTEGER END TYPE DIM SHARED Joystick AS JoystickType COLOR 0, 1 'makes a blue background CLS 'clears screen COLOR 15, 3 'white text on cyan background PRINT SPACE$(80) 'Prints the titlebar LOCATE 1, 1 PRINT " Joystick version 1.0 By Jakob Krarup " COLOR 11, 1 'Light cyan on blue LOCATE 25, 55 PRINT "Press any key to exit"; DO 'runs a loop Key$ = INKEY$ 'stores content of keyboard in Key$ GetJoystick 'We get joystick koordinates PrintJoystickStatus 'And display them LOOP WHILE Key$ <> CHR$(27) 'loop while isn't pressed SUB GetJoystick Joystick.XKoordinate = STICK(0) Joystick.YKoordinate = STICK(1) Joystick.Button1 = STRIG(1) Joystick.Button2 = STRIG(5) Joystick.Button3 = STRIG(7) END SUB SUB PrintJoystickStatus LOCATE 8, 1 'go down 8 lines PRINT TAB(15); Joystick.XKoordinate; TAB(25); " X-koordinate" PRINT TAB(15); Joystick.YKoordinate; TAB(25); " Y-koordinate" PRINT TAB(15); Joystick.Button1; TAB(25); " Button 1" PRINT TAB(15); Joystick.Button2; TAB(25); " Button 2" PRINT TAB(15); Joystick.Button3; TAB(25); " Button 3" END SUB