psychopy.org | Reference | Downloads | Github

Joystick for PsychoPy3 builder

Hi everyone, I am trying out PsychoPy (I am very new to both PsychoPy and Python) to make a task using a joystick.

I am using MacOS 10.14 Mojave, and PsychoPy 3.2.4, and trying to use the joystick to move a polygon (ideally, an image, but for now testing on a polygon).

Using builder, I cannot get the polygon to link to the joystick and use the joystick to move it.

I am attaching my screenshots of what I input in the builder.

Screen Shot 2020-01-19 at 3.25.48 PM

I get the following error: ori=0, pos=(joystick.getX(), joystick.getY()),
NameError: name ‘joystick’ is not defined

Can anyone help me identify what I need to do to get it to work? I assume there is code that should be inserted somewhere, but I have not been successful in that either…

thanks!

Hi @TryingPsychopy, the error occurs because you are using variables that are not available at the beginning of the experiment, that is when the shape object is being created. To bypass this error, you could move the Joystick before the Polygon in Builder, but the is still an error in how you are checking for Joystick movement. To move the polygon in real time using joystick coordinates, you need to set the position field in your polygon to update on every screen refresh.