[solved] Different mouse behavior in fullscreen vs. window mode

first of all: thank you for the great program! I started using it two months ago and it really offers more flexibility than the experimental software I was previously using (E-Prime...).

I am writing you because I have a problem when using the forms plugin: I created a simple custom form with an inline script where participants can click on a button. If participants do not click on the button but somewhere else, different things happen depending on whether I run the experiment in the window or the fullscreen mode: In the window mode, the position of the mouse cursor exactly stays the same (as it should). In the fullscreen mode, the cursor position is set to the center (if the mouse was moved directly after clicking).

Besides, I use the following argument to set the mouse to a specific position when creating the form:

import pygame
pygame.mouse.set_pos(xstart,ystart)

The argument works fine in the window mode but seems to be ignored in the fullscreen mode.

I am using OpenSesame 0.27 'Frisky Freud' with the xpyriment backend (but the problem also occurs in the 0.27.1 Frisky Freud portable version).

Comments

first of all: thank you for the great program! I started using it two months ago and it really offers more flexibility than the experimental software I was previously using (E-Prime...).

Glad you like it!

In the fullscreen mode, the cursor position is set to the center (if the mouse was moved directly after clicking).

and

The argument works fine in the window mode but seems to be ignored in the fullscreen mode.

It seems that both of these issues are related to PyGame (see for example the comments here). My (unverified) guess is that OpenGL (the hardware acceleration layer) causes the trouble, because this only works in fullscreen mode. If temporal accuracy is not your primary concern, you could try disabling OpenGL by switching to the legacy back-end, or by setting Use OpenGL to 'no' in the back-end settings of the xpriment back-end.

thank you for your ideas! Switching the back-end to legacy did solve the problem, disabling OpenGL, however, did not work.

Thanks also for pointing out the PyGame issues: the command

self.mouse.set_visible()

seems to cause the centering of the mouse in fullscreen mode. Interestingly, I did not specify this command explicitly (as the mouse was already visible). However, after I specified it followed by the commands

and it works well on full screen (partly) and in quick run (fully) but! but it works for me on full screen for only one row from the loop.
how can I repeat this lines so that the cursor will continue to return to the position (400,400) every line from the loop .

my loop :

how can I repeat this lines so that the cursor will continue to return to the position (400,400) every line from the loop .

Am I assuming correctly that you have included a code like the following in the run phase (not the prepare phase) of inline_script_3_1?

import pygame pygame.mouse.set_pos(400,400)

If so, this should definitely work in every trial. What backend are you using?

Side note: if you want to use more complex mouse-tracking operations (not sure what the focus of your experiment is), the mousetrap_response plugin might come in handy for you. It is designed to implement "buttons" on a sketchpad (i.e., different clickable areas) and also allows resetting the mouse to specific coordinates.

"I assuming you included a code like the following in the run phase (not the prepare phase) of inline_script_3_1?" ---------- YES

I will try this: mousetrap_response plugin

I attached an image of the sketchpad presented at every trial.
I need that every trial the mouse cursor will come back to this position (400,400).
yes I am using the code you mentioned and it works for only one trial (the first one) and then it saddely stops from working for the rest of the trials. I tried it in few systems and I got the same result.

I just looked again at the OpenSesame documentation for the mouse. I think you should replace your code above with:my_mouse = mouse() my_mouse.set_pos(pos=(400,400))

In your current setup, I don't think that the mousetrap_response plugin makes that much sense (as it looks to me you don't have buttons but want the participant to freely click somewhere on the slider). You could still use the plugin with a single wide button area (this way you can also ensure that only clicks in the slider region are registered), but depending on what else you want to do, it is probably easier if you use a mouse_response item and write the specific code for your purpose yourself.

(A bit late but hopefully still useful.) If memory serves me, this resetting happens when the cursor is made visible. What if you first call my_mouse.show_cursor(True) and then afterwards change the position?

There is not much you can do about the mouse cursor being reset to the center upon you're showing/ hiding it, except changing the backend settings until you've found a combination that doesn't suffer from this. (It's difficult to provide exact instructions, because this behavior seems to depend on the system.)

But regarding your script: The self.mouse reference assumes that there is a self object (and there is: it's the inline_script ), which has a mouse property, which doesn't exist.

But what would work is the following: first create a Mouse object, then show the cursor so that it remains visible, and finally change its position. (Whether that will accomplish your goal, I'm not sure.)