Seb - 05 October 2007 02:35 PM
Just make a map in which you store key->value as TouchData.id->[TouchData,movement] and in each fingerUpdate replace the current TouchData.id’s movement with the old movement+deltaMovement.
Then use a threshold for minimumMovement for actually interpreting as an update.
(I will add this to Touchlib as soon as I need it, by the way.)
I tried this, not exactly how you typed it because i dont understand this part : “replace the current TouchData.id’s movement with the old movement+deltaMovement.”.
I’ve never programmed in C++ but after a bit of experimentation i learned a bit.
I did this :
//! Notify that a finger has moved
virtual void fingerUpdate(TouchData data)
{
// NO MORE SHAKY BLOBS
float shakeTreshold=0.0035;
fingerDeltaList[data.ID] = data;
// CHECK IF THE MOVEMENT IS BIGGER THEN THE TRESHOLD
if (abs(fingerDeltaList[data.ID].dX) >= shakeTreshold || abs(fingerDeltaList[data.ID].dY) >= shakeTreshold) {
fingerList[data.ID] = data;
printf("OSC FingerUpdate detected: %i, %f, - %f, %f - %f, %f\n",data.ID, shakeTreshold, data.X, data.Y, abs(data.dX), abs(data.dY));
}
}
This works as far as i can see, but sometimes i completely lose my tracking but i can fix that. But another problem is a result of this method i guess.
If i move my finger very slow, it doesn’t detect movement because the movement is less than the treshold.
So maybe i didn’t code this right and is “replace the current TouchData.id’s movement with the old movement+deltaMovement.” the solution.