Skip to contentSkip to conversation

ntrig tool separation

PATCH In review Rafi Rubin 2 participants 3 messages Jun 17, 2009 HID

lore
Share & tools
lore

Rafi Rubin

author
#0 lore raw

PATCH 1/1 ntrig tool separation

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.

---
 drivers/hid/hid-ntrig.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
drivers/hid/hid-ntrig.c +29 -0
index aeab973..46ece5e 100644
@@ -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;
Signature · 1 line
1.6.3.1
#1 lore raw
Quoted 4 lines · Rafi Rubin

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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw

-----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.

Quoted 14 lines · Stéphane Chatty
Quoted 4 lines · Rafi Rubin

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.

Quoted 11 lines

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.

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html