All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ntrig tool separation and pen usages
@ 2009-06-17 22:48 Rafi Rubin
  2009-06-17 22:52 ` Rafi Rubin
  2009-06-23 12:01 ` Jiri Kosina
  0 siblings, 2 replies; 5+ messages in thread
From: Rafi Rubin @ 2009-06-17 22:48 UTC (permalink / raw)
  To: linux-input; +Cc: chatty, 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.

Restored three usage codes used by the pen.

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

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 75ed9d2..7765970 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;
 };
 
 /*
@@ -63,10 +66,7 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 	case HID_UP_DIGITIZER:
 		switch (usage->hid) {
 		/* we do not want to map these for now */
-		case HID_DG_INVERT: /* value is always 0 */
-		case HID_DG_ERASER: /* value is always 0 */
 		case HID_DG_CONTACTID: /* value is useless */
-		case HID_DG_BARRELSWITCH:  /* doubtful */
 		case HID_DG_INPUTMODE:
 		case HID_DG_DEVICEINDEX:
 		case HID_DG_CONTACTCOUNT:
@@ -125,6 +125,18 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 
         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;
@@ -148,6 +160,10 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 			 * to emit a normal (X, Y) position
 			 */
 			if (! nd->found_contact_id) {
+				if(nd->pen_active && nd->finger_active) {
+					input_report_key(input, BTN_TOOL_DOUBLETAP, 0);
+					input_report_key(input, BTN_TOOL_DOUBLETAP, 1);
+				}
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 			}
@@ -159,6 +175,14 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 			 * to emit a normal (X, Y) position
 			 */
 			if (! nd->found_contact_id) {
+				if(nd->pen_active && nd->finger_active) {
+					input_report_key(input,
+							nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
+							, 0);
+					input_report_key(input,
+							nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
+							, 1);
+				}
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 				input_event(input, EV_ABS, ABS_PRESSURE, value);
@@ -233,6 +257,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	if (ret)
 		kfree (nd);
+
 	return ret;
 }
 
-- 
1.6.3.1


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

* Re: [PATCH] ntrig tool separation and pen usages
  2009-06-17 22:48 [PATCH] ntrig tool separation and pen usages Rafi Rubin
@ 2009-06-17 22:52 ` Rafi Rubin
  2009-06-23 12:01 ` Jiri Kosina
  1 sibling, 0 replies; 5+ messages in thread
From: Rafi Rubin @ 2009-06-17 22:52 UTC (permalink / raw)
  To: linux-input

This patch replaces the two I sent in last night.

Rafi

Rafi Rubin wrote:
> 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.
> 
> Restored three usage codes used by the pen.
> 
> Signed-off-by: Rafi Rubin <rafi@seas.upenn.edu>
> ---
>  drivers/hid/hid-ntrig.c |   31 ++++++++++++++++++++++++++++---
>  1 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
> index 75ed9d2..7765970 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;
>  };
>  
>  /*
> @@ -63,10 +66,7 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>  	case HID_UP_DIGITIZER:
>  		switch (usage->hid) {
>  		/* we do not want to map these for now */
> -		case HID_DG_INVERT: /* value is always 0 */
> -		case HID_DG_ERASER: /* value is always 0 */
>  		case HID_DG_CONTACTID: /* value is useless */
> -		case HID_DG_BARRELSWITCH:  /* doubtful */
>  		case HID_DG_INPUTMODE:
>  		case HID_DG_DEVICEINDEX:
>  		case HID_DG_CONTACTCOUNT:
> @@ -125,6 +125,18 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
>  
>          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;
> @@ -148,6 +160,10 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
>  			 * to emit a normal (X, Y) position
>  			 */
>  			if (! nd->found_contact_id) {
> +				if(nd->pen_active && nd->finger_active) {
> +					input_report_key(input, BTN_TOOL_DOUBLETAP, 0);
> +					input_report_key(input, BTN_TOOL_DOUBLETAP, 1);
> +				}
>  				input_event(input, EV_ABS, ABS_X, nd->x);
>  				input_event(input, EV_ABS, ABS_Y, nd->y);
>  			}
> @@ -159,6 +175,14 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
>  			 * to emit a normal (X, Y) position
>  			 */
>  			if (! nd->found_contact_id) {
> +				if(nd->pen_active && nd->finger_active) {
> +					input_report_key(input,
> +							nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
> +							, 0);
> +					input_report_key(input,
> +							nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
> +							, 1);
> +				}
>  				input_event(input, EV_ABS, ABS_X, nd->x);
>  				input_event(input, EV_ABS, ABS_Y, nd->y);
>  				input_event(input, EV_ABS, ABS_PRESSURE, value);
> @@ -233,6 +257,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  
>  	if (ret)
>  		kfree (nd);
> +
>  	return ret;
>  }
>  

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

* Re: [PATCH] ntrig tool separation and pen usages
  2009-06-17 22:48 [PATCH] ntrig tool separation and pen usages Rafi Rubin
  2009-06-17 22:52 ` Rafi Rubin
@ 2009-06-23 12:01 ` Jiri Kosina
  2009-06-23 15:29   ` Stéphane Chatty
  1 sibling, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2009-06-23 12:01 UTC (permalink / raw)
  To: Rafi Rubin; +Cc: linux-input, chatty

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2940 bytes --]

On Wed, 17 Jun 2009, Rafi Rubin wrote:

> 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.
> 
> Restored three usage codes used by the pen.
> 
> Signed-off-by: Rafi Rubin <rafi@seas.upenn.edu>
> ---
>  drivers/hid/hid-ntrig.c |   31 ++++++++++++++++++++++++++++---
>  1 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
> index 75ed9d2..7765970 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;
>  };
>  
>  /*
> @@ -63,10 +66,7 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>  	case HID_UP_DIGITIZER:
>  		switch (usage->hid) {
>  		/* we do not want to map these for now */
> -		case HID_DG_INVERT: /* value is always 0 */
> -		case HID_DG_ERASER: /* value is always 0 */
>  		case HID_DG_CONTACTID: /* value is useless */
> -		case HID_DG_BARRELSWITCH:  /* doubtful */
>  		case HID_DG_INPUTMODE:
>  		case HID_DG_DEVICEINDEX:
>  		case HID_DG_CONTACTCOUNT:
> @@ -125,6 +125,18 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
>  
>          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;

Maybe putting brackets around the comparsion and putting spaces around 
'!=' would make the code more readable and easy to understand on a first 
sight?

> +			return 0;
> +
> +		case HID_DG_INVERT:
> +			nd->inverted = value;
> +			return 0;
> +
>  		case HID_GD_X:
>  			nd->x = value;
>  			nd->reading_a_point = 1;
> @@ -148,6 +160,10 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
>  			 * to emit a normal (X, Y) position
>  			 */
>  			if (! nd->found_contact_id) {

While at it, could you please remove the space after '!' to be compatible 
with the kernel coding style?

> +				if(nd->pen_active && nd->finger_active) {

And insert a space after 'if' here.

> +					input_report_key(input, BTN_TOOL_DOUBLETAP, 0);
> +					input_report_key(input, BTN_TOOL_DOUBLETAP, 1);
> +				}
>  				input_event(input, EV_ABS, ABS_X, nd->x);
>  				input_event(input, EV_ABS, ABS_Y, nd->y);
>  			}
> @@ -159,6 +175,14 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
>  			 * to emit a normal (X, Y) position
>  			 */
>  			if (! nd->found_contact_id) {
> +				if(nd->pen_active && nd->finger_active) {

And the same here.



Stéphane, did you have chance to verify with your device, that everything 
works as expected with this version of Rafi's patch?

Thanks,

-- 
Jiri Kosina
SUSE Labs

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

* Re: [PATCH] ntrig tool separation and pen usages
  2009-06-23 12:01 ` Jiri Kosina
@ 2009-06-23 15:29   ` Stéphane Chatty
  0 siblings, 0 replies; 5+ messages in thread
From: Stéphane Chatty @ 2009-06-23 15:29 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Rafi Rubin, linux-input


Le 23 juin 09 à 14:01, Jiri Kosina a écrit :
>
>
> Stéphane, did you have chance to verify with your device, that  
> everything
> works as expected with this version of Rafi's patch?

Oops, I had missed this new version of Rafi's patch. Yes, it looks good.

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] 5+ messages in thread

* [PATCH] ntrig tool separation and pen usages
@ 2009-06-23 18:09 Rafi Rubin
  0 siblings, 0 replies; 5+ messages in thread
From: Rafi Rubin @ 2009-06-23 18:09 UTC (permalink / raw)
  To: linux-input; +Cc: jkosina, chatty, 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.

Restored three usage codes used by the pen.

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

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 75ed9d2..d7b3e61 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;
 };
 
 /*
@@ -63,10 +66,7 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 	case HID_UP_DIGITIZER:
 		switch (usage->hid) {
 		/* we do not want to map these for now */
-		case HID_DG_INVERT: /* value is always 0 */
-		case HID_DG_ERASER: /* value is always 0 */
 		case HID_DG_CONTACTID: /* value is useless */
-		case HID_DG_BARRELSWITCH:  /* doubtful */
 		case HID_DG_INPUTMODE:
 		case HID_DG_DEVICEINDEX:
 		case HID_DG_CONTACTCOUNT:
@@ -125,6 +125,18 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 
         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;
@@ -147,7 +159,11 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 			 * report received in a finger event. We want
 			 * to emit a normal (X, Y) position
 			 */
-			if (! nd->found_contact_id) {
+			if (!nd->found_contact_id) {
+				if (nd->pen_active && nd->finger_active) {
+					input_report_key(input, BTN_TOOL_DOUBLETAP, 0);
+					input_report_key(input, BTN_TOOL_DOUBLETAP, 1);
+				}
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 			}
@@ -159,6 +175,14 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 			 * to emit a normal (X, Y) position
 			 */
 			if (! nd->found_contact_id) {
+				if (nd->pen_active && nd->finger_active) {
+					input_report_key(input,
+							nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
+							, 0);
+					input_report_key(input,
+							nd->inverted ? BTN_TOOL_RUBBER : BTN_TOOL_PEN
+							, 1);
+				}
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 				input_event(input, EV_ABS, ABS_PRESSURE, value);
@@ -233,6 +257,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	if (ret)
 		kfree (nd);
+
 	return ret;
 }
 
-- 
1.6.3.1


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-17 22:48 [PATCH] ntrig tool separation and pen usages Rafi Rubin
2009-06-17 22:52 ` Rafi Rubin
2009-06-23 12:01 ` Jiri Kosina
2009-06-23 15:29   ` Stéphane Chatty
2009-06-23 18:09 Rafi Rubin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.