Move camera with joystick

joystick-nav.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2
 3print("Executing move script!")
 4
 5newScene()
 6
 7def movedJoystick(js):
 8    #print js.getButtons()
 9    #print js.getAxes()
10
11    # speed
12    rotspeed = 0.01
13    zoomspeed = 0.01
14    panspeed = 0.1
15
16    # buttons
17    buttons = js.getButtons()
18
19    if buttons & 1:
20        setCameraPanning(panspeed, 0) # left
21    if buttons & 8:
22        setCameraPanning(-panspeed, 0) # right
23    if buttons & 2:
24        setCameraPanning(0, -panspeed) # up
25    if buttons & 4:
26        setCameraPanning(0, panspeed) # down
27    
28    # analog stick
29    axes = js.getAxes()
30    if len(axes) >= 2:
31        #print axes[0], axes[1]
32        setCameraRotation(-axes[0] * rotspeed, axes[1] * rotspeed)
33        setCameraZoom(axes[2] * zoomspeed)
34
35loadGeometry("$VRED_EXAMPLES/geo/car.osb")
36updateScene()
37
38joystick = vrJoystick()
39joystick.connect(movedJoystick, joystick)
40
41vrLogWarning("Use your joystick for navigation.")