psychopy.org | Reference | Downloads | Github

Dot Rotation with Mouse

Hello,
I am trying to implement an adjustment task with a dot is presented on the screen. Depending on mouse movement, the dot continuously rotates around an imaginary circle. When observers have chosen the location they want, they click and the exp goes to the next trial.
So far, I have achieved something similar, but with the keyboard. Depending on the left/right key, the dot rotates around an imaginary circle. When observers have chosen the location they want, they press Spacebar and the exp goes to the next trial.

Does anybody know how to implement this mouse adjustment task?
I managed to record mouse location but I have no idea of how to link it to my stimulus:

while notFinished==True:
win.winHandle.push_handlers(keyState)
mousePos = tuple(mouse.getPos()) # Get mouse coordinates

if keyState[key.LEFT]:
    Start_Line.ori -= 1
    line1Response-=1
    angle+=1 #increase angle if LEFT

if keyState[key.RIGHT]:
    Start_Line.ori += 1
    line1Response+=1
    angle-=1 #increase angle if RIGHT

if keyState[key.SPACE]:
    line1Response = Start_Line.ori
    orResponse = angle
    AdjTime=clock.getTime()
    notFinished=False #breaks the loop and saves response
if keyState[key.ESCAPE]:
        core.quit()
Start_Line.draw()

angleR = math.radians(angle)
xStart = math.cos(angleR) * radius
yStart = math.sin(angleR) * radius    
Dot_Start = visual.Polygon(
    win=win, name='Dot_Start',units='deg', 
    edges=40, size=(.5, .5),
    ori=0, pos=[xStart,yStart],
    lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
    fillColor=[1,1,1], fillColorSpace='rgb',
    opacity=1, depth=-6.0, interpolate=True)

Dot_Start.draw()    #draw dot at new location
win.flip()

@Mauro83, if you just need to know which direction the mouse is moving, you can check whether the mouse has moved, and whether the previous position is greater or less than the last position on the X axis. This will tell you if the pointer is moving left or right. You can replace your keyboard code with these mouse conditionals - see the example attached.

mouseDirection.psyexp (8.6 KB)