' Joystick routines $TYPECHECK ON Const JOYSTICKID1 = 0 Const JOYSTICKID2 = 1 Const JOY_POVCENTERED = -1 Const JOY_POVFORWARD = 0 Const JOY_POVRIGHT = 9000 Const JOY_POVLEFT = 27000 Const JOY_RETURNX = &H1 Const JOY_RETURNY = &H2 Const JOY_RETURNZ = &H4 Const JOY_RETURNR = &H8 Const JOY_RETURNU = &H10 Const JOY_RETURNV = &H20 Const JOY_RETURNPOV = &H40 Const JOY_RETURNBUTTONS = &H80 Const JOY_RETURNRAWDATA = &H100 Const JOY_RETURNPOVCTS = &H200 Const JOY_RETURNCENTERED = &H400 Const JOY_USEDEADZONE = &H800 Const JOY_RETURNALL = JOY_RETURNX Or JOY_RETURNY Or JOY_RETURNZ Or JOY_RETURNR Or JOY_RETURNU Or JOY_RETURNV Or JOY_RETURNPOV Or JOY_RETURNBUTTONS Const JOY_CAL_READALWAYS = &H10000 Const JOY_CAL_READRONLY = &H2000000 Const JOY_CAL_READ3 = &H40000 Const JOY_CAL_READ4 = &H80000 Const JOY_CAL_READXONLY = &H100000 Const JOY_CAL_READYONLY = &H200000 Const JOY_CAL_READ5 = &H400000 Const JOY_CAL_READ6 = &H800000 Const JOY_CAL_READZONLY = &H1000000 Const JOY_CAL_READUONLY = &H4000000 Const JOY_CAL_READVONLY = &H8000000 Const JOY_OFFSET = 10000 TYPE TJOYINFOEX dwSize AS LONG dwFlags AS LONG dwXpos AS LONG dwYpos AS LONG dwZpos AS LONG dwRpos AS LONG dwUpos AS LONG dwVpos AS LONG dwButtons AS LONG dwButtonNubmer AS LONG dwPOV AS LONG dwReserved1 AS LONG dwReserved2 AS LONG END TYPE DECLARE FUNCTION JoyGetPosEx LIB "WINMM" ALIAS "joyGetPosEx" _ (uJoyID AS LONG, JoyInfo AS TJOYINFOEX) AS LONG DECLARE FUNCTION JoyReleaseCapture LIB "WINMM" ALIAS "joyReleaseCapture" _ (uJoyID AS LONG) AS LONG DECLARE FUNCTION JoySetCapture LIB "WINMM" ALIAS "joySetCapture" _ (hWnd AS LONG, uJoyID AS LONG, uPeriod AS LONG, fChanged AS LONG) AS LONG DIM JoyInfoEx AS TJOYINFOEX DIM JoyX AS LONG, JoyY AS LONG JoySetCapture(Application.Handle, JOYSTICKID1, 1, 0) JoyReleaseCapture(JOYSTICKID1) JoyInfoEx.dwSize = 64 JoyInfoEx.dwFlags = JOY_RETURNALL JoyGetPosEx(JOYSTICKID1, JoyInfoEx) JoyX = JoyInfoEx.dwXpos JoyY = JoyInfoEx.dwYpos PRINT "Move your joystick, and press some buttons, CTRL+C to break." DO JoyGetPosEx(JOYSTICKID1, JoyInfoEx) IF JoyInfoEx.dwXpos > JoyX+JOY_OFFSET THEN PRINT "RIGHT" IF JoyInfoEx.dwXpos < JoyX-JOY_OFFSET THEN PRINT "LEFT" IF JoyInfoEx.dwYpos > JoyY+JOY_OFFSET THEN PRINT "DOWN" IF JoyInfoEx.dwYpos < JoyY-JOY_OFFSET THEN PRINT "UP" IF JoyInfoEx.dwButtons > - THEN PRINT "Button "; JoyInfoEx.dwButtons; " pressed." LOOP