[PATCH 12/20] dix: add some more documentation to ptraccel code
Simon Thum
simon.thum at gmx.de
Wed Apr 20 15:30:20 PDT 2011
On 04/20/2011 08:28 AM, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> dix/ptrveloc.c | 15 ++++++++++++---
> 1 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
> index 9e1cf87..ba6b88b 100644
> --- a/dix/ptrveloc.c
> +++ b/dix/ptrveloc.c
> @@ -548,6 +548,10 @@ GetDirection(int dx, int dy){
> #define TRACKER_INDEX(s, d) (((s)->num_tracker + (s)->cur_tracker - (d)) % (s)->num_tracker)
> #define TRACKER(s, d) &(s)->tracker[TRACKER_INDEX(s,d)]
>
> +/**
> + * Add the delta motion to each tracker, then reset the latest tracker to
> + * 0/0 and set it as the current one.
... thus ensuring each tracker contains the distance to that event's
position. But that's not too critical.
> + */
> static inline void
> FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t)
> {
> @@ -583,10 +587,11 @@ CalcTracker(const MotionTracker *tracker, int cur_t){
> }
>
> /* find the most plausible velocity. That is, the most distant
> - * (in time) tracker which isn't too old, beyond a linear partition,
> - * or simply too much off initial velocity.
> + * (in time) tracker which isn't too old, the movement vector was
> + * in the same octant, and where the velocity is within an
It's not the same octant, more an overlapping set (bits) of octants that
determines the range given the other conditions hold.
> + * acceptable range to the inital velocity.
> *
> - * May return 0.
> + * @return The tracker's velocity or 0 if the above conditions are unmet
I guess division by zero also can lead to this.
> */
> static float
> QueryTrackers(DeviceVelocityPtr vel, int cur_t){
> @@ -749,6 +754,8 @@ BasicComputeAcceleration(
>
> /**
> * Compute acceleration. Takes into account averaging, nv-reset, etc.
> + * If the velocity has changed, an average is taken of 6 velocity factors:
> + * current velocity, last velocity and 4 times the average between the two.
This is known as simpson integration, which I shortcut to simpson
averaging. It's an estimate of the mean value between those two points
on the function's curve. Also, it's not 4 times the average between the
two, but 4 times the function value in the middle between the two ends.
> */
> static float
> ComputeAcceleration(
> @@ -1150,6 +1157,8 @@ acceleratePointerPredictable(
> &fdx, &fdy,
> (mult > 1.0f) && soften);
>
> + /* Calculate the new delta (with accel) and drop it back
> + * into the valuator masks */
> if (dx) {
> tmp = mult * fdx + dev->last.remainder[0];
> /* Since it may not be apparent: lrintf() does not offer
Other than that,
Reviewed-by: Simon Thum <simon.thum at gmx.de>
Cheers,
Simon
More information about the xorg-devel
mailing list