diff options
| author | Chase Douglas <chase.douglas@canonical.com> | 2010-07-05 09:57:52 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2010-07-11 17:01:51 -0400 |
| commit | e3612e8669b8c15278058f8dd52e3dc6e7d26710 (patch) | |
| tree | 387c8259006adbd4865046ef812613f714d3984f /drivers | |
| parent | c04266889b591165bdea396b20313bebb83c0fd6 (diff) | |
HID: magicmouse: report last touch up
The evdev multitouch protocol requires that a last MT sync event must be
sent after all touches are up. This change adds the last MT sync event
to the hid-magicmouse driver.
Also, don't send events when a touch leaves.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Michael Poole <mdpoole@troilus.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/hid/hid-magicmouse.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 0b89c1cf9ec4..ee7878785955 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c | |||
| @@ -98,6 +98,7 @@ struct magicmouse_sc { | |||
| 98 | short scroll_x; | 98 | short scroll_x; |
| 99 | short scroll_y; | 99 | short scroll_y; |
| 100 | u8 size; | 100 | u8 size; |
| 101 | u8 down; | ||
| 101 | } touches[16]; | 102 | } touches[16]; |
| 102 | int tracking_ids[16]; | 103 | int tracking_ids[16]; |
| 103 | }; | 104 | }; |
| @@ -170,6 +171,7 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
| 170 | int id = (misc >> 6) & 15; | 171 | int id = (misc >> 6) & 15; |
| 171 | int x = x_y << 12 >> 20; | 172 | int x = x_y << 12 >> 20; |
| 172 | int y = -(x_y >> 20); | 173 | int y = -(x_y >> 20); |
| 174 | int down = (tdata[7] & TOUCH_STATE_MASK) != TOUCH_STATE_NONE; | ||
| 173 | 175 | ||
| 174 | /* Store tracking ID and other fields. */ | 176 | /* Store tracking ID and other fields. */ |
| 175 | msc->tracking_ids[raw_id] = id; | 177 | msc->tracking_ids[raw_id] = id; |
| @@ -221,9 +223,11 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
| 221 | } | 223 | } |
| 222 | 224 | ||
| 223 | /* Generate the input events for this touch. */ | 225 | /* Generate the input events for this touch. */ |
| 224 | if (report_touches) { | 226 | if (report_touches && down) { |
| 225 | int orientation = (misc >> 10) - 32; | 227 | int orientation = (misc >> 10) - 32; |
| 226 | 228 | ||
| 229 | msc->touches[id].down = 1; | ||
| 230 | |||
| 227 | input_report_abs(input, ABS_MT_TRACKING_ID, id); | 231 | input_report_abs(input, ABS_MT_TRACKING_ID, id); |
| 228 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, tdata[3]); | 232 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, tdata[3]); |
| 229 | input_report_abs(input, ABS_MT_TOUCH_MINOR, tdata[4]); | 233 | input_report_abs(input, ABS_MT_TOUCH_MINOR, tdata[4]); |
| @@ -243,7 +247,7 @@ static int magicmouse_raw_event(struct hid_device *hdev, | |||
| 243 | { | 247 | { |
| 244 | struct magicmouse_sc *msc = hid_get_drvdata(hdev); | 248 | struct magicmouse_sc *msc = hid_get_drvdata(hdev); |
| 245 | struct input_dev *input = msc->input; | 249 | struct input_dev *input = msc->input; |
| 246 | int x, y, ts, ii, clicks; | 250 | int x, y, ts, ii, clicks, last_up; |
| 247 | 251 | ||
| 248 | switch (data[0]) { | 252 | switch (data[0]) { |
| 249 | case 0x10: | 253 | case 0x10: |
| @@ -263,6 +267,20 @@ static int magicmouse_raw_event(struct hid_device *hdev, | |||
| 263 | msc->ntouches = (size - 6) / 8; | 267 | msc->ntouches = (size - 6) / 8; |
| 264 | for (ii = 0; ii < msc->ntouches; ii++) | 268 | for (ii = 0; ii < msc->ntouches; ii++) |
| 265 | magicmouse_emit_touch(msc, ii, data + ii * 8 + 6); | 269 | magicmouse_emit_touch(msc, ii, data + ii * 8 + 6); |
| 270 | |||
| 271 | if (report_touches) { | ||
| 272 | last_up = 1; | ||
| 273 | for (ii = 0; ii < ARRAY_SIZE(msc->touches); ii++) { | ||
| 274 | if (msc->touches[ii].down) { | ||
| 275 | last_up = 0; | ||
| 276 | msc->touches[ii].down = 0; | ||
| 277 | } | ||
| 278 | } | ||
| 279 | if (last_up) { | ||
| 280 | input_mt_sync(input); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 266 | /* When emulating three-button mode, it is important | 284 | /* When emulating three-button mode, it is important |
| 267 | * to have the current touch information before | 285 | * to have the current touch information before |
| 268 | * generating a click event. | 286 | * generating a click event. |
