Feature #337
touch-move: implement threshold
Beginn:
12.01.2023
Abgabedatum:
% erledigt:
0%
Geschätzter Aufwand:
CS Zielversion:
Beschreibung
As long as the touch is pressed, the coordinates are read out periodically and an event is emited.
There is no need to send move-events to widgets when the coordinates did not change.
There can be an threshold implemented to filter out jittering between two pixels.
An more rocket-science would be to calculate the actual distance. An overkill whenn we just want to filter 1 pixel distance.
But function can be prepared in "OPoint".
int findSqrtInt(int x)
{
// for 0 and 1, the square roots are themselves
if (x < 2)
return x;
// considering the equation values
int y = x;
int z = (y + (x / y)) / 2;
// as we want to get upto 5 decimal digits, the absolute
// difference should not exceed 0.00001
while (abs(y - z) >= 1) {
y = z;
z = (y + (x / y)) / 2;
}
return z;
}
int main(int argc, char *argv[])
{
printf("Distance: %d\n", (int)findSqrtInt( 4*4 + 4*4 ));
printf("Distance: %d\n", (int)findSqrtInt( 4*4 + 0 ));
}