Commit 55736917 authored by Peter Osterlund's avatar Peter Osterlund Committed by Vojtech Pavlik

input: Here it is, with the suggestions from Pete and Dmitry included. The

patch does the following:

* Compensates for the lack of floating point arithmetic by keeping
  track of remainders from the integer divisions.
* Removes the xres/yres scaling so that you get the same speed in the
  X and Y directions even if your screen does not the same aspect ratio
  as your touchpad.
* Sets scale factors to make the speed for synaptics and alps equal to
  each other and equal to the synaptics speed from 2.6.10.
Signed-off-by: default avatarPeter Osterlund <petero2@telia.com>
Signed-off-by: default avatarVojtech Pavlik <vojtech@suse.cz>
parent 5d152e02
......@@ -71,6 +71,7 @@ struct mousedev {
struct mousedev_hw_data packet;
unsigned int pkt_count;
int old_x[4], old_y[4];
int frac_dx, frac_dy;
unsigned long touch;
};
......@@ -117,24 +118,31 @@ static struct mousedev mousedev_mix;
static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mousedev, unsigned int code, int value)
{
int size;
int size, tmp;
enum { FRACTION_DENOM = 128 };
if (mousedev->touch) {
size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
if (size == 0) size = 256 * 2;
switch (code) {
case ABS_X:
size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
if (size == 0) size = xres;
fx(0) = value;
if (mousedev->pkt_count >= 2)
mousedev->packet.dx = ((fx(0) - fx(1)) / 2 + (fx(1) - fx(2)) / 2) * xres / (size * 2);
if (mousedev->pkt_count >= 2) {
tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
tmp += mousedev->frac_dx;
mousedev->packet.dx = tmp / FRACTION_DENOM;
mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
}
break;
case ABS_Y:
size = dev->absmax[ABS_Y] - dev->absmin[ABS_Y];
if (size == 0) size = yres;
fy(0) = value;
if (mousedev->pkt_count >= 2)
mousedev->packet.dy = -((fy(0) - fy(1)) / 2 + (fy(1) - fy(2)) / 2) * yres / (size * 2);
if (mousedev->pkt_count >= 2) {
tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
tmp += mousedev->frac_dy;
mousedev->packet.dy = tmp / FRACTION_DENOM;
mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
}
break;
}
}
......@@ -268,6 +276,8 @@ static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
clear_bit(0, &mousedev_mix.packet.buttons);
}
mousedev->touch = mousedev->pkt_count = 0;
mousedev->frac_dx = 0;
mousedev->frac_dy = 0;
}
else
if (!mousedev->touch)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment