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
1=== modified file 'src/wizardpen.c'
2--- src/wizardpen.c 2010-03-21 17:50:57 +0000
3+++ src/wizardpen.c 2010-03-21 20:57:25 +0000
4@@ -904,6 +904,9 @@
5 break;
6
7 case ABS_PRESSURE:
8+ if(priv->pressuredis)
9+ break; /* Disable pressure events because this is actually part of a button event */
10+
11 /* send button events if pressure crosses topZ threshold */
12 oldz = z;
13 z = event->value;
14@@ -967,6 +970,62 @@
15 if(priv->debugLevel)
16 xf86Msg(X_CONFIG, "BTN_RIGHT event is %d\n", event->value);
17 break;
18+
19+
20+ /*Code for handling the buttons on GPEN styluses
21+ * Pressure MUST be disabled otherwise left-click events will be sent.
22+ F509:
23+ Top button: BTN_STYLUS = 1, BTN_STYLUS = 0
24+ Bottom button: BTN_TOUCH =1, BTN_STYLUS = 1, BTN_TOUCH = 0, BTN_STYLUS = 0
25+
26+ 560:
27+ 1st side button: BTN_STYLUS =1, BTN_STYLUS = 0
28+ 2nd side button: BTN_STYLUS2 = 1, BTN_STYLUS2 = 0
29+ */
30+ case BTN_TOUCH:
31+ if(priv->debugLevel)
32+ xf86Msg(X_CONFIG, "BTN_TOUCH event is %d\n", event->value);
33+ priv->activebuttons ^= WIZARDPEN_BTN_TOUCH; //Toggle event
34+ if(!event->value)
35+ {
36+ buttons = set_bit(buttons, 2, 0); /* try to clear events to prevent some becoming 'locked' in the active state */
37+ buttons = set_bit(buttons, 1, 0);
38+ }
39+ break;
40+ case BTN_STYLUS:
41+ if(priv->debugLevel)
42+ xf86Msg(X_CONFIG, "BTN_STYLUS event is %d\n", event->value);
43+ priv->activebuttons ^= WIZARDPEN_BTN_STYLUS;
44+
45+ buttons = set_bit(buttons, 1, 0); //HACK, to avoid having to do conditional sections depending on tablet type
46+
47+ if(priv->activebuttons & WIZARDPEN_BTN_TOUCH)
48+ buttons = set_bit(buttons, 2, event->value);
49+ else
50+ {
51+ buttons = set_bit(buttons, 1, event->value);
52+ if(!event->value)
53+ buttons = set_bit(buttons, 2, 0); /* Clear right click event as well, due to clearing order */
54+ }
55+
56+ priv->pressuredis = event->value;
57+
58+ break;
59+ case BTN_STYLUS2:
60+ if(priv->debugLevel)
61+ xf86Msg(X_CONFIG, "BTN_STYLUS2 event is %d\n", event->value);
62+ priv->activebuttons ^= WIZARDPEN_BTN_STYLUS2;
63+
64+ buttons = set_bit(buttons, 2, event->value);
65+ priv->pressuredis = event->value;
66+
67+ break;
68+
69+ default:
70+ if(priv->debugLevel)
71+ xf86Msg(X_CONFIG, "BTN_DEFAULT event is %d\n", event->value);
72+ break;
73+
74 }
75 break; // EV_KEY
76 case EV_MSC:
77
78=== modified file 'src/wizardpen.h'
79--- src/wizardpen.h 2010-03-21 14:02:17 +0000
80+++ src/wizardpen.h 2010-03-21 20:57:25 +0000
81@@ -49,6 +49,10 @@
82
83 #define WIZARDPEN_PROMPT "P" /* Prompt for current position */
84
85+#define WIZARDPEN_BTN_TOUCH 1 /* Used for stylus button events */
86+#define WIZARDPEN_BTN_STYLUS 2
87+#define WIZARDPEN_BTN_STYLUS2 4
88+
89 #define PHASING_BIT 0x80
90 #define PROXIMITY_BIT 0x40
91 #define TABID_BIT 0x20
92@@ -99,6 +103,8 @@
93 int rotate90;
94 int mouseSpeed;
95 int mouseAccel;
96+ int pressuredis;
97+ int activebuttons;
98 } WizardPenPrivateRec, *WizardPenPrivatePtr;
99
100

Subscribers

People subscribed via source and target branches