Graphics 640,480,0,2SetBuffer BackBuffer()Global Controller_port = 0Global info$ = " "Type joypad Field x1id Field y1id Field x2id Field y2id Field x1invert Field y1invert Field x2invert Field y2invertEnd Type Dim j.joypad(3)For port = 0 To 3 j(port) = New joypad j(port)x1id = 0 j(port)y1id = 0 j(port)x2id = 0 j(port)y2id = 0 j(port)x1invert = 1 ;toggles between 1 and -1 j(port)y1invert = 1 j(port)x2invert = 1 j(port)y2invert = 1Next readconfig()While Not KeyHit(1) ; start main loop esc for Quit Cls Text 50,30,"Use the MapAxis Function to grab the inputs" Text 50,50,info$ Text 50,70,"X1 axis :" + MapAxis(j(Controller_port)x1id,j(Controller_port)x1invert) Text 50,90,"Y1 axis :" + MapAxis(j(Controller_port)y1id,j(Controller_port)y1invert) Text 50,110,"X2 axis :" + MapAxis(j(Controller_port)x2id,j(Controller_port)x2invert) Text 50,130,"Y2 axis :" + MapAxis(j(Controller_port)y2id,j(Controller_port)y2invert) FlipWend ; end main loopEnd ; end programFunction MapAxis#( axis, invert ) Select axis Case 1 joy#=JoyX(Controller_port) Case 2 joy#=JoyY(Controller_port) Case 3 joy#=JoyZ(Controller_port) Case 4 joy#=JoyPitch(Controller_port)/180 Case 5 joy#=JoyRoll(Controller_port)/180 Case 6 joy#=JoyYaw(Controller_port)/180 Case 7 joy#=JoyU(Controller_port) Case 8 joy#=JoyV(Controller_port) End Select Return (joy# * invert)End FunctionFunction readconfig()filename = ReadFile ("joypad.cfg")If filename <> 0 For port = 0 To 3 tmp = ReadLine (filename) ; skip this line in the file j(port)x1id = ReadLine (filename) j(port)y1id = ReadLine (filename) j(port)x2id = ReadLine (filename) j(port)y2id = ReadLine (filename) j(port)x1invert = ReadLine (filename) j(port)y1invert = ReadLine (filename) j(port)x2invert = ReadLine (filename) j(port)y2invert = ReadLine (filename) Next CloseFile (filename) info$ = "config file opened"Else info$ = "load failed, or no .cfg file present"EndIf End Function