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 4:48AM

    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

  • edited 4:48AM

    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)

  • 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

    Buy Me A Coffee

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

    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)
    
  • 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.

    #full screen mode: sets the mouse to the middle on each click
    #quick run mode: keeps the mouse position
    empty.show()
    my_mouse = Mouse(visible=True)
    while True:
        button, (x, y), timestamp = my_mouse.get_click(visible=True)
        empty.show()
    
    #both modes: keeps the mouse position in full screen mode
    empty.show()
    my_mouse = Mouse(visible=True)
    my_mouse.show_cursor(True)
    x=y=0
    while True:
        my_mouse.set_pos((x, y))
        button, (x, y), timestamp = my_mouse.get_click(visible=True)
        empty.show()
    

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

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

    import pygame
    self.mouse.set_visible(True)
    pygame.mouse.set_pos(xstart, ystart)
    

    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 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.)

    my_mouse = Mouse()
    my_mouse.show_cursor(True)
    my_mouse.set_pos((xstart, ystart))
    

    Cheers!

    Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games