mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 08:18:02 +02:00
filter: localize a few variables
No functional changes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
528f09a969
commit
e59dc2ec58
1 changed files with 6 additions and 10 deletions
16
src/filter.c
16
src/filter.c
|
|
@ -204,19 +204,15 @@ double
|
||||||
trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
|
trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
|
||||||
{
|
{
|
||||||
const double MAX_VELOCITY_DIFF = v_ms2us(1); /* units/us */
|
const double MAX_VELOCITY_DIFF = v_ms2us(1); /* units/us */
|
||||||
struct pointer_tracker *tracker;
|
|
||||||
double velocity;
|
|
||||||
double result = 0.0;
|
double result = 0.0;
|
||||||
double initial_velocity = 0.0;
|
double initial_velocity = 0.0;
|
||||||
double velocity_diff;
|
|
||||||
unsigned int offset;
|
|
||||||
|
|
||||||
unsigned int dir = trackers_by_offset(trackers, 0)->dir;
|
unsigned int dir = trackers_by_offset(trackers, 0)->dir;
|
||||||
|
|
||||||
/* Find least recent vector within a timelimit, maximum velocity diff
|
/* Find least recent vector within a timelimit, maximum velocity diff
|
||||||
* and direction threshold. */
|
* and direction threshold. */
|
||||||
for (offset = 1; offset < trackers->ntrackers; offset++) {
|
for (unsigned int offset = 1; offset < trackers->ntrackers; offset++) {
|
||||||
tracker = trackers_by_offset(trackers, offset);
|
const struct pointer_tracker *tracker = trackers_by_offset(trackers, offset);
|
||||||
|
|
||||||
/* Bug: time running backwards */
|
/* Bug: time running backwards */
|
||||||
if (tracker->time > time)
|
if (tracker->time > time)
|
||||||
|
|
@ -231,9 +227,9 @@ trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
velocity = calculate_trackers_velocity(tracker,
|
double velocity = calculate_trackers_velocity(tracker,
|
||||||
time,
|
time,
|
||||||
trackers->smoothener);
|
trackers->smoothener);
|
||||||
|
|
||||||
/* Stop if direction changed */
|
/* Stop if direction changed */
|
||||||
dir &= tracker->dir;
|
dir &= tracker->dir;
|
||||||
|
|
@ -252,7 +248,7 @@ trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
|
||||||
result = initial_velocity = velocity;
|
result = initial_velocity = velocity;
|
||||||
} else {
|
} else {
|
||||||
/* Stop if velocity differs too much from initial */
|
/* Stop if velocity differs too much from initial */
|
||||||
velocity_diff = fabs(initial_velocity - velocity);
|
double velocity_diff = fabs(initial_velocity - velocity);
|
||||||
if (velocity_diff > MAX_VELOCITY_DIFF)
|
if (velocity_diff > MAX_VELOCITY_DIFF)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue