On Wed, Dec 7, 2011 at 2:16 PM, Jason Gerecke <[email protected]> wrote:
> This patch breaks the Graphire 4. The X driver appears to get confused
> about what buttons are being pressed. This happens with all tools,
> from what I can tell. Only the right mouse button appears to work
> correctly, and can be used to get the driver back in sync with reality
> until you make another non-right click.

I think I see the bug in patch.  I'll point it out below and try to
send an updated patch at another time.

>
> Jason
>
> ---
> Day xee-nee-svsh duu-'ushtlh-ts'it;
> nuu-wee-ya' duu-xan' 'vm-nvshtlh-ts'it.
> Huu-chan xuu naa~-gha.
>
>
>
> On Thu, Dec 1, 2011 at 8:02 PM,  <[email protected]> wrote:
>> From: Chris Bagwell <[email protected]>
>>
>> Don't work so hard to not report events.  Let input event
>> filtering do its thing for us.  Makes it easier to follow
>> data parsing vs. event sending features.
>>
>> Left in event filtering for overlapping events and had
>> a purpose for preventing events.
>>
>> Signed-off-by: Chris Bagwell <[email protected]>
>> ---
>>  drivers/input/tablet/wacom_wac.c |  141 
>> ++++++++++++++++++++++---------------
>>  1 files changed, 84 insertions(+), 57 deletions(-)
>>
>> diff --git a/drivers/input/tablet/wacom_wac.c 
>> b/drivers/input/tablet/wacom_wac.c
>> index 7b69a21..7acc87b 100644
>> --- a/drivers/input/tablet/wacom_wac.c
>> +++ b/drivers/input/tablet/wacom_wac.c
>> @@ -206,9 +206,10 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
>>        struct wacom_features *features = &wacom->features;
>>        unsigned char *data = wacom->data;
>>        struct input_dev *input = wacom->input;
>> -       int prox;
>> -       int rw = 0;
>>        int retval = 0;
>> +       int prox, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
>> +       int btnl = 0, btnm = 0, btnr = 0, btnb = 0, btnf = 0;
>> +       int rw = 0, aw = 0;
>>
>>        if (data[0] != WACOM_REPORT_PENABLED) {
>>                dbg("wacom_graphire_irq: received unknown report #%d", 
>> data[0]);
>> @@ -216,86 +217,112 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
>>        }
>>
>>        prox = data[1] & 0x80;
>> -       if (prox || wacom->id[0]) {
>> -               if (prox) {
>> -                       switch ((data[1] >> 5) & 3) {
>> +       if (prox) {
>> +               switch ((data[1] >> 5) & 3) {
>>
>> -                       case 0: /* Pen */
>> -                               wacom->tool[0] = BTN_TOOL_PEN;
>> -                               wacom->id[0] = STYLUS_DEVICE_ID;
>> -                               break;
>> +               case 0: /* Pen */
>> +                       wacom->tool[0] = BTN_TOOL_PEN;
>> +                       break;
>>
>> -                       case 1: /* Rubber */
>> -                               wacom->tool[0] = BTN_TOOL_RUBBER;
>> -                               wacom->id[0] = ERASER_DEVICE_ID;
>> -                               break;
>> +               case 1: /* Rubber */
>> +                       wacom->tool[0] = BTN_TOOL_RUBBER;
>> +                       break;
>>
>> -                       case 2: /* Mouse with wheel */
>> -                               input_report_key(input, BTN_MIDDLE, data[1] 
>> & 0x04);
>> -                               /* fall through */
>> +               case 2: /* Mouse with wheel */
>> +                       btnm = data[1] & 0x04;
>> +                       /* fall through */
>>
>> -                       case 3: /* Mouse without wheel */
>> -                               wacom->tool[0] = BTN_TOOL_MOUSE;
>> -                               wacom->id[0] = CURSOR_DEVICE_ID;
>> -                               break;
>> -                       }
>> +               case 3: /* Mouse without wheel */
>> +                       wacom->tool[0] = BTN_TOOL_MOUSE;
>> +                       break;
>>                }
>> -               input_report_abs(input, ABS_X, le16_to_cpup((__le16 
>> *)&data[2]));
>> -               input_report_abs(input, ABS_Y, le16_to_cpup((__le16 
>> *)&data[4]));
>> +               x = le16_to_cpup((__le16 *)&data[2]);
>> +               y = le16_to_cpup((__le16 *)&data[4]);
>>                if (wacom->tool[0] != BTN_TOOL_MOUSE) {
>> -                       input_report_abs(input, ABS_PRESSURE, data[6] | 
>> ((data[7] & 0x01) << 8));
>> -                       input_report_key(input, BTN_TOUCH, data[1] & 0x01);
>> -                       input_report_key(input, BTN_STYLUS, data[1] & 0x02);
>> -                       input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
>> +                       p = data[6] | ((data[7] & 0x01) << 8);
>> +                       pen = data[1] & 0x01;
>> +                       btn1 = data[1] & 0x02;
>> +                       btn2 = data[1] & 0x04;
>>                } else {
>> -                       input_report_key(input, BTN_LEFT, data[1] & 0x01);
>> -                       input_report_key(input, BTN_RIGHT, data[1] & 0x02);
>> +                       btnl = data[1] & 0x01;
>> +                       btnr = data[1] & 0x02;
>>                        if (features->type == WACOM_G4 ||
>>                                        features->type == WACOM_MO) {
>> -                               input_report_abs(input, ABS_DISTANCE, 
>> data[6] & 0x3f);
>> +                               d = data[6] & 0x3f;
>>                                rw = (data[7] & 0x04) - (data[7] & 0x03);
>>                        } else {
>> -                               input_report_abs(input, ABS_DISTANCE, 
>> data[7] & 0x3f);
>> +                               d = data[7] & 0x3f;
>>                                rw = -(signed char)data[6];
>>                        }
>> -                       input_report_rel(input, REL_WHEEL, rw);
>>                }
>> +       }
>>
>> -               if (!prox)
>> -                       wacom->id[0] = 0;
>> -               input_report_key(input, wacom->tool[0], prox);
>> -               input_sync(input); /* sync last event */
>> +       input_report_abs(input, ABS_X, x);
>> +       input_report_abs(input, ABS_Y, y);
>> +       input_report_abs(input, ABS_PRESSURE, p);
>> +       input_report_key(input, BTN_TOUCH, pen);
>> +       input_report_key(input, BTN_STYLUS, btn1);
>> +       input_report_key(input, BTN_STYLUS2, btn2);
>> +       input_report_abs(input, ABS_DISTANCE, d);
>> +       input_report_rel(input, REL_WHEEL, rw);
>> +       input_report_key(input, BTN_MIDDLE, btnm);
>> +
>> +       /* Buttons on the mouse puck are sending the same events as
>> +        * buttons located on the tablet.
>> +        *
>> +        * The following is to only send these overlapping events
>> +        * when pressed and once more upon release so that the
>> +        * two sources are not fighting each other.
>> +        *
>> +        * It would be odd for user to click the mouse puck and tablet
>> +        * buttons at same time.
>> +        */
>> +       if (btnl || btnr || wacom->id[0]) {
>> +               input_report_key(input, BTN_LEFT, btnl);
>> +               input_report_key(input, BTN_RIGHT, btnr);
>> +               wacom->id[0] = 0;
>>        }

That should be something like this.  Without it, we were never sending
the button release event.

       if (btnl || btnr || wacom->id[0]) {
               wacom->id[0] = CURSOR_DEVICE_ID;
               input_report_key(input, BTN_LEFT, btnl);
               input_report_key(input, BTN_RIGHT, btnr);
               if (wacom->id[0])
                       wacom->id[0] = 0;
      }

Could be more bugs lurking, I'm sure.

Chris

>>
>> +       input_report_key(input, wacom->tool[0], prox);
>> +       input_sync(input); /* sync last event */
>> +
>>        /* send pad data */
>>        switch (features->type) {
>>        case WACOM_G4:
>> -               prox = data[7] & 0xf8;
>> -               if (prox || wacom->id[1]) {
>> -                       wacom->id[1] = PAD_DEVICE_ID;
>> -                       input_report_key(input, BTN_BACK, (data[7] & 0x40));
>> -                       input_report_key(input, BTN_FORWARD, (data[7] & 
>> 0x80));
>> -                       rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 
>> 3);
>> -                       input_report_rel(input, REL_WHEEL, rw);
>> -                       if (!prox)
>> -                               wacom->id[1] = 0;
>> -                       retval = 1;
>> -               }
>> +               btnb = (data[7] & 0x40);
>> +               btnf = (data[7] & 0x80);
>> +               aw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
>> +               input_report_key(input, BTN_BACK, (data[7] & 0x40));
>> +               input_report_key(input, BTN_FORWARD, (data[7] & 0x80));
>> +               input_report_rel(input, REL_WHEEL, aw);
>> +               retval = 1;
>> +
>>                break;
>>
>>        case WACOM_MO:
>> -               prox = (data[7] & 0xf8) || data[8];
>> -               if (prox || wacom->id[1]) {
>> +               btnb = (data[7] & 0x08);
>> +               btnf = (data[7] & 0x10);
>> +               aw = (data[8] & 0x7f);
>> +               input_report_key(input, BTN_BACK, btnb);
>> +               input_report_key(input, BTN_FORWARD, btnf);
>> +               input_report_abs(input, ABS_WHEEL, aw);
>> +
>> +               /* See comment for mouse puck buttons above */
>> +               btnl = 0;
>> +               btnr = 0;
>> +               prox = data[7] & 0x60;
>> +               if (prox) {
>> +                       btnl = (data[7] & 0x20);
>> +                       btnr = (data[7] & 0x40);
>>                        wacom->id[1] = PAD_DEVICE_ID;
>> -                       input_report_key(input, BTN_BACK, (data[7] & 0x08));
>> -                       input_report_key(input, BTN_LEFT, (data[7] & 0x20));
>> -                       input_report_key(input, BTN_FORWARD, (data[7] & 
>> 0x10));
>> -                       input_report_key(input, BTN_RIGHT, (data[7] & 0x40));
>> -                       input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
>> -                       if (!prox)
>> -                               wacom->id[1] = 0;
>> -                       retval = 1;
>> +               };
>> +               if (prox || wacom->id[1]) {
>> +                       input_report_key(input, BTN_LEFT, btnl);
>> +                       input_report_key(input, BTN_RIGHT, btnr);
>> +                       wacom->id[1] = 0;
>>                }
>> +               retval = 1;
>> +
>>                break;
>>        }
>>  exit:
>> --
>> 1.7.7.3
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure
>> contains a definitive record of customers, application performance,
>> security threats, fraudulent activity, and more. Splunk takes this
>> data and makes sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-novd2d
>> _______________________________________________
>> Linuxwacom-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to