aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet
diff options
context:
space:
mode:
authorRene van Paassen <rene.vanpaassen@gmail.com>2007-05-21 00:32:17 -0400
committerDmitry Torokhov <dtor@insightbb.com>2007-07-10 00:35:17 -0400
commit1e7b3faed1793e7637a774240ae22541c5ba6ca0 (patch)
tree65844e9d6afe11c548a98c4cd4032bc7fe45efee /drivers/input/tablet
parent0112db36ef95e5632db071297f7df130725c47b9 (diff)
Input: aiptek - rework the function key code
Function keys (also called macro keys) code corrected. Using a lastMacro variable to keep track of key currently pressed. This ensures proper resetting when dragging the pen in the drawing area or to another key. Also suppress sending pressure reports when over the macro key area. Signed-off-by: Rene van Paassen <rene.vanpaassen@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/tablet')
-rw-r--r--drivers/input/tablet/aiptek.c97
1 files changed, 46 insertions, 51 deletions
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 54c8d6f49833..292eb507e5d3 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -509,6 +509,11 @@ static void aiptek_irq(struct urb *urb)
509 aiptek->curSetting.wheel); 509 aiptek->curSetting.wheel);
510 aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE; 510 aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE;
511 } 511 }
512 if (aiptek->lastMacro != -1) {
513 input_report_key(inputdev,
514 macroKeyEvents[aiptek->lastMacro], 0);
515 aiptek->lastMacro = -1;
516 }
512 input_sync(inputdev); 517 input_sync(inputdev);
513 } 518 }
514 } 519 }
@@ -589,6 +594,11 @@ static void aiptek_irq(struct urb *urb)
589 } 594 }
590 } 595 }
591 input_report_abs(inputdev, ABS_MISC, p | AIPTEK_REPORT_TOOL_STYLUS); 596 input_report_abs(inputdev, ABS_MISC, p | AIPTEK_REPORT_TOOL_STYLUS);
597 if (aiptek->lastMacro != -1) {
598 input_report_key(inputdev,
599 macroKeyEvents[aiptek->lastMacro], 0);
600 aiptek->lastMacro = -1;
601 }
592 input_sync(inputdev); 602 input_sync(inputdev);
593 } 603 }
594 } 604 }
@@ -647,6 +657,11 @@ static void aiptek_irq(struct urb *urb)
647 } 657 }
648 } 658 }
649 input_report_abs(inputdev, ABS_MISC, p | AIPTEK_REPORT_TOOL_MOUSE); 659 input_report_abs(inputdev, ABS_MISC, p | AIPTEK_REPORT_TOOL_MOUSE);
660 if (aiptek->lastMacro != -1) {
661 input_report_key(inputdev,
662 macroKeyEvents[aiptek->lastMacro], 0);
663 aiptek->lastMacro = -1;
664 }
650 input_sync(inputdev); 665 input_sync(inputdev);
651 } 666 }
652 } 667 }
@@ -662,10 +677,10 @@ static void aiptek_irq(struct urb *urb)
662 bs = (data[1] & aiptek->curSetting.stylusButtonLower) != 0 ? 1 : 0; 677 bs = (data[1] & aiptek->curSetting.stylusButtonLower) != 0 ? 1 : 0;
663 pck = (data[1] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0; 678 pck = (data[1] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0;
664 679
665 macro = data[3]; 680 macro = dv && p && tip && !(data[3] & 1) ? (data[3] >> 1) : -1;
666 z = le16_to_cpu(get_unaligned((__le16 *) (data + 4))); 681 z = le16_to_cpu(get_unaligned((__le16 *) (data + 4)));
667 682
668 if (dv != 0) { 683 if (dv) {
669 /* If the selected tool changed, reset the old 684 /* If the selected tool changed, reset the old
670 * tool key, and set the new one. 685 * tool key, and set the new one.
671 */ 686 */
@@ -679,30 +694,20 @@ static void aiptek_irq(struct urb *urb)
679 aiptek->previousToolMode = 694 aiptek->previousToolMode =
680 aiptek->curSetting.toolMode; 695 aiptek->curSetting.toolMode;
681 } 696 }
697 }
682 698
683 if (p != 0) { 699 if (aiptek->lastMacro != -1 && aiptek->lastMacro != macro) {
684 input_report_key(inputdev, BTN_TOUCH, tip); 700 input_report_key(inputdev, macroKeyEvents[aiptek->lastMacro], 0);
685 input_report_key(inputdev, BTN_STYLUS, bs); 701 aiptek->lastMacro = -1;
686 input_report_key(inputdev, BTN_STYLUS2, pck); 702 }
687 input_report_abs(inputdev, ABS_PRESSURE, z);
688 }
689 703
690 /* For safety, we're sending key 'break' codes for the 704 if (macro != -1 && macro != aiptek->lastMacro) {
691 * neighboring macro keys. 705 input_report_key(inputdev, macroKeyEvents[macro], 1);
692 */ 706 aiptek->lastMacro = macro;
693 if (macro > 0) {
694 input_report_key(inputdev,
695 macroKeyEvents[macro - 1], 0);
696 }
697 if (macro < 25) {
698 input_report_key(inputdev,
699 macroKeyEvents[macro + 1], 0);
700 }
701 input_report_key(inputdev, macroKeyEvents[macro], p);
702 input_report_abs(inputdev, ABS_MISC,
703 p | AIPTEK_REPORT_TOOL_STYLUS);
704 input_sync(inputdev);
705 } 707 }
708 input_report_abs(inputdev, ABS_MISC,
709 p | AIPTEK_REPORT_TOOL_STYLUS);
710 input_sync(inputdev);
706 } 711 }
707 /* Report 5s come from the macro keys when pressed by mouse 712 /* Report 5s come from the macro keys when pressed by mouse
708 */ 713 */
@@ -714,46 +719,35 @@ static void aiptek_irq(struct urb *urb)
714 left = (data[1]& aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0; 719 left = (data[1]& aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
715 right = (data[1] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0; 720 right = (data[1] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
716 middle = (data[1] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0; 721 middle = (data[1] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
717 macro = data[3]; 722 macro = dv && p && left && !(data[3] & 1) ? (data[3] >> 1) : 0;
718 723
719 if (dv != 0) { 724 if (dv) {
720 /* If the selected tool changed, reset the old 725 /* If the selected tool changed, reset the old
721 * tool key, and set the new one. 726 * tool key, and set the new one.
722 */ 727 */
723 if (aiptek->previousToolMode != 728 if (aiptek->previousToolMode !=
724 aiptek->curSetting.toolMode) { 729 aiptek->curSetting.toolMode) {
725 input_report_key(inputdev, 730 input_report_key(inputdev,
726 aiptek->previousToolMode, 0); 731 aiptek->previousToolMode, 0);
727 input_report_key(inputdev, 732 input_report_key(inputdev,
728 aiptek->curSetting.toolMode, 733 aiptek->curSetting.toolMode, 1);
729 1); 734 aiptek->previousToolMode = aiptek->curSetting.toolMode;
730 aiptek->previousToolMode =
731 aiptek->curSetting.toolMode;
732 }
733
734 if (p != 0) {
735 input_report_key(inputdev, BTN_LEFT, left);
736 input_report_key(inputdev, BTN_MIDDLE, middle);
737 input_report_key(inputdev, BTN_RIGHT, right);
738 } 735 }
736 }
739 737
740 /* For safety, we're sending key 'break' codes for the 738 if (aiptek->lastMacro != -1 && aiptek->lastMacro != macro) {
741 * neighboring macro keys. 739 input_report_key(inputdev, macroKeyEvents[aiptek->lastMacro], 0);
742 */ 740 aiptek->lastMacro = -1;
743 if (macro > 0) { 741 }
744 input_report_key(inputdev,
745 macroKeyEvents[macro - 1], 0);
746 }
747 if (macro < 25) {
748 input_report_key(inputdev,
749 macroKeyEvents[macro + 1], 0);
750 }
751 742
743 if (macro != -1 && macro != aiptek->lastMacro) {
752 input_report_key(inputdev, macroKeyEvents[macro], 1); 744 input_report_key(inputdev, macroKeyEvents[macro], 1);
753 input_report_rel(inputdev, ABS_MISC, 745 aiptek->lastMacro = macro;
754 p | AIPTEK_REPORT_TOOL_MOUSE);
755 input_sync(inputdev);
756 } 746 }
747
748 input_report_abs(inputdev, ABS_MISC,
749 p | AIPTEK_REPORT_TOOL_MOUSE);
750 input_sync(inputdev);
757 } 751 }
758 /* We have no idea which tool can generate a report 6. Theoretically, 752 /* We have no idea which tool can generate a report 6. Theoretically,
759 * neither need to, having been given reports 4 & 5 for such use. 753 * neither need to, having been given reports 4 & 5 for such use.
@@ -1710,6 +1704,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1710 aiptek->inDelay = 0; 1704 aiptek->inDelay = 0;
1711 aiptek->endDelay = 0; 1705 aiptek->endDelay = 0;
1712 aiptek->previousJitterable = 0; 1706 aiptek->previousJitterable = 0;
1707 aiptek->lastMacro = -1;
1713 1708
1714 /* Set up the curSettings struct. Said struct contains the current 1709 /* Set up the curSettings struct. Said struct contains the current
1715 * programmable parameters. The newSetting struct contains changes 1710 * programmable parameters. The newSetting struct contains changes