linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ntrig tool separation
@ 2009-06-17  5:50 Rafi Rubin
  2009-06-17 13:41 ` Stéphane Chatty
  0 siblings, 1 reply; 3+ messages in thread
From: Rafi Rubin @ 2009-06-17  5:50 UTC (permalink / raw)
  To: linux-input; +Cc: Stéphane Chatty

When both touch and pen are active send a tool announcement before
sending any status changes so that event users may differentiate
which tool is changing.

Signed-off-by: Rafi Rubin <rafi@seas.upenn.edu>
---
 drivers/hid/hid-ntrig.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index aeab973..46ece5e 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -27,6 +27,9 @@
 struct ntrig_data {
 	__s32 x, y, id, w, h;
 	char reading_a_point, found_contact_id;
+	char pen_active;
+	char finger_active;
+	char inverted;
 };

 /*
@@ -127,11 +130,37 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 	struct input_dev *input = field->hidinput->input;
 	struct ntrig_data *nd = hid_get_drvdata(hid);

+	__u16 tool;
+
         if (hid->claimed & HID_CLAIMED_INPUT) {
 		switch (usage->hid) {
+
+		case HID_DG_INRANGE:
+			if(field->application & 0x3)
+				nd->pen_active = value!=0;
+			else
+				nd->finger_active = value!=0;
+			return 0;
+
+		case HID_DG_INVERT:
+			nd->inverted = value;
+			return 0;
+
 		case HID_GD_X:
 			nd->x = value;
 			nd->reading_a_point = 1;
+			if(nd->pen_active && nd->finger_active)
+			{
+				if(field->application & 0x3)
+				{
+					tool = nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
+				}
+				else
+					tool = BTN_TOOL_DOUBLETAP;
+
+				input_report_key(input, tool, 0);
+				input_report_key(input, tool, 1);
+			}
 			break;
 		case HID_GD_Y:
 			nd->y = value;
-- 
1.6.3.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ntrig tool separation
  2009-06-17  5:50 [PATCH] ntrig tool separation Rafi Rubin
@ 2009-06-17 13:41 ` Stéphane Chatty
  2009-06-17 18:37   ` Rafi Rubin
  0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Chatty @ 2009-06-17 13:41 UTC (permalink / raw)
  To: Rafi Rubin; +Cc: linux-input


Le 17 juin 09 à 07:50, Rafi Rubin a écrit :

> When both touch and pen are active send a tool announcement before
> sending any status changes so that event users may differentiate
> which tool is changing.
>

With my multitouch-enabled TouchSmart tx2 (firwmare 4.2.17.8.5,  
finally found it!) I get a series of ten BTN_TOOL_DOUBLETAP (value =  
0 then 1, five times) in every event. This is because the device  
emits HID_GD_X several times in every event, whatever the real number  
of touches on the screen.

The way to avoid this would be to delay the emission of your  
BTN_TOOL_DOUBLETAP as I did for ABS_X and ABS_Y, that is when we  
receive HID_DG_HEIGHT (single touch firmware) or 0xff000002 (multi- 
touch firmware)

St.

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ntrig tool separation
  2009-06-17 13:41 ` Stéphane Chatty
@ 2009-06-17 18:37   ` Rafi Rubin
  0 siblings, 0 replies; 3+ messages in thread
From: Rafi Rubin @ 2009-06-17 18:37 UTC (permalink / raw)
  To: Stéphane Chatty; +Cc: linux-input

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Good point, that's actually what I did earlier in my much sloppier version.  I'll rewrite this patch.

Stéphane Chatty wrote:
> 
> Le 17 juin 09 à 07:50, Rafi Rubin a écrit :
> 
>> When both touch and pen are active send a tool announcement before
>> sending any status changes so that event users may differentiate
>> which tool is changing.
>>
> 
> With my multitouch-enabled TouchSmart tx2 (firwmare 4.2.17.8.5, finally
> found it!) I get a series of ten BTN_TOOL_DOUBLETAP (value = 0 then 1,
> five times) in every event. This is because the device emits HID_GD_X
> several times in every event, whatever the real number of touches on the
> screen.
> 
> The way to avoid this would be to delay the emission of your
> BTN_TOOL_DOUBLETAP as I did for ABS_X and ABS_Y, that is when we receive
> HID_DG_HEIGHT (single touch firmware) or 0xff000002 (multi-touch firmware)
> 
> St.
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAko5N/cACgkQwuRiAT9o609lZACfUyxsUSbrSXSsZtJFXLgBSU9B
J0kAmwSeANwjprdqc6BTjIFozVWsfQxn
=5z+v
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-06-17 18:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17  5:50 [PATCH] ntrig tool separation Rafi Rubin
2009-06-17 13:41 ` Stéphane Chatty
2009-06-17 18:37   ` Rafi Rubin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).