Return joystick to neutral position

This code looks very much like my mouse code for mobile devices.

Try

joystickloc = joystick.getY()

if moved == False:
     if joystickloc != joystickrec:
          moved = True
          thisExp.addData('Moved',round(t*1000)) # reaction time for movement

yMove = joystickloc-joystickrec  # Check whether joystick moved on Y dimension

# Increase or decrease sizeChange variable
# depending on direction of movement
# e.g., make smaller if pushing away

if yMove >  0:
    sizeChange1 -= .0066
    sizeChange2 -= .01
elif yMove <  0:
    sizeChange1 += .0066
    sizeChange2 += .01

P.S. What’s the difference between joystick.device.getY() and joystick.getY() ?

1 Like