From:brunfeld
I am trying to make the cursor feedback a little more robust, and my thought was to add a trail. This would be something similar to the pointer trail option in the Windows Pointer Options tab under mouse settings.
Ideally, I would program it such that this trail could act like the Windows version, ie: the cursor leaves a copy behind for a finite amount of time, OR I could leave the trail until the participant successfully hits a target. Any help would be most appreciated!
Thank you,
Alex.
There is no good way to keep a full path since that would likely be too many VCodes. However, you can leave behind the last X number of vodes. Send the output of the Hand Feedback block to an embedded MATLAB function like (as edited by brunfeld):
function VCODETrail = makeTrail(handFeedbackVcode)
%#create a permanent variable that will exist in between calls to this method.
persistent trail
persistent ignoreCounter
if isempty(trail)
%this will leave behind the last 10 positions, adjust this as required.
trail = zeros(10, 70);
ignoreCounter = 40; %ensure we record the first VCode
end
%this will ensure we only grab each 40th VCode. The model runs at 2KHz,
%so if we don’t do this then there will just be a solid trail of VCodes where you
%can’t see between any of them. You can adjust this number as required!
if ignoreCounter < 40
ignoreCounter = ignoreCounter + 1;
VCODETrail = trail;
return;
end
%reset the counter so the above if statement still works
ignoreCounter = 0;
%This will help fade out the older VCodes
opacityChange = 100.0/ size(trail,1);
opacity = opacityChange;
%Move each VCode one position down the list.
for row=size(trail,1):-1:2
trail(row,:) = trail(row-1,:);
%#This code changes the opacity of the VCode and therefore fades it out.
trail(row, 9) = opacity;
opacity = opacity + opacityChange;
end
trail(1,:) = handFeedbackVcode(1,:);
VCODETrail = trail;
end
I didn’t test this code but hopefully it gives you the idea of what you need to do. Let me know if this idea works for you. There are at least a few other ways to handle this.
Duncan