lkml.org 
[lkml]   [2010]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 6/6] hid: egalax: Convert to MT slots
    From
    Date
    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



    \
     
     \ /
      Last update: 2010-10-13 19:37    [W:0.047 / U:59.312 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site