Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 204389
b: refs/heads/master
c: e3612e8
h: refs/heads/master
i:
  204387: 4d4b9c5
v: v3
  • Loading branch information
Chase Douglas authored and Jiri Kosina committed Jul 11, 2010
1 parent 79c5b52 commit bcc0a16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c04266889b591165bdea396b20313bebb83c0fd6
refs/heads/master: e3612e8669b8c15278058f8dd52e3dc6e7d26710
22 changes: 20 additions & 2 deletions trunk/drivers/hid/hid-magicmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct magicmouse_sc {
short scroll_x;
short scroll_y;
u8 size;
u8 down;
} touches[16];
int tracking_ids[16];
};
Expand Down Expand Up @@ -170,6 +171,7 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
int id = (misc >> 6) & 15;
int x = x_y << 12 >> 20;
int y = -(x_y >> 20);
int down = (tdata[7] & TOUCH_STATE_MASK) != TOUCH_STATE_NONE;

/* Store tracking ID and other fields. */
msc->tracking_ids[raw_id] = id;
Expand Down Expand Up @@ -221,9 +223,11 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
}

/* Generate the input events for this touch. */
if (report_touches) {
if (report_touches && down) {
int orientation = (misc >> 10) - 32;

msc->touches[id].down = 1;

input_report_abs(input, ABS_MT_TRACKING_ID, id);
input_report_abs(input, ABS_MT_TOUCH_MAJOR, tdata[3]);
input_report_abs(input, ABS_MT_TOUCH_MINOR, tdata[4]);
Expand All @@ -243,7 +247,7 @@ static int magicmouse_raw_event(struct hid_device *hdev,
{
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
struct input_dev *input = msc->input;
int x, y, ts, ii, clicks;
int x, y, ts, ii, clicks, last_up;

switch (data[0]) {
case 0x10:
Expand All @@ -263,6 +267,20 @@ static int magicmouse_raw_event(struct hid_device *hdev,
msc->ntouches = (size - 6) / 8;
for (ii = 0; ii < msc->ntouches; ii++)
magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);

if (report_touches) {
last_up = 1;
for (ii = 0; ii < ARRAY_SIZE(msc->touches); ii++) {
if (msc->touches[ii].down) {
last_up = 0;
msc->touches[ii].down = 0;
}
}
if (last_up) {
input_mt_sync(input);
}
}

/* When emulating three-button mode, it is important
* to have the current touch information before
* generating a click event.
Expand Down

0 comments on commit bcc0a16

Please sign in to comment.