Get mouse movement when mouse is at border of window

I have an experiment where I need to hide the mouse and participants have to sometimes perform a task where they change the length of a line by moving the mouse left or right. I’m currently using mouse.getRel() and increasing the length of the line if the mouse is moved right and decreasing the length if it is moved left.

My problem occurs when the mouse is either at the left or right edge of the screen and therefore a movement in that direction is not registered because the mouse is already at the edge of the window.

Offline I would just re-centre the mouse position at the beginning of every trial. However, I’m aware setting the mouse position online is not possible.

If I’m moving the physical mouse to the right, but the cursor is not moving because is at the edge of the screen, is it possible to capture that ‘trying to move right’ action? Or any other workaround? I’m very stuck at this point.

No. The mouse position is information that comes from the operating system, and the OS won’t have the concept of tracking the mouse outside of the boundaries of the display. It will just keep returning a constant, maximum, value for the horizontal mouse coordinate.

Get the subject to do it for you? i.e. don’t start a trial until the mouse has been re-centred.