I'm trying again.
Code:
import viz
import vizjoy
viz.go()
#Add a ground model
viz.add('tut_ground.wrl')
#Add a joystick
joy = vizjoy.add()
def UpdateJoystick():
#Get the joystick position
x,y,z = joy.getPosition()
#Get the twist of the joystick
twist = joy.getTwist()
#Move the viewpoint forward/backward based on y-axis value
if abs(y) > 0.2: #Make sure value is above a certain threshold
viz.MainView.move(0,0,-y*0.1,viz.BODY_ORI)
#Move the viewpoint left/right based on x-axis value
if abs(x) > 0.2: #Make sure value is above a certain threshold
viz.MainView.move(x*0.1,0,0,viz.BODY_ORI)
#Turn the viewpoint left/right based on twist value
if abs(twist) > 0.2: #Make sure value is above a certain threshold
viz.MainView.rotate(0,1,0,twist,viz.BODY_ORI,viz.RELATIVE_WORLD)
#UpdateJoystick every frame
vizact.ontimer(0,UpdateJoystick)
#Register a callback for joystick button events
def onjoybutton(e):
print 'Joystick button',e.button,'pressed'
viz.callback(vizjoy.BUTTONDOWN_EVENT,onjoybutton)