diff options
Diffstat (limited to 'drivers/hid/hid-magicmouse.c')
-rw-r--r-- | drivers/hid/hid-magicmouse.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 004c01d9a61a..402682e0c2f4 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c | |||
@@ -158,18 +158,21 @@ static void magicmouse_emit_buttons(struct magicmouse_sc *msc, int state) | |||
158 | static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tdata) | 158 | static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tdata) |
159 | { | 159 | { |
160 | struct input_dev *input = msc->input; | 160 | struct input_dev *input = msc->input; |
161 | __s32 x_y = tdata[0] << 8 | tdata[1] << 16 | tdata[2] << 24; | 161 | int id = (tdata[6] << 2 | tdata[5] >> 6) & 0xf; |
162 | int misc = tdata[5] | tdata[6] << 8; | 162 | int x = (tdata[1] << 28 | tdata[0] << 20) >> 20; |
163 | int id = (misc >> 6) & 15; | 163 | int y = -((tdata[2] << 24 | tdata[1] << 16) >> 20); |
164 | int x = x_y << 12 >> 20; | 164 | int size = tdata[5] & 0x3f; |
165 | int y = -(x_y >> 20); | 165 | int orientation = (tdata[6] >> 2) - 32; |
166 | int down = (tdata[7] & TOUCH_STATE_MASK) != TOUCH_STATE_NONE; | 166 | int touch_major = tdata[3]; |
167 | int touch_minor = tdata[4]; | ||
168 | int state = tdata[7] & TOUCH_STATE_MASK; | ||
169 | int down = state != TOUCH_STATE_NONE; | ||
167 | 170 | ||
168 | /* Store tracking ID and other fields. */ | 171 | /* Store tracking ID and other fields. */ |
169 | msc->tracking_ids[raw_id] = id; | 172 | msc->tracking_ids[raw_id] = id; |
170 | msc->touches[id].x = x; | 173 | msc->touches[id].x = x; |
171 | msc->touches[id].y = y; | 174 | msc->touches[id].y = y; |
172 | msc->touches[id].size = misc & 63; | 175 | msc->touches[id].size = size; |
173 | 176 | ||
174 | /* If requested, emulate a scroll wheel by detecting small | 177 | /* If requested, emulate a scroll wheel by detecting small |
175 | * vertical touch motions. | 178 | * vertical touch motions. |
@@ -180,7 +183,7 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
180 | int step_y = msc->touches[id].scroll_y - y; | 183 | int step_y = msc->touches[id].scroll_y - y; |
181 | 184 | ||
182 | /* Calculate and apply the scroll motion. */ | 185 | /* Calculate and apply the scroll motion. */ |
183 | switch (tdata[7] & TOUCH_STATE_MASK) { | 186 | switch (state) { |
184 | case TOUCH_STATE_START: | 187 | case TOUCH_STATE_START: |
185 | msc->touches[id].scroll_x = x; | 188 | msc->touches[id].scroll_x = x; |
186 | msc->touches[id].scroll_y = y; | 189 | msc->touches[id].scroll_y = y; |
@@ -216,11 +219,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
216 | 219 | ||
217 | /* Generate the input events for this touch. */ | 220 | /* Generate the input events for this touch. */ |
218 | if (report_touches && down) { | 221 | if (report_touches && down) { |
219 | int orientation = (misc >> 10) - 32; | ||
220 | |||
221 | input_report_abs(input, ABS_MT_TRACKING_ID, id); | 222 | input_report_abs(input, ABS_MT_TRACKING_ID, id); |
222 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, tdata[3]); | 223 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, touch_major); |
223 | input_report_abs(input, ABS_MT_TOUCH_MINOR, tdata[4]); | 224 | input_report_abs(input, ABS_MT_TOUCH_MINOR, touch_minor); |
224 | input_report_abs(input, ABS_MT_ORIENTATION, orientation); | 225 | input_report_abs(input, ABS_MT_ORIENTATION, orientation); |
225 | input_report_abs(input, ABS_MT_POSITION_X, x); | 226 | input_report_abs(input, ABS_MT_POSITION_X, x); |
226 | input_report_abs(input, ABS_MT_POSITION_Y, y); | 227 | input_report_abs(input, ABS_MT_POSITION_Y, y); |