Messages in this thread |  | | | Subject | Re: [PATCH 6/6] hid: egalax: Convert to MT slots | | From | Chase Douglas <> | | Date | Wed, 13 Oct 2010 13:35:08 -0400 |
| |
On Wed, 2010-10-13 at 15:58 +0200, Henrik Rydberg wrote: > The joojoo reports touches sequentially, one per report, which > confuses the current driver. Convert to the MT slots protocol and use > the stored slot information to emulate pointer movement in a stable > manner. > > Tested-by: Philipp Merkel <mail@philmerk.de> > Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
[...]
> @@ -122,64 +133,61 @@ static int egalax_input_mapped(struct hid_device *hdev, struct hid_input *hi, > return -1; > } > > +static void emulate_pointer(struct egalax_data *td, struct input_dev *input) > +{ > + struct egalax_contact *s = &td->single; > + struct egalax_contact *best = 0; > + int dbest, i; > + > + for (i = 0; i < MAX_SLOTS; i++) { > + struct egalax_contact *f = &td->contact[i]; > + if (f->touch) { > + int d = abs(f->x - s->x) + abs(f->y - s->y); > + if (!best || d < dbest) { > + best = f; > + dbest = d; > + }
Wouldn't it be better to do a real distance comparison:
int d = (f->x - s->x) * (f->x - s->x) + (f->y - s->y) * (f->y - s->y)
That should be the square of the actual distance between two contacts.
The rest looks ok to me.
-- Chase
|  |