[PATCH 1/6] dix: ptraccel - Add GetAccelerationProfile()
Peter Hutterer
peter.hutterer at who-t.net
Thu Dec 4 22:42:33 PST 2008
From: Simon Thum <simon.thum at gmx.de>
Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
---
dix/ptrveloc.c | 65 ++++++++++++++++++++++++++++---------------------------
1 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index a1f6e7a..95a7c71 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -75,7 +75,8 @@ CleanupFilterChain(DeviceVelocityPtr s);
static float
SimpleSmoothProfile(DeviceVelocityPtr pVel, float velocity,
float threshold, float acc);
-
+static PointerAccelerationProfileFunc
+GetAccelerationProfile(DeviceVelocityPtr s, int profile_num);
/*#define PTRACCEL_DEBUGGING*/
@@ -675,52 +676,52 @@ LinearProfile(
}
-/**
- * Set the profile by number.
- * 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.
- * returns FALSE (0) if profile number is unavailable.
- */
-int
-SetAccelerationProfile(
+static PointerAccelerationProfileFunc
+GetAccelerationProfile(
DeviceVelocityPtr s,
int profile_num)
{
- PointerAccelerationProfileFunc profile;
switch(profile_num){
- case -1:
- profile = NULL; /* Special case to uninit properly */
- break;
case AccelProfileClassic:
- profile = ClassicProfile;
- break;
+ return ClassicProfile;
case AccelProfileDeviceSpecific:
- if(NULL == s->deviceSpecificProfile)
- return FALSE;
- profile = s->deviceSpecificProfile;
- break;
+ return s->deviceSpecificProfile;
case AccelProfilePolynomial:
- profile = PolynomialAccelerationProfile;
- break;
+ return PolynomialAccelerationProfile;
case AccelProfileSmoothLinear:
- profile = SmoothLinearProfile;
- break;
+ return SmoothLinearProfile;
case AccelProfileSimple:
- profile = SimpleSmoothProfile;
- break;
+ return SimpleSmoothProfile;
case AccelProfilePower:
- profile = PowerProfile;
- break;
+ return PowerProfile;
case AccelProfileLinear:
- profile = LinearProfile;
- break;
+ return LinearProfile;
case AccelProfileReserved:
/* reserved for future use, e.g. a user-defined profile */
default:
- return FALSE;
+ return NULL;
}
+}
+
+/**
+ * Set the profile by number.
+ * 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.
+ * returns FALSE (0) if profile number is unavailable.
+ */
+int
+SetAccelerationProfile(
+ DeviceVelocityPtr s,
+ int profile_num)
+{
+ PointerAccelerationProfileFunc profile;
+ profile = GetAccelerationProfile(s, profile_num);
+
+ if(profile == NULL && profile_num != -1)
+ return FALSE;
+
if(s->profile_private != NULL){
/* Here one could free old profile-private data */
xfree(s->profile_private);
--
1.6.0.4
More information about the xorg
mailing list