diff options
author | Ping Cheng <pingc@wacom.com> | 2010-03-20 01:18:15 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-04-14 02:24:06 -0400 |
commit | 4492efffffeb88d87e7aa74765f3c53b3a7dd40f (patch) | |
tree | 258b17da4faf0934efb8bc63a5163d77e047dbc8 /drivers/input/tablet/wacom_wac.c | |
parent | 3b57ca0f80c5c8994b5b1e3d3f904cfe727951f2 (diff) |
Input: wacom - share pen info with touch of the same ID
Touch enbaled devices share the same product ID with pen. However,
we do not want to post touch events while pen is in prox. To do so,
we used to keep a local static variable to keep track of if pen is
in prox or not. This works fine for Tablet PC devices since there
is only one device attached. With the newer touch enabled regular
tablets, we can not make this assumption any more, i.e, one system
may have more than one identical tablet plugged in.
This patch adds an new entry, shared, into the struct wacom_wac so
touch data can access pen data to locally. This solution assumes
the two tools (touch and pen) of the same ID will be probed one
after the other without interruption in between by another Wacom
device of the same ID.
Diffstat (limited to 'drivers/input/tablet/wacom_wac.c')
-rw-r--r-- | drivers/input/tablet/wacom_wac.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index b3ba3437a2eb..428144af865f 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -688,7 +688,6 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) | |||
688 | struct wacom_features *features = &wacom->features; | 688 | struct wacom_features *features = &wacom->features; |
689 | char *data = wacom->data; | 689 | char *data = wacom->data; |
690 | int prox = 0, pressure, idx = -1; | 690 | int prox = 0, pressure, idx = -1; |
691 | static int stylusInProx, touchInProx = 1, touchOut; | ||
692 | struct urb *urb = ((struct wacom_combo *)wcombo)->urb; | 691 | struct urb *urb = ((struct wacom_combo *)wcombo)->urb; |
693 | 692 | ||
694 | dbg("wacom_tpc_irq: received report #%d", data[0]); | 693 | dbg("wacom_tpc_irq: received report #%d", data[0]); |
@@ -707,16 +706,12 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) | |||
707 | prox = data[1] & 0x03; | 706 | prox = data[1] & 0x03; |
708 | } | 707 | } |
709 | 708 | ||
710 | if (!stylusInProx) { /* stylus not in prox */ | 709 | if (!wacom->shared->stylus_in_proximity) { |
711 | if (prox) { | 710 | if (prox) { |
712 | if (touchInProx) { | 711 | wacom_tpc_touch_in(wacom, wcombo); |
713 | wacom_tpc_touch_in(wacom, wcombo); | ||
714 | touchOut = 1; | ||
715 | return 1; | ||
716 | } | ||
717 | } else { | 712 | } else { |
718 | /* 2FGT out-prox */ | ||
719 | if (data[0] == WACOM_REPORT_TPC2FG) { | 713 | if (data[0] == WACOM_REPORT_TPC2FG) { |
714 | /* 2FGT out-prox */ | ||
720 | idx = (wacom->id[1] & 0x01) - 1; | 715 | idx = (wacom->id[1] & 0x01) - 1; |
721 | if (idx == 0) { | 716 | if (idx == 0) { |
722 | wacom_tpc_touch_out(wacom, wcombo, idx); | 717 | wacom_tpc_touch_out(wacom, wcombo, idx); |
@@ -727,23 +722,19 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) | |||
727 | idx = (wacom->id[1] & 0x02) - 1; | 722 | idx = (wacom->id[1] & 0x02) - 1; |
728 | if (idx == 1) | 723 | if (idx == 1) |
729 | wacom_tpc_touch_out(wacom, wcombo, idx); | 724 | wacom_tpc_touch_out(wacom, wcombo, idx); |
730 | } else /* one finger touch */ | 725 | } else { |
726 | /* one finger touch */ | ||
731 | wacom_tpc_touch_out(wacom, wcombo, 0); | 727 | wacom_tpc_touch_out(wacom, wcombo, 0); |
732 | touchOut = 0; | 728 | } |
733 | touchInProx = 1; | 729 | wacom->id[0] = 0; |
734 | return 1; | ||
735 | } | 730 | } |
736 | } else if (touchOut || !prox) { /* force touch out-prox */ | 731 | } else if (wacom->id[0]) { /* force touch out-prox */ |
737 | wacom_tpc_touch_out(wacom, wcombo, 0); | 732 | wacom_tpc_touch_out(wacom, wcombo, 0); |
738 | touchOut = 0; | ||
739 | touchInProx = 1; | ||
740 | return 1; | ||
741 | } | 733 | } |
734 | return 1; | ||
742 | } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */ | 735 | } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */ |
743 | prox = data[1] & 0x20; | 736 | prox = data[1] & 0x20; |
744 | 737 | ||
745 | touchInProx = 0; | ||
746 | |||
747 | if (!wacom->id[0]) { /* first in prox */ | 738 | if (!wacom->id[0]) { /* first in prox */ |
748 | /* Going into proximity select tool */ | 739 | /* Going into proximity select tool */ |
749 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | 740 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
@@ -751,6 +742,8 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) | |||
751 | wacom->id[0] = STYLUS_DEVICE_ID; | 742 | wacom->id[0] = STYLUS_DEVICE_ID; |
752 | else | 743 | else |
753 | wacom->id[0] = ERASER_DEVICE_ID; | 744 | wacom->id[0] = ERASER_DEVICE_ID; |
745 | |||
746 | wacom->shared->stylus_in_proximity = true; | ||
754 | } | 747 | } |
755 | wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); | 748 | wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); |
756 | wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); | 749 | wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); |
@@ -763,12 +756,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) | |||
763 | wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); | 756 | wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); |
764 | if (!prox) { /* out-prox */ | 757 | if (!prox) { /* out-prox */ |
765 | wacom->id[0] = 0; | 758 | wacom->id[0] = 0; |
766 | /* pen is out so touch can be enabled now */ | 759 | wacom->shared->stylus_in_proximity = false; |
767 | touchInProx = 1; | ||
768 | } | 760 | } |
769 | wacom_report_key(wcombo, wacom->tool[0], prox); | 761 | wacom_report_key(wcombo, wacom->tool[0], prox); |
770 | wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); | 762 | wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); |
771 | stylusInProx = prox; | ||
772 | return 1; | 763 | return 1; |
773 | } | 764 | } |
774 | return 0; | 765 | return 0; |