Merge lp:~a-lown0/wizardpen/gpen into lp:wizardpen

Proposed by Ali Lown
Status: Merged
Merged at revision: 24
Proposed branch: lp:~a-lown0/wizardpen/gpen
Merge into: lp:wizardpen
Diff against target: 98 lines (+65/-0)
2 files modified
src/wizardpen.c (+59/-0)
src/wizardpen.h (+6/-0)
To merge this branch: bzr merge lp:~a-lown0/wizardpen/gpen
Reviewer Review Type Date Requested Status
Gerard Krol Approve
Review via email: mp+21813@code.launchpad.net

Description of the change

Re-made this branch so that it is a direct branch from wizardpen.
Hopefully this will make the merge a bit easier to see.

To post a comment you must log in.
Revision history for this message
Ali Lown (a-lown0) wrote :

[quote]Would it also work if you only suppress the button event, but still update the pressure status?[/quote]
Would, but there is no point. The reason pressure gets disabled is because the F509 sends pressure events which were making the computer think a left-click whenever one of the side buttons (which are mapped to middle/right-click) were pressed.

[quote]Also, the "//HACK, do avoid having to do conditional sections depending on tablet type" is a bit scary. I'd rather prefer a configuration option like "AlwaysTapToClick" that would only send standard clicks when none of the buttons is pressed, and sends the other buttons when you tap.[/quote]
I don't understand quite what you are saying this option should do. The 'HACK' is clearing of the middle click event because some click patterns (due to the re-use of the BTN_TOUCH event for when the stylus tip is pressed) would prevent the un-set event from being sent.

Also: would it be worth adding 2 options to enable the user to choose the event sent for each button (rather than hard-coding in middle/right-clicks)?

Revision history for this message
Gerard Krol (gerard-) wrote :

I changed the indentation from tabs to spaces and committed it. I think the logic could maybe be simplified a little but we can as well do that from trunk at a later date.

review: Approve
Revision history for this message
Gerard Krol (gerard-) wrote :

Making the buttons configurable would be really nice but as you can already do that using xinput it doesn't have high priority. I also wouldn't know what would be the best way, maybe a nice gui tool on top of xinput is all we need.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/wizardpen.c'
--- src/wizardpen.c 2010-03-21 17:50:57 +0000
+++ src/wizardpen.c 2010-03-21 20:57:25 +0000
@@ -904,6 +904,9 @@
904 break;904 break;
905905
906 case ABS_PRESSURE:906 case ABS_PRESSURE:
907 if(priv->pressuredis)
908 break; /* Disable pressure events because this is actually part of a button event */
909
907 /* send button events if pressure crosses topZ threshold */910 /* send button events if pressure crosses topZ threshold */
908 oldz = z;911 oldz = z;
909 z = event->value;912 z = event->value;
@@ -967,6 +970,62 @@
967 if(priv->debugLevel)970 if(priv->debugLevel)
968 xf86Msg(X_CONFIG, "BTN_RIGHT event is %d\n", event->value);971 xf86Msg(X_CONFIG, "BTN_RIGHT event is %d\n", event->value);
969 break;972 break;
973
974
975 /*Code for handling the buttons on GPEN styluses
976 * Pressure MUST be disabled otherwise left-click events will be sent.
977 F509:
978 Top button: BTN_STYLUS = 1, BTN_STYLUS = 0
979 Bottom button: BTN_TOUCH =1, BTN_STYLUS = 1, BTN_TOUCH = 0, BTN_STYLUS = 0
980
981 560:
982 1st side button: BTN_STYLUS =1, BTN_STYLUS = 0
983 2nd side button: BTN_STYLUS2 = 1, BTN_STYLUS2 = 0
984 */
985 case BTN_TOUCH:
986 if(priv->debugLevel)
987 xf86Msg(X_CONFIG, "BTN_TOUCH event is %d\n", event->value);
988 priv->activebuttons ^= WIZARDPEN_BTN_TOUCH; //Toggle event
989 if(!event->value)
990 {
991 buttons = set_bit(buttons, 2, 0); /* try to clear events to prevent some becoming 'locked' in the active state */
992 buttons = set_bit(buttons, 1, 0);
993 }
994 break;
995 case BTN_STYLUS:
996 if(priv->debugLevel)
997 xf86Msg(X_CONFIG, "BTN_STYLUS event is %d\n", event->value);
998 priv->activebuttons ^= WIZARDPEN_BTN_STYLUS;
999
1000 buttons = set_bit(buttons, 1, 0); //HACK, to avoid having to do conditional sections depending on tablet type
1001
1002 if(priv->activebuttons & WIZARDPEN_BTN_TOUCH)
1003 buttons = set_bit(buttons, 2, event->value);
1004 else
1005 {
1006 buttons = set_bit(buttons, 1, event->value);
1007 if(!event->value)
1008 buttons = set_bit(buttons, 2, 0); /* Clear right click event as well, due to clearing order */
1009 }
1010
1011 priv->pressuredis = event->value;
1012
1013 break;
1014 case BTN_STYLUS2:
1015 if(priv->debugLevel)
1016 xf86Msg(X_CONFIG, "BTN_STYLUS2 event is %d\n", event->value);
1017 priv->activebuttons ^= WIZARDPEN_BTN_STYLUS2;
1018
1019 buttons = set_bit(buttons, 2, event->value);
1020 priv->pressuredis = event->value;
1021
1022 break;
1023
1024 default:
1025 if(priv->debugLevel)
1026 xf86Msg(X_CONFIG, "BTN_DEFAULT event is %d\n", event->value);
1027 break;
1028
970 }1029 }
971 break; // EV_KEY1030 break; // EV_KEY
972 case EV_MSC:1031 case EV_MSC:
9731032
=== modified file 'src/wizardpen.h'
--- src/wizardpen.h 2010-03-21 14:02:17 +0000
+++ src/wizardpen.h 2010-03-21 20:57:25 +0000
@@ -49,6 +49,10 @@
4949
50#define WIZARDPEN_PROMPT "P" /* Prompt for current position */50#define WIZARDPEN_PROMPT "P" /* Prompt for current position */
5151
52#define WIZARDPEN_BTN_TOUCH 1 /* Used for stylus button events */
53#define WIZARDPEN_BTN_STYLUS 2
54#define WIZARDPEN_BTN_STYLUS2 4
55
52#define PHASING_BIT 0x8056#define PHASING_BIT 0x80
53#define PROXIMITY_BIT 0x4057#define PROXIMITY_BIT 0x40
54#define TABID_BIT 0x2058#define TABID_BIT 0x20
@@ -99,6 +103,8 @@
99 int rotate90;103 int rotate90;
100 int mouseSpeed;104 int mouseSpeed;
101 int mouseAccel;105 int mouseAccel;
106 int pressuredis;
107 int activebuttons;
102} WizardPenPrivateRec, *WizardPenPrivatePtr;108} WizardPenPrivateRec, *WizardPenPrivatePtr;
103109
104110

Subscribers

People subscribed via source and target branches