aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mousedev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mousedev.c')
-rw-r--r--drivers/input/mousedev.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 764970f5da2e..3b8011c56c86 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -124,32 +124,33 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
124 int size, tmp; 124 int size, tmp;
125 enum { FRACTION_DENOM = 128 }; 125 enum { FRACTION_DENOM = 128 };
126 126
127 if (mousedev->touch) { 127 switch (code) {
128 size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; 128 case ABS_X:
129 if (size == 0) 129 fx(0) = value;
130 size = 256 * 2; 130 if (mousedev->touch && mousedev->pkt_count >= 2) {
131 131 size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
132 switch (code) { 132 if (size == 0)
133 case ABS_X: 133 size = 256 * 2;
134 fx(0) = value; 134 tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
135 if (mousedev->pkt_count >= 2) { 135 tmp += mousedev->frac_dx;
136 tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size; 136 mousedev->packet.dx = tmp / FRACTION_DENOM;
137 tmp += mousedev->frac_dx; 137 mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
138 mousedev->packet.dx = tmp / FRACTION_DENOM; 138 }
139 mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM; 139 break;
140 }
141 break;
142 140
143 case ABS_Y: 141 case ABS_Y:
144 fy(0) = value; 142 fy(0) = value;
145 if (mousedev->pkt_count >= 2) { 143 if (mousedev->touch && mousedev->pkt_count >= 2) {
146 tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size; 144 /* use X size to keep the same scale */
147 tmp += mousedev->frac_dy; 145 size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
148 mousedev->packet.dy = tmp / FRACTION_DENOM; 146 if (size == 0)
149 mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM; 147 size = 256 * 2;
150 } 148 tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
151 break; 149 tmp += mousedev->frac_dy;
152 } 150 mousedev->packet.dy = tmp / FRACTION_DENOM;
151 mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
152 }
153 break;
153 } 154 }
154} 155}
155 156