[open] Joystick programming & inline script writing
Hi
I am hoping to use Open Sesame for an upcoming experiment, but I nor anyone else in my team has even the slightest knowledge of coding/script writing.
I want Open Sesame to show a video and record a joystick movement response (the direction, speed and extent of the towards/away movement) simultaneously. There will then be a keyboard yes/no response time task before the next video is shown.
I have used the GUI to present the video and record the keyboard yes/no response times but I believe in order to make the joystick work, it requires an inline script item to be included after the joystick item (this is what I have read on previous forums).
As you can probably tell, I have no experience whatsoever in the area of computer programming so don't even know where to begin with this... I get to the stage of inserting an inline script item using the GUI and then get stuck. Consequently I have no script to show you!
I realise this is a big ask but any help would be fantastic!
Thank you!
Comments
Hey Helen,
Unfortunately, I have myself not much experience which joysticks. So, I can give you only some very general advice. First of all, in case you haven't seen it yet, here you can find some information how to deal with joysticks in an
inline_script.A way you could start is inserting the
joystick plug-inin the beginning of your experiment, followed by placing aninline_scriptright after your video. There you can refer to the joystick by callingexp.joystick. The best way to learn using it, is playing around with it. So, have a look on the functions that are described in the documentation and check out what they are doing (you can print their return values to thedebug window). For example, I could imagine that based on this function, you can compute direction and speed rather easily.I hope this was of any help.
Good luck,
Eduard
Hi Helena,
This sounds like an approach-avoidance task, am I right?
You can use the
media_player_vlcplug-in for video playback, and use its inline-script field to interact with the joystick. For example, this piece of script, when entered into themedia_player_vlcwill check whether a joystick button is pressed, and stop playback when this is the case:For a full list of joystick functions, see:
To make this script work, you need to add a
joystickplug-in somewhere in your experiment to initialize the joystick. And you need to set 'Call custom code' to 'on every frame' in themedia_player_vlcplug-in.So, in general, this is how you interact with the joystick. To get a more specific answer, you need to specify in detail what kind of information you want to have. The direction of which movement? Because the joystick can be moved multiple times. Which speed? The average speed, the top speed, the speed of the first movements, etc.? So first you need to be very specific about what information you want to log, and from there you (with some help perhaps) can build a simple script like the one above.
Cheers and good luck!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Crosspost!
Check out SigmundAI.eu for our OpenSesame AI assistant!