The way of touch finger and pen stylus report
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Scott,
Quoted 10 lines · 劉嘉駿
I would like to write a touch driver for finger touch and pen stylus.
They have different definition on maximum range of X, Y, Pressure,
additionally, pen have two buttons functionality that need to be reported.
So can driver register two input device to corresponding finger touch and pen stylus?
Yes, and that's the only way you can achieve that. Each (touch and pen) should have their own input node.
Quoted 3 lines
Otherwise how single input device can map two different X, Y, Pressure range.
That's not possible. There use to be something roughly like that in the wacom.ko driver in the past, but this wasn't compatible with wayland. So now every driver reports 2 input nodes in such cases.
Quoted 10 lines
Another thing is that pen stylus has two buttons which enumerate to Eraser/Invert and Barrel as MS spec said.
Please refer to
https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design/component-guidelines/required-hid-top-level-collectionsMy question is that how do buttons represents to key bit event? Any example?
HID should handle it properly. You should map it to BTN_TOOL_RUBBER in case you are not using a HID device.
There is not much to do with this bit: if button is depressed, set the tool to BTN_TOOL_RUBBER, and when released, switch back to BTN_TOOL_PEN.
Cheers,
Benjamin
Quoted 12 lines
Thanks.
BR,
Scott
Hi Benjamin,
I appreciate your quick response.
I referred to Wacom_i2c.c which is an example about how does pen stylus report. My firmware are listed following hid usage as MS' specification :
Barrel, Invert, Erase
And I think the those hid usage is mapping to below event code:
HID usage : linux-input EV_* code
Eraser : BTN_TOOL_RUBBER (button1 with pen contact on touch surface)
Invert : ?? (button1 with pen hover)
Barrel : BTN_STYLUS (button2)
Can you tell me what event code is mapped to hid usage "Invert"?
My device is hid-i2c and what else I need to do after I built hid-i2c module into kernel? Like, do I need add my device information to whitelist.
Thanks!!
BR,
Scott
-----Original Message-----
From: Benjamin Tissoires [mailto:[email protected]]
Sent: Friday, May 05, 2017 3:33 PM
To: 劉嘉駿
Cc: linux-input; Dmitry Torokhov
Subject: Re: The way of touch finger and pen stylus report
Hi Scott,
Quoted 10 lines · 劉嘉駿
I would like to write a touch driver for finger touch and pen stylus.
They have different definition on maximum range of X, Y, Pressure,
additionally, pen have two buttons functionality that need to be reported.
So can driver register two input device to corresponding finger touch and pen stylus?
Yes, and that's the only way you can achieve that. Each (touch and pen) should have their own input node.
Quoted 3 lines
Otherwise how single input device can map two different X, Y, Pressure range.
That's not possible. There use to be something roughly like that in the wacom.ko driver in the past, but this wasn't compatible with wayland. So now every driver reports 2 input nodes in such cases.
Quoted 11 lines
Another thing is that pen stylus has two buttons which enumerate to Eraser/Invert and Barrel as MS spec said.
Please refer to
https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design
/component-guidelines/required-hid-top-level-collectionsMy question is that how do buttons represents to key bit event? Any example?
HID should handle it properly. You should map it to BTN_TOOL_RUBBER in case you are not using a HID device.
There is not much to do with this bit: if button is depressed, set the tool to BTN_TOOL_RUBBER, and when released, switch back to BTN_TOOL_PEN.
Cheers,
Benjamin
Quoted 12 lines
Thanks.
BR,
Scott
Quoted 11 lines · 劉嘉駿
Hi Benjamin,
I appreciate your quick response.
I referred toWacom_i2c.cwhich is an example about how does pen stylus report. My firmware are listed following hid usage as MS' specification :
Barrel, Invert, Erase
And I think the those hid usage is mapping to below event code:HID usage : linux-input EV_* code
Eraser :BTN_TOOL_RUBBER(button1 with pen contact on touch surface)
Invert : ?? (button1 with pen hover)
Barrel :BTN_STYLUS(button2)
IIRC, you should have:
Invert: BTN_TOOL_RUBBER (button 1 pressed, hover or touching)
Eraser: BTN_TOUCH (button1 with pen contact on touch surface)
Barrel: BTN_STYLUS (button2)
Note that as long as button 1 is pressed, your firmware should send invert to 1 (independently of the tip touching the surface).
That's how the wacom driver works, and how hid-input should be working (I haven't seen the eraser part in hid-input, so there might be a bug here). hid-input handles the pressure as tip switch too, so it should eb working fine if you report pressure.
Quoted 5 lines
Can you tell me what event code is mapped to hid usage "Invert"?
My device is hid-i2c and what else I need to do after I built hid-i2c module into kernel? Like, do I need add my device information to whitelist.
You should only build i2c-hid and hid-multitouch. Nothing else, no whitelist.
Cheers,
Benjamin
Quoted 66 lines
Thanks!!
BR,
Scott
-----Original Message-----
From: Benjamin Tissoires [mailto:[email protected]]
Sent: Friday, May 05, 2017 3:33 PM
To: 劉嘉駿
Cc: linux-input; Dmitry Torokhov
Subject: Re: The way of touch finger and pen stylus reportHi Scott,
Quoted 10 lines · 劉嘉駿
I would like to write a touch driver for finger touch and pen stylus.
They have different definition on maximum range of X, Y, Pressure,
additionally, pen have two buttons functionality that need to be reported.
So can driver register two input device to corresponding finger touch and pen stylus?
Yes, and that's the only way you can achieve that. Each (touch and pen) should have their own input node.
Quoted 3 lines
Otherwise how single input device can map two different X, Y, Pressure range.
That's not possible. There use to be something roughly like that in the wacom.ko driver in the past, but this wasn't compatible with wayland. So now every driver reports 2 input nodes in such cases.
Quoted 11 lines
Another thing is that pen stylus has two buttons which enumerate to Eraser/Invert and Barrel as MS spec said.
Please refer to
https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design
/component-guidelines/required-hid-top-level-collectionsMy question is that how do buttons represents to key bit event? Any example?
HID should handle it properly. You should map it to
BTN_TOOL_RUBBERin case you are not using a HID device.
There is not much to do with this bit: if button is depressed, set the tool toBTN_TOOL_RUBBER, and when released, switch back toBTN_TOOL_PEN.Cheers,
BenjaminQuoted 12 lines
Thanks.
BR,
Scott