Win11
2022.2.5
Standard Standalone? Yes
What are you trying to achieve?:
I need an on-screen custom cursor (e.g. a shape component) that is controlled by the mouse component when pressed. I need to record the trajectory of this on-screen cursor which moves from the center of the screen until it overlaps an onscreen target. If the mouse button is released mid-trajectory, the cursor needs to reset to the center and the trial should continue. The four possible target locations are controlled by a loop. The mouse component is controlled by a stylus on a trackpad.
What did you try to make it work?:
It works with what is already built. I have four components in this routine. A target (shape), a cursor (shape), mouse, and a custom code component. All builder components are set to never end. The only routine end condition is specified in the code component.
The custom code component has the following in each frame to make things work.
if mouse_baseline.getPressed()[0]:
#record the first click location as center for trackpad control
if first_click:
first_click = False
baseline_mouse_center = mouse_baseline.getPos()
cursor_baseline_pos = mouse_baseline.getPos() - baseline_mouse_center
cursor_traj.append(cursor_baseline_pos)
else:
first_click = True
# mouse_baseline.clickReset()
cursor_baseline_pos = [0, 0]
if target_baseline.overlaps(cursor_baseline):
continueRoutine = False
first_click = True
What specifically went wrong when you tried that?:
There is no error. It works fine for the most part. However, when participants release their clicks mid-trajectory, it seems a new row is created in the data csv for the same trial but a new trajectory is not recorded. The trial counter also increases (which means a trial gets dropped at the end).