Millisecond Forums

Set mouse coordinates

https://forums.millisecond.com/Topic3965.aspx

By Blackadder - 2/21/2010

Hi All,


in an eyetracking paradigm I wish to set the mouse cursor to a specific screen location on each trial in order to prevent that subjects have to search for the mouse cursor. Is something like this possible:


<trial>
/ ontrialbegin = [mouse.x=50%; mouse.y=50%]
...
</trial>



Bye, Malte.


By Dave - 2/21/2010

As far as I know, setting the mouse cursor to a predefined position is not possible currently. I think this is kind of a bummer, and that's why this feature suggestion is on my personal Inquisit wishlist...;-)


~Dave

By Blackadder - 2/21/2010

And on the forum wishlist, too.

By Dave - 2/21/2010

A few workaround strategies, which may or may not be helpful depending on your overall task characteristics:


(1) Insert a trial element requiring subjects to center the mouse cursor:


<trial centermouse>
/ stimulusframes = [1=centersquare]
/ inputdevice = mouse
/ validresponse = (centersquare)
</trial>

<shape centersquare>
/ shape = rectangle
/ size = (20px, 20px)
/ position = (50%, 50%)
/ color = (green)
</shape>


(2) If your eyetracking trial only involves mouse events as input (lbuttondown, etc.) and does not require subjects to click on a specific stimulus, you can disable the display of the mouse cursor via '/ inputdevice = mousekey' or '/ showmousecursor = false' to avoid visual distractions caused by the cursor position.


~Dave

By Blackadder - 2/21/2010

Hi Dave,


I tend to use the mouse as an input device with a visible mouse cursor only if absolutely necessary, i.e. when a pointing or tracking task is involved. For all other purposes, we had custom response boxes built from ordinary USB keyboards sporting only five buttons, with one box for each hand. Buttons internally map to none-numpad keys 1-5 (right hand) and 6-10 (left hand). Subjects provide responses always with their dominant hand on the respective box. We can thereby warrant that the same finger is associated with the same response regardless of handedness.


The centering trial came to my mind, too, I was just adding such a thingie to my script when I read your posting. Cumbersome? Yes. Avoidable? No, sadly.


If anybody is interested in the details of my implementation, the script elements are set up as follows.



<values>
/ centeringtext=""
/ centertolerance=3px
/ screencenter.x=640px

/ screencenter.y=512px

</values>

<text TEXT_centering>
/ items = ("<%values.centeringtext%>")
/ position = (50,40)
</text>

<trial TRIAL_centering>
/ branch =
[if(sqrt(pow(trial.TRIAL_centering.responsex-values.screencenter.x,2) +
pow(trial.TRIAL_centering.responsey-values.screencenter.y,2)) >
values.centertolerance) TRIAL_centering]

/ validresponse = (lbuttonup)
/ responseinterrupt = trial
/ stimulusframes = [1 = sequence(TEXT_centering,PIC_centerspot)]
/ ontrialend = [values.centeringtext="Your mouse cursor is too far off the black dot. Please try again."]
</trial>



The expression "sqrt(...)" computes the euclidian distance of the click coordinate to the center of the screen. If the click commenced too far off the center, the trial alters the message issued by TEXT_centering and repeats itself. The values.centeringtext variable is reset to "Please click on the black dot at the center of the screen." by every trial that calls TRIAL_centering.


Bye, Malte

By Dave - 2/21/2010

/ branch =
[if(sqrt(pow(trial.TRIAL_centering.responsex-values.screencenter.x,2) +
pow(trial.TRIAL_centering.responsey-values.screencenter.y,2)) >
values.centertolerance) TRIAL_centering]


Nice! However that's really a little too cumbersome for my tastes. Why not simply define a <shape> that covers your "tolerance" area, e.g.


<shape blackdot>
/ size = whatever you compute it to be
/ position = (50%, 50%)
[...]
</shape>


and then just go for


<trial
centermouse>
/ stimulusframes = [1=blackdot]
/ inputdevice =
mouse
/ validresponse = (blackdot)
</trial>


? The trial will only move on if subjects indeed click within the screen region defined / covered by <shape blackdot>. Essentially this should achieve the same thing as your current setup.


Now beg to differ!


~Dave

By Blackadder - 2/22/2010

Uh, didn't know that works. If you wish to issue an error message when a subject does not hit the black dot, the code reduces to



<values>
/ centeringtext=""
</values>

<text TEXT_centering>
/ items = ("<%values.centeringtext%>")
/ position = (50,40)
</text>

<trial TRIAL_centering>
/ branch = if(trial.TRIAL_centering.correct==0) TRIAL_centering
/ ontrialend = [values.centeringtext="Your mouse cursor did not hit the black dot. Please try again."]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ correctresponse = (PIC_centerspot)
/ responseinterrupt = trial
/ stimulusframes = [1 = sequence(TEXT_centering,PIC_centerspot)]
</trial>