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
also unused, it will optimize motion processing.

Other possiblities to deactivate acceleration were quite hidden,
and didn't always work as expected. E.g. xset m 1 1 would retain
adaptive deceleration, while xset m 1 0 would not (in the default
profile).

Also removes the 'reserved' profile; it was unused and it's trivial
to add new ones anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Simon Thum 2009-05-06 10:39:16 +02:00 committed by Peter Hutterer
parent 9d1597cbef
commit 3fc6fcfb26
2 changed files with 31 additions and 12 deletions

View File

@ -77,9 +77,12 @@ GetAccelerationProfile(DeviceVelocityPtr s, int profile_num);
#endif #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 * Init struct so it should match the average case
*/ */
@ -108,7 +111,7 @@ InitVelocityData(DeviceVelocityPtr s)
static void static void
FreeVelocityData(DeviceVelocityPtr s){ FreeVelocityData(DeviceVelocityPtr s){
xfree(s->tracker); xfree(s->tracker);
SetAccelerationProfile(s, -1); SetAccelerationProfile(s, PROFILE_UNINITIALIZE);
} }
@ -824,6 +827,16 @@ LinearProfile(
} }
static float
NoProfile(
DeviceVelocityPtr pVel,
float velocity,
float threshold,
float acc)
{
return 1.0f;
}
static PointerAccelerationProfileFunc static PointerAccelerationProfileFunc
GetAccelerationProfile( GetAccelerationProfile(
DeviceVelocityPtr s, DeviceVelocityPtr s,
@ -844,8 +857,8 @@ GetAccelerationProfile(
return PowerProfile; return PowerProfile;
case AccelProfileLinear: case AccelProfileLinear:
return LinearProfile; return LinearProfile;
case AccelProfileReserved: case AccelProfileNone:
/* reserved for future use, e.g. a user-defined profile */ return NoProfile;
default: default:
return NULL; return NULL;
} }
@ -856,8 +869,10 @@ GetAccelerationProfile(
* Intended to make profiles exchangeable at runtime. * Intended to make profiles exchangeable at runtime.
* If you created a profile, give it a number here and in the header to * 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 * 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
* returns FALSE (0) if profile number is unavailable. * PROFILE_UNINITIALIZE.
*
* returns FALSE if profile number is unavailable, TRUE otherwise.
*/ */
int int
SetAccelerationProfile( SetAccelerationProfile(
@ -867,7 +882,7 @@ SetAccelerationProfile(
PointerAccelerationProfileFunc profile; PointerAccelerationProfileFunc profile;
profile = GetAccelerationProfile(s, profile_num); profile = GetAccelerationProfile(s, profile_num);
if(profile == NULL && profile_num != -1) if(profile == NULL && profile_num != PROFILE_UNINITIALIZE)
return FALSE; return FALSE;
if(s->profile_private != NULL){ if(s->profile_private != NULL){
@ -955,6 +970,11 @@ acceleratePointerPredictable(
if (!num_valuators || !valuators || !velocitydata) if (!num_valuators || !valuators || !velocitydata)
return; 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) { if (first_valuator == 0) {
dx = valuators[0]; dx = valuators[0];
px = &valuators[0]; px = &valuators[0];
@ -994,7 +1014,7 @@ acceleratePointerPredictable(
/* Since it may not be apparent: lrintf() does not offer /* Since it may not be apparent: lrintf() does not offer
* strong statements about rounding; however because we * strong statements about rounding; however because we
* process each axis conditionally, there's no danger * process each axis conditionally, there's no danger
* of a toggling remainder. Its lack of guarantees hopefully * of a toggling remainder. Its lack of guarantees likely
* makes it faster on the average target. */ * makes it faster on the average target. */
*px = lrintf(tmp); *px = lrintf(tmp);
pDev->last.remainder[0] = tmp - (float)*px; pDev->last.remainder[0] = tmp - (float)*px;

View File

@ -27,9 +27,9 @@
#include <input.h> /* DeviceIntPtr */ #include <input.h> /* DeviceIntPtr */
/* constants for acceleration profiles; /* constants for acceleration profiles */
* see */
#define AccelProfileNone -1
#define AccelProfileClassic 0 #define AccelProfileClassic 0
#define AccelProfileDeviceSpecific 1 #define AccelProfileDeviceSpecific 1
#define AccelProfilePolynomial 2 #define AccelProfilePolynomial 2
@ -37,8 +37,7 @@
#define AccelProfileSimple 4 #define AccelProfileSimple 4
#define AccelProfilePower 5 #define AccelProfilePower 5
#define AccelProfileLinear 6 #define AccelProfileLinear 6
#define AccelProfileReserved 7 #define AccelProfileLAST AccelProfileLinear
#define AccelProfileLAST AccelProfileReserved
/* fwd */ /* fwd */
struct _DeviceVelocityRec; struct _DeviceVelocityRec;