From 414742d8c1fbafaa827f0337c6a5fda1bc55c787 Mon Sep 17 00:00:00 2001 From: dschmenk Date: Mon, 4 Nov 2013 13:14:59 -0800 Subject: [PATCH] Change mouse acceleration code --- Makefile | 2 +- debian/changelog | 6 ++++++ src/a2pid.c | 17 ++++++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 91de16b..d8a6758 100755 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PACKAGE=a2pi -VERSION=0.1.3 +VERSION=0.1.4 DIST=$(PACKAGE)-$(VERSION) DISTDIR=./$(DIST) diff --git a/debian/changelog b/debian/changelog index aa2a96c..425714f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +a2pi (0.1.4-1) unstable; urgency=low + + * Change mouse accleration code from table lookup to squared value + + -- David Schmenk Mon, 4 Nov 2013 10:59:43 -0800 + a2pi (0.1.3-1) unstable; urgency=low * Fix multi-thread locking in FUSE driver diff --git a/src/a2pid.c b/src/a2pid.c index 165ba8c..a48361e 100755 --- a/src/a2pid.c +++ b/src/a2pid.c @@ -332,8 +332,6 @@ int keycode[256] = { #define RUN 0 #define STOP 1 #define RESET 2 -int accel[32] = { 0, 1, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 - -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -4, -1}; volatile int state = RUN, isdaemon = FALSE; struct input_event evkey, evrelx, evrely, evsync; @@ -441,10 +439,15 @@ void sendbttn(int fd, int mod, int bttn) } void sendrelxy(int fd, int x, int y) { - if (x > 4 || x < -4) x = x *4; - else x = accel[x & 0x1F]; - if (y > 4 || y < -4) y = y * 4; - else y = accel[y & 0x1F]; +#if 0 + static int accel[32] = { 0, 1, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -4, -1}; + x = ((x > 4) || (x < -4)) ? x * 2 : accel[x & 0x1F]; + y = ((y > 4) || (y < -4)) ? y * 2 : accel[y & 0x1F]; +#else + x = x < 0 ? -x * x : x * x; + y = y < 0 ? -y * y : y * y; +#endif evrelx.value = x; evrely.value = y; write(fd, &evrelx, sizeof(evrelx)); @@ -847,7 +850,7 @@ reset: //state = STOP; break; case 0x84: /* mouse move event */ - // printf("Mouse XY Event: %d,%d\n", (signed char)iopkt[1], (signed char)iopkt[2]); + //printf("Mouse XY Event: %d,%d\n", (signed char)iopkt[1], (signed char)iopkt[2]); sendrelxy(moufd, (signed char)iopkt[1], (signed char)iopkt[2]); break; case 0x86: /* mouse button event */