Hi there, I am creating an offline experiment via the Coder with Psychopy v2024.2.4 and have difficulties with fixing the mouse cursor to start from the screen center whenever a new screen appears. I need this to work on an extended external screen on the right side of my MacBook but couldn’t find a solution yet. It worked when running the experiment on Windows or on the Macbook desktop or with a mirrored screen.
When centering the cursor via screen coordinates, it appears at the top or left border of the screen (consistenly) but somehow the center doesn’t work. All other stimuli are displayed correctly (loacted via unit=’height’). When centering the mouse via hard coded pixels, the cursor appears at a different position on the screen and jumps to the center only after it has been moved. I need it to appear at the center already before it has been moved with the mouse. This is the position where the cursor appears although I haven’t specified it to go there:
This is my current approach to define the current hard coding in pixels:
import Quartz
CENTER_PIXEL_X = 1440 + 960 # = 2400
CENTER_PIXEL_Y = 540
def setMousePos(win, pos):
“”“Set mouse position using hardcoded center coordinates”“”
mouse = event.Mouse(win=win)
if pos == [0, 0]:
try:
Quartz.CGWarpMouseCursorPosition((float(CENTER_PIXEL_X), float(CENTER_PIXEL_Y)))
except ImportError:
print(“Quartz not available - falling back to PsychoPy method”)
mouse.setPos(pos)
else:
mouse.setPos(pos)
return mouse
And this is how I call the function throughout the experiment:
mouse = setMousePos(win, [0, 0])
Does anyone have a new idea of how to fix this? Grateful for any recommendations, thanks!