xf86ScaleAxis: support for high resolution devices

High resolution devices was generating integer overflow.
For instance the wacom Cintiq 21UX has an axis value up to
87000. Thus the term (dSx * (Cx - Rxlow)) is greater than
MAX_INT32.

Using 64bits integer avoids such problem.

Signed-off-by: Philippe Ribet <ribet@cena.fr>
Signed-off-by: Benjamin Tissoires <tissoire@cena.fr>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Benjamin Tissoires 2010-04-14 17:27:51 +02:00 committed by Peter Hutterer
parent e424d58123
commit a780e5b363

View File

@ -86,6 +86,7 @@
#include "windowstr.h" /* screenIsSaved */
#include <stdarg.h>
#include <stdint.h> /* for int64_t */
#include <X11/Xpoll.h>
@ -1177,12 +1178,11 @@ xf86ScaleAxis(int Cx,
int Rxlow )
{
int X;
int dSx = Sxhigh - Sxlow;
int dRx = Rxhigh - Rxlow;
int64_t dSx = Sxhigh - Sxlow;
int64_t dRx = Rxhigh - Rxlow;
dSx = Sxhigh - Sxlow;
if (dRx) {
X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow;
X = (int)(((dSx * (Cx - Rxlow)) / dRx) + Sxlow);
}
else {
X = 0;