Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

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

edited February 2013 in OpenSesame

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

  • edited 6:30PM

    Hi Pascal,

    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.

    Hope this helps! If not, please let me know.

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 6:30PM

    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

  • edited October 2017

    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

  • edited October 2017


    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

  • edited October 2017

    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)

    2.png 47.9K
  • 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

  • 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?

    Thanked by 1DahmSF

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • I just checked this and the following script resets the cursor correctly in full screen mode:

    my_mouse = Mouse(visible=True)
    my_mouse.show_cursor(True)
    my_mouse.set_pos((300, 200))
    button, (x, y), timestamp = my_mouse.get_click(visible=True)
    
    Thanked by 1DahmSF
Sign In or Register to comment.