[solved] Different mouse behavior in fullscreen vs. window mode
Hi all,
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).
Thanks in advance for your help!
Best
Pascal
Comments
Hi Pascal,
Glad you like it!
and
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.
Hope this helps! If not, please let me know.
Cheers,
Sebastiaan
Hi Sebaastian,
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
import pygame
pygame.mouse.set_pos(xstart,ystart)
everything worked as intended.
Best
Pascal
Hello Pascal and Sebastiaan,
I have used these lines:
import pygame
pygame.mouse.set_pos(xstart,ystart)
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 .
Hi Matanel,
I am not completely sure if I understand your issue.
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.
Best,
Pascal
Thank you very much Pascal.
I am using Legasy [uses Pygame] backend.
"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.
Is there any function that can loop the code for every trial?
I will try this: mousetrap_response plugin
Hi Matanel,
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.
Best,
Pascal
I tried this function that I treid to def but it doesn't work either.
I have also tried these two options (with the right indentation):
def set_mouse_pos(x):
for x in pygame:
if pygame.event:
return pygame.mouse.set_pos(400,400)
else:
return pygame.mouse.set_pos(400,400)
return set_mouse_pos(pygame.event)
option 2
for mouse in pygame(MOUSEBUTTONUP):
if pygame.event:
return pygame.mouse.set_pos(400,400)
else:
return pygame.mouse.set_pos(400,400)
Hi Matanel,
Is this question here different from the one you asked in a separate discussion? If not, I'd like to discuss it centrally in the other discussion instead of in both.
Let me know.
Eduard
Hello Eduard,
I answered you on this discussion
http://forum.cogsci.nl/index.php?p=/discussion/3491/scales-in-sketch-pad-reset-to-zero-in-a-different-place#latest
Old post, same problem
my_mouse.set_pos(pos=(0,375))
works fine in window mode ('quick run') but not in fullscreen.I am using xpyriment because of timing.
The mouse is always set to pos=0,0 in fullscreen.
(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?I just checked this and the following script resets the cursor correctly in full screen mode:
Not only when the cursor is made visible
my_mouse = Mouse(visible=True)
, but also each time a new picture is presented the cursor is set to 0,0 (middle of the screen) in full screen mode.@sebastiaan : Would be better if performance in 'quick run' and 'full screen' would be the same
Although this is a minor problem, maybe a fix for future versions?
Ideally, yes! But this behavior comes from
pygame
, which uses different video modes for full-screen and window modes. So it's not something that can easily be fixed by OpenSesame.Hi everyone,
I'm programming an experiment and the same error Pascal mentioned in his original post occurs, however, using legacy mode does not fix the issue. So how can I prevent the mouse from being reset?
I tried to set the mouse visible in an inline_script preceding the custom_form item, which caused an error. (exception: mouse not found)
Any help is appreciated!
Hi Florian,
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 aself
object (and there is: it's theinline_script
), which has amouse
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.)Cheers!
Sebastiaan