Patchwork usb-hid: Fix 0/0 position for Windows in tablet mode

login
register
mail settings
Submitter Jan Kiszka
Date June 24, 2011, 2:27 p.m.
Message ID <4E049EB7.4010309@siemens.com>
Download mbox | patch
Permalink /patch/101806/
State New
Headers show

Comments

Jan Kiszka - June 24, 2011, 2:27 p.m.
For unknown reasons, Windows drivers (tested with XP and Win7) ignore
usb-tablet events that move the pointer to 0/0. So always set bit 0 of
the coordinates.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/usb-hid.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Andreas Färber - June 25, 2011, 12:37 p.m.
Am 24.06.2011 um 16:27 schrieb Jan Kiszka:

> For unknown reasons, Windows drivers (tested with XP and Win7) ignore
> usb-tablet events that move the pointer to 0/0. So always set bit 0 of
> the coordinates.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> hw/usb-hid.c |    6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/usb-hid.c b/hw/usb-hid.c
> index d711b5c..2b9a451 100644
> --- a/hw/usb-hid.c
> +++ b/hw/usb-hid.c
> @@ -457,8 +457,10 @@ static void  
> usb_pointer_event_combine(USBPointerEvent *e, int xyrel,
>         e->xdx += x1;
>         e->ydy += y1;
>     } else {
> -        e->xdx = x1;
> -        e->ydy = y1;
> +        /* Windows drivers do not like the 0/0 position and ignore  
> such
> +         * events. */
> +        e->xdx = x1 | 1;
> +        e->ydy = y1 | 1;

Doesn't this change mean we can't access any other even pixel either?

Andreas

>     }
>     e->dz += z1;
> }
Jan Kiszka - June 25, 2011, 12:55 p.m.
On 2011-06-25 14:37, Andreas Färber wrote:
> Am 24.06.2011 um 16:27 schrieb Jan Kiszka:
> 
>> For unknown reasons, Windows drivers (tested with XP and Win7) ignore
>> usb-tablet events that move the pointer to 0/0. So always set bit 0 of
>> the coordinates.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>> hw/usb-hid.c |    6 ++++--
>> 1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/usb-hid.c b/hw/usb-hid.c
>> index d711b5c..2b9a451 100644
>> --- a/hw/usb-hid.c
>> +++ b/hw/usb-hid.c
>> @@ -457,8 +457,10 @@ static void
>> usb_pointer_event_combine(USBPointerEvent *e, int xyrel,
>>         e->xdx += x1;
>>         e->ydy += y1;
>>     } else {
>> -        e->xdx = x1;
>> -        e->ydy = y1;
>> +        /* Windows drivers do not like the 0/0 position and ignore such
>> +         * events. */
>> +        e->xdx = x1 | 1;
>> +        e->ydy = y1 | 1;
> 
> Doesn't this change mean we can't access any other even pixel either?

Only on 32767x32767 screens (that's the resolution of the tablet).

Jan
Andreas Färber - June 25, 2011, 1:10 p.m.
Am 25.06.2011 um 14:55 schrieb Jan Kiszka:

> On 2011-06-25 14:37, Andreas Färber wrote:
>> Am 24.06.2011 um 16:27 schrieb Jan Kiszka:
>>
>>> For unknown reasons, Windows drivers (tested with XP and Win7)  
>>> ignore
>>> usb-tablet events that move the pointer to 0/0. So always set bit  
>>> 0 of
>>> the coordinates.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> ---
>>> hw/usb-hid.c |    6 ++++--
>>> 1 files changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/hw/usb-hid.c b/hw/usb-hid.c
>>> index d711b5c..2b9a451 100644
>>> --- a/hw/usb-hid.c
>>> +++ b/hw/usb-hid.c
>>> @@ -457,8 +457,10 @@ static void
>>> usb_pointer_event_combine(USBPointerEvent *e, int xyrel,
>>>        e->xdx += x1;
>>>        e->ydy += y1;
>>>    } else {
>>> -        e->xdx = x1;
>>> -        e->ydy = y1;
>>> +        /* Windows drivers do not like the 0/0 position and  
>>> ignore such
>>> +         * events. */
>>> +        e->xdx = x1 | 1;
>>> +        e->ydy = y1 | 1;
>>
>> Doesn't this change mean we can't access any other even pixel either?
>
> Only on 32767x32767 screens (that's the resolution of the tablet).

Well, if it's just a fix for 0/0 I would've expected something like:

e->xdx = x1 ? x1 : 1;
e->ydy = y1 ? y1 : 1;

Andreas
Jan Kiszka - June 26, 2011, 9:11 a.m.
On 2011-06-25 15:10, Andreas Färber wrote:
> Am 25.06.2011 um 14:55 schrieb Jan Kiszka:
> 
>> On 2011-06-25 14:37, Andreas Färber wrote:
>>> Am 24.06.2011 um 16:27 schrieb Jan Kiszka:
>>>
>>>> For unknown reasons, Windows drivers (tested with XP and Win7) ignore
>>>> usb-tablet events that move the pointer to 0/0. So always set bit 0 of
>>>> the coordinates.
>>>>
>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>> ---
>>>> hw/usb-hid.c |    6 ++++--
>>>> 1 files changed, 4 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/hw/usb-hid.c b/hw/usb-hid.c
>>>> index d711b5c..2b9a451 100644
>>>> --- a/hw/usb-hid.c
>>>> +++ b/hw/usb-hid.c
>>>> @@ -457,8 +457,10 @@ static void
>>>> usb_pointer_event_combine(USBPointerEvent *e, int xyrel,
>>>>        e->xdx += x1;
>>>>        e->ydy += y1;
>>>>    } else {
>>>> -        e->xdx = x1;
>>>> -        e->ydy = y1;
>>>> +        /* Windows drivers do not like the 0/0 position and ignore
>>>> such
>>>> +         * events. */
>>>> +        e->xdx = x1 | 1;
>>>> +        e->ydy = y1 | 1;
>>>
>>> Doesn't this change mean we can't access any other even pixel either?
>>
>> Only on 32767x32767 screens (that's the resolution of the tablet).
> 
> Well, if it's just a fix for 0/0 I would've expected something like:
> 
> e->xdx = x1 ? x1 : 1;
> e->ydy = y1 ? y1 : 1;

Works as well, my version is a little bit simpler. But I don't mind,
will post whatever is preferred to fix this.

Jan
andrzej zaborowski - July 4, 2011, 6:15 p.m.
On 26 June 2011 11:11, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2011-06-25 15:10, Andreas Färber wrote:
>> Am 25.06.2011 um 14:55 schrieb Jan Kiszka:
>>
>>> On 2011-06-25 14:37, Andreas Färber wrote:
>>>> Am 24.06.2011 um 16:27 schrieb Jan Kiszka:
>>>>
>>>>> For unknown reasons, Windows drivers (tested with XP and Win7) ignore
>>>>> usb-tablet events that move the pointer to 0/0. So always set bit 0 of
>>>>> the coordinates.
>>>>>
>>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>>> ---
>>>>> hw/usb-hid.c |    6 ++++--
>>>>> 1 files changed, 4 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/hw/usb-hid.c b/hw/usb-hid.c
>>>>> index d711b5c..2b9a451 100644
>>>>> --- a/hw/usb-hid.c
>>>>> +++ b/hw/usb-hid.c
>>>>> @@ -457,8 +457,10 @@ static void
>>>>> usb_pointer_event_combine(USBPointerEvent *e, int xyrel,
>>>>>        e->xdx += x1;
>>>>>        e->ydy += y1;
>>>>>    } else {
>>>>> -        e->xdx = x1;
>>>>> -        e->ydy = y1;
>>>>> +        /* Windows drivers do not like the 0/0 position and ignore
>>>>> such
>>>>> +         * events. */
>>>>> +        e->xdx = x1 | 1;
>>>>> +        e->ydy = y1 | 1;
>>>>
>>>> Doesn't this change mean we can't access any other even pixel either?
>>>
>>> Only on 32767x32767 screens (that's the resolution of the tablet).
>>
>> Well, if it's just a fix for 0/0 I would've expected something like:
>>
>> e->xdx = x1 ? x1 : 1;
>> e->ydy = y1 ? y1 : 1;
>
> Works as well, my version is a little bit simpler. But I don't mind,
> will post whatever is preferred to fix this.

Would it be enough to just do this for x or y, not both?

Cheers

Patch

diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index d711b5c..2b9a451 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -457,8 +457,10 @@  static void usb_pointer_event_combine(USBPointerEvent *e, int xyrel,
         e->xdx += x1;
         e->ydy += y1;
     } else {
-        e->xdx = x1;
-        e->ydy = y1;
+        /* Windows drivers do not like the 0/0 position and ignore such
+         * events. */
+        e->xdx = x1 | 1;
+        e->ydy = y1 | 1;
     }
     e->dz += z1;
 }