| Reference | Downloads | Github

mouse.getPos() and mouse.setPos() playing up - location rel to top right corner?

Hi all,

Not sure if others have experienced this, but thought it’s worth a shot in case it’s a fixable bug.

I’m making a task where I want to be able to set a mouse position given a specific angle (around the centre) to help with a response. However, getting some problems when trying to mouse.setPos() to anything - even (0,0)!!

I stripped it back completely and tried with some v basic code, and still getting the same problem. It looks, weirdly, like things are being set relative to the top right corner of my laptop. Setting location to the origin puts it there, and negative x values take it further left (rather than starting centre and moving left of centre). I’ve attached code here for what I’ve been using to look at this problem.

import numpy    as np
from psychopy   import visual
from psychopy   import event, core, gui, data, logging

test_loc = 0 #force macbookpro at the moment...

#set screen parameters
if test_loc == 0: #laptop for testing, macbook pro (retina atm)
    resxy   = [1680, 1050] #laptop pixel resolution
    reshz   = 60 #refresh rate of the screen
    sw      = 28.5 #screen width
    vdistcm = 50 #distance from screen
    mon     = 'mbp' #identifying string for the monitor on the computer!
    retina  = True

colours = np.array([
        [255, 255, 255], #white?
        [255, 255,  21], #yellow ?
        [  0,   0, 255], #blue
        [150, 150, 150]  #dark grey (neutral)

#create the screen
screen = visual.Window(size                 = resxy,
                       units                = 'deg',
                       colorSpace           = 'rgb',
                       color                = (-1,-1,-1), #black background
                       fullscr              = True,
                       monitor              = mon, 
                       useRetina            = True, #set to false if not on a retina screen
                       winType              = 'pyglet') 
mouse = event.Mouse(win = screen, visible = True, newPos = [0,0]) #set up mouse for the task (`visible = False` will stop it being visible on screen. default is visible)

mouse.setPos(newPos = [2,2])
mouse.setPos(newPos = [-2,-2])
mouse.setPos(newPos = [-5,-7])

Not sure why i’m getting this bug, so any advice would be great. I’m running one of the new macbook pros with OS X Mojave (this is quite probably the problem…) with psychopy v 1.90.3.

just an update: I tried this on the windows testing PC and it wasn’t an issue, which suggests that this is probably an issue with the way that the mouse is interacting with the screen when useRetina is set to True. Would be great to get this fixed on mac laptops though, because otherwise it becomes unsustainable to design tasks on them if you need to get/set the mouse position in your design!