summaryrefslogtreecommitdiff
path: root/dix/ptrveloc.c
AgeCommit message (Collapse)AuthorFilesLines
2011-10-25dix: move #if statement to stop compiler warningPeter Hutterer1-2/+2
ptrveloc.c: In function 'QueryTrackers': ptrveloc.c:598:34: warning: variable 'used_offset' set but not used [-Wunused-but-set-variable] used_offset is used, but only in the debugging code. Move the #if statement to ignore that warning. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29Input: Convert acceleration code to using ValuatorMaskDaniel Stone1-54/+22
Instead of passing a set of int* to the acceleration code, pass it a mask instead, which avoids an unfortunate loss of precision. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-09-29Input: Widen pointer acceleration types to doubleDaniel Stone1-118/+112
This widens almost all of the float-using code in ptrveloc.[ch] to doubles, other than values coming from properties which are specified to be floats by the property API. Bumps input API to v14 as this changes the AccelScheme signature, as used by xf86-input-synaptics. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2011-09-29Input: Use trunc instead of lrintf in acceleration codeDaniel Stone1-7/+2
For compatibility with all the rest of the input code. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: improve control flow in QueryTrackersPeter Hutterer1-8/+8
If the velocity is 0, skip the remainder. If we're not in range, skip the remainder. No functional change. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-04-21dix: rename a bunch of variables to be more self-explanatoryPeter Hutterer1-19/+20
i → used_offset iveloc → initial_velocity res → result vdiff → velocity_diff vfac → velocity_factor tmp → tracker_velocity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: reduce scope of tmp and mult.Peter Hutterer1-1/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: reduce the work done by ApplySofteningPeter Hutterer1-15/+16
We can modify fdx/fdy in-place rather than requiring dx/dy as well. And the decision to soften can be made in the caller (unless decided by the velocity state). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: split softening and constant deceleration into two functionsPeter Hutterer1-5/+10
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: use single return statement in ApplySimpleSofteningPeter Hutterer1-6/+7
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: rename od, d to prev_delta, deltaPeter Hutterer1-9/+9
And res to result. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: Don't use short as boolPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: rename "res" to "result" for improved readabilityPeter Hutterer1-9/+9
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: change ProcessVelocityData2D to BOOL.Peter Hutterer1-1/+1
Don't confuse users with a return type of short, that's even less indicative that it returns 0/non-0 than "int". Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-04-21dix: add some more documentation to ptraccel codePeter Hutterer1-4/+13
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: don't pass the index for a tracker around, pass the trackerPeter Hutterer1-10/+11
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: CalcTracker only uses the tracker, thus only pass the tracker.Peter Hutterer1-6/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-21dix: use single return statement in DoGetDirectionPeter Hutterer1-42/+49
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: use single return value in GetDirectionPeter Hutterer1-9/+8
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: document GetDirectionPeter Hutterer1-1/+7
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: document DoGetDirection's mathsPeter Hutterer1-2/+10
This is the best explanation I can come up with, but it seems to hold true for my example values. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: improve comment, directions flagged are 45° eachPeter Hutterer1-1/+1
The two directions returned by this calculation are always the two boundary conditions. Since we don't do quadrants but octants, the flagged ones are 45° each. e.g. an angle of 35° flags E and NE. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-04-21dix: improve readbility of DoGetDirection.Peter Hutterer1-12/+25
Use enums for the direction bits, not hardcoded bitfield values that are added up. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: only use a single return where only one is needed.Peter Hutterer1-2/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-04-21dix: fix typo in direction calculationPeter Hutterer1-1/+1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
2011-03-02dix: change all timestamps in pointer acceleration to CARD32Simon Thum1-2/+2
CARD32 is being returned by GetTimeInMilis(), so use it consistently. Signed-off-by: Simon Thum <simon.thum@gmx.de> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-02dix: update pointer acceleration code to use ValuatorMaskSimon Thum1-67/+58
Signed-off-by: Simon Thum <simon.thum@gmx.de> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-02dix: refactor predictable scheme initializationSimon Thum1-30/+58
This intends to clean up the predictable accel struct from purely scheme-related things like input properties, as they would be useless in other use cases such as wheel acceleration. Signed-off-by: Simon Thum <simon.thum@gmx.de> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-02-17dix: avoid FP promotion during pointer accelerationSimon Thum1-2/+2
Signed-off-by: Simon Thum <simon.thum@gmx.de> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-02-17dix: refactor scheme initSimon Thum1-8/+30
This makes it possible to init a scheme in one init call, so we get rid of the tightly coupled two-phase init used before. Signed-off-by: Simon Thum <simon.thum@gmx.de> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11Remove superfluous if(p!=NULL) checks around free(p); p=NULL;Cyril Brulebois1-5/+3
This patch has been generated by the following Coccinelle semantic patch: @@ expression E; @@ - if (E != NULL) { - free(E); ( - E = NULL; | - E = 0; ) - } + free(E); + E = NULL; Signed-off-by: Cyril Brulebois <kibi@debian.org> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-10Remove unnecessary parentheses around return values in functionsMikhail Gusarov1-1/+1
This patch was generated by the following Perl code: perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;' Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-13Replace X-allocation functions with their C89 counterpartsMikhail Gusarov1-5/+5
The only remaining X-functions used in server are XNF*, the rest is converted to plain alloc/calloc/realloc/free/strdup. X* functions are still exported from server and x* macros are still defined in header file, so both ABI and API are not affected by this change. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-30Replace some input devPrivates with regular struct fieldsKeith Packard1-22/+9
In the process, fixes a memory leak in CloseDevice, and an unchecked memory allocation in InitializePredictableAccelerationProperties. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-01-01dix: add smooth limited pointer acceleration profileSimon Thum1-1/+27
This profile is inspired by the accel code removed from the wacom driver. It ascends from zero to acceleration, maxing out at threshold. This means you can control the slope using threshold, which wasn't possible in wacom. For sanity's sake, threshold should grow with acceleration. Works best with adaptive deceleration, since otherwise it only generates acceleration above 1, causing seldom pixel skips. Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-25dix: clean up accel old scheme data when switching schemes.Peter Hutterer1-12/+52
InitValuatorClassDeviceStruct always initializes with the default profile. The default profile allocs data and adds a few properties which become obsolete if the profile is changed lateron by the driver. The property handlers are stored in the device's devPrivates and cleaned up. Ideally, the property handler ID's could be stored somewhere more obvious, but that seems to require breaking the ABI. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Simon Thum <simon.thum@gmx.de>
2009-07-17Revert "Coverity Prevent: RESOURCE_LEAK in AccelSetProfileProperty:"Oliver McFadden1-4/+0
This reverts commit 7333dc2969f60af0abcfb28e7182a5fff9918223. False positive.
2009-07-16Coverity Prevent: RESOURCE_LEAK in AccelSetProfileProperty:Oliver McFadden1-0/+4
Event alloc_arg: Called allocation function "XIPropToInt" on "ptr" [details] 167 rc = XIPropToInt(val, &nelem, &ptr); Event leaked_storage: Variable "ptr" goes out of scope
2009-06-29dix: rename pDev->dev, pVel->vel for consistencySimon Thum1-164/+165
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-29dix: improve pointer acceleration APISimon Thum1-26/+40
This makes the ptr accel api actually sensible from a driver perspective, since it avoids superfluous device lookups. Also, makes independent accel contexts possible. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-28Merge branch 'master' into xi2Peter Hutterer1-8/+28
Conflicts: Xext/geext.c Xi/chdevcur.c Xi/extgrbdev.c Xi/xiproperty.c configure.ac dix/ptrveloc.c hw/xfree86/common/xf86Config.c mi/mipointer.h test/input.c xkb/xkb.c
2009-05-08dix: remove superfluous includes from ptrveloc.cSimon Thum1-3/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08dix: fix warning in pointer accelerationSimon Thum1-2/+8
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). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-07dix: add 'none' pointer acceleration profile with number -1Simon Thum1-8/+28
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>
2009-05-07dix: remove superfluous includes from ptrveloc.cSimon Thum1-3/+0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-07dix: fix warning in pointer accelerationSimon Thum1-2/+8
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). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-19dix: correctly utilize tracker buffer and protect from timer overrunsSimon Thum1-11/+13
two small related fixes hard to split up Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-19dix: fix pointer accelerations remainder handlingSimon Thum1-7/+7
This didn't really work as intended, but did amazingly well thanks to roundf() hiding the defect. Cheers! Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-19dix: allow relative motion buffer to accumulate in a natural waySimon Thum1-6/+0
Since with XI2 we pass sub-pixel motion, anything else is broken. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-10dix: correctly utilize tracker buffer and protect from timer overrunsSimon Thum1-11/+13
two small related fixes hard to split up Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>