Hello, attached are some minor patches to pointer acceleration:
- A 'none' profile is added so users can disable acceleration at runtime in a more explicit way than xset m 1 0 or other magic. - fix a warning newer GCCs issue on some casts and maybe improve performance as well. - remove unneeded headers from ptrveloc.c Cheers, Simon
>From 883cab39ace28695c3be4303b919d3b786d83ee6 Mon Sep 17 00:00:00 2001 From: Simon Thum <[email protected]> Date: Tue, 28 Apr 2009 10:11:32 +0200 Subject: [PATCH] dix: add 'none' pointer acceleration profile with number -1 this is a shorthand for disabling acceleration, while retaining the possiblity to use constant deceleration. If constant deceleration is unused, it will also optimize motion processing. --- dix/ptrveloc.c | 30 ++++++++++++++++++++++++------ include/ptrveloc.h | 4 ++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 1590cfd..6553772 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -80,9 +80,12 @@ GetAccelerationProfile(DeviceVelocityPtr s, int profile_num); #endif /******************************** - * Init/Uninit etc + * Init/Uninit *******************************/ +/* some int which is not a profile number */ +#define PROFILE_UNINITIALIZE (-100) + /** * Init struct so it should match the average case */ @@ -111,7 +114,7 @@ InitVelocityData(DeviceVelocityPtr s) static void FreeVelocityData(DeviceVelocityPtr s){ xfree(s->tracker); - SetAccelerationProfile(s, -1); + SetAccelerationProfile(s, PROFILE_UNINITIALIZE); } @@ -827,6 +830,16 @@ LinearProfile( } +static float +NoProfile( + DeviceVelocityPtr pVel, + float velocity, + float threshold, + float acc) +{ + return 1.0f; +} + static PointerAccelerationProfileFunc GetAccelerationProfile( DeviceVelocityPtr s, @@ -847,8 +860,8 @@ GetAccelerationProfile( return PowerProfile; case AccelProfileLinear: return LinearProfile; - case AccelProfileReserved: - /* reserved for future use, e.g. a user-defined profile */ + case AccelProfileNone: + return NoProfile; default: return NULL; } @@ -859,7 +872,7 @@ GetAccelerationProfile( * Intended to make profiles exchangeable at runtime. * If you created a profile, give it a number here and in the header to * make it selectable. In case some profile-specific init is needed, here - * would be a good place, since FreeVelocityData() also calls this with -1. + * would be a good place, since FreeVelocityData() also calls this with -100. * returns FALSE (0) if profile number is unavailable. */ int @@ -870,7 +883,7 @@ SetAccelerationProfile( PointerAccelerationProfileFunc profile; profile = GetAccelerationProfile(s, profile_num); - if(profile == NULL && profile_num != -1) + if(profile == NULL && profile_num != PROFILE_UNINITIALIZE) return FALSE; if(s->profile_private != NULL){ @@ -958,6 +971,11 @@ acceleratePointerPredictable( if (!num_valuators || !valuators || !velocitydata) return; + if (velocitydata->statistics.profile_number == AccelProfileNone && + velocitydata->const_acceleration == 1.0f) { + return; /*we're inactive anyway, so skip the whole thing.*/ + } + if (first_valuator == 0) { dx = valuators[0]; px = &valuators[0]; diff --git a/include/ptrveloc.h b/include/ptrveloc.h index 6ef8c75..974af35 100644 --- a/include/ptrveloc.h +++ b/include/ptrveloc.h @@ -27,9 +27,9 @@ #include <input.h> /* DeviceIntPtr */ -/* constants for acceleration profiles; - * see */ +/* constants for acceleration profiles */ +#define AccelProfileNone -1 #define AccelProfileClassic 0 #define AccelProfileDeviceSpecific 1 #define AccelProfilePolynomial 2 -- 1.6.0.6
>From 9ddcb814ede849b1a05538eba1ab7df76240a7e1 Mon Sep 17 00:00:00 2001 From: Simon Thum <[email protected]> Date: Thu, 30 Apr 2009 12:58:48 +0200 Subject: [PATCH] dix: fix warning in pointer acceleration newer gcc's warn against how this cast is done (though it eludes me why), and lrintf() is also faster especially on insane processors like the P4 (http://www.mega-nerd.com/FPcast). --- dix/ptrveloc.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 6553772..89bf7d2 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -1006,14 +1006,20 @@ acceleratePointerPredictable( if (dx) { tmp = mult * fdx + pDev->last.remainder[0]; - *px = (int)roundf(tmp); + /* Since it may not be apparent: lrintf() does not offer + * strong statements about rounding; however because we + * process each axis conditionally, there's no danger + * of a toggling remainder. Its lack of guarantees hopefully + * makes it faster on the average target. */ + *px = lrintf(tmp); pDev->last.remainder[0] = tmp - (float)*px; } if (dy) { tmp = mult * fdy + pDev->last.remainder[1]; - *py = (int)roundf(tmp); + *py = lrintf(tmp); pDev->last.remainder[1] = tmp - (float)*py; } + DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n", *px, *py, pDev->last.remainder[0], pDev->last.remainder[1], fdx, fdy); } } } -- 1.6.0.6
>From 31b1412e9b459aa3276844571fcfa91dae069dba Mon Sep 17 00:00:00 2001 From: Simon Thum <[email protected]> Date: Thu, 30 Apr 2009 13:01:17 +0200 Subject: [PATCH] dix: remove superfluous includes from ptrveloc.c --- dix/ptrveloc.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 89bf7d2..d3b9774 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -28,11 +28,8 @@ #include <math.h> #include <ptrveloc.h> -#include <inputstr.h> #include <exevents.h> #include <X11/Xatom.h> -#include <assert.h> -#include <os.h> #include <xserver-properties.h> -- 1.6.0.6
_______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
