Merge lp:~oif-team/grail/trunk.v1.0.13 into lp:grail

Proposed by Henrik Rydberg
Status: Superseded
Proposed branch: lp:~oif-team/grail/trunk.v1.0.13
Merge into: lp:grail
Diff against target: 231 lines (+130/-3)
4 files modified
configure.ac (+1/-1)
include/grail-touch.h (+1/-0)
src/touch-caps.c (+37/-0)
src/touch-dev.c (+91/-2)
To merge this branch: bzr merge lp:~oif-team/grail/trunk.v1.0.13
Reviewer Review Type Date Requested Status
Chase Douglas (community) Needs Fixing
Review via email: mp+34843@code.launchpad.net

This proposal supersedes a proposal from 2010-09-07.

This proposal has been superseded by a proposal from 2010-09-09.

Description of the change

The changes needed to support non-MT devices through the utouch stack.

To post a comment you must log in.
Revision history for this message
Chase Douglas (chasedouglas) wrote : Posted in a previous version of this proposal

Commit 79 makes sense, so no issues there.

However, I'm not sure what to do about commit 80. I think it looks good and it probably can introduce some interesting support for synaptics trackpads. However, it's also really late in the cycle to be adding this much new code.

I know it would be a bit of extra work, but can we keep commit 80 in a separate branch for now and not package it up for Maverick? By strict definition it is clearly out of scope at this point in the development cycle, and it likely won't actually add any new features since synaptics will be used for most of these devices anyways. However, I worry that there could be regressions in the single-touch touchscreen use case.

I guess the most appropriate review state for this is resubmit to include only commit 79. If you aren't meaning to push this into maverick, perhaps this could be merged as 1.1.0 and we would keep maverick on the 1.0.x series that would not include commit 80?

review: Needs Resubmitting
Revision history for this message
Henrik Rydberg (rydberg) wrote : Posted in a previous version of this proposal

Well, I was thinking maverick for this, since there has already been bug reports about it. I see your point clearly, but I also see the conflict between the normal maverick procedure and the interests to make gestures work for as broad an audience as possible.

Revision history for this message
Henrik Rydberg (rydberg) wrote :

Code now replaces the "has_mtdata" with "is_supported" logic, and lets some non-MT devices
through. That should take care of the risk of regression for other devices.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

It sounds like we're going to try to push this into maverick. I'm going to do some testing on it to be sure it doesn't kill my cat :).

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Yeah, we try to support animal-friendly products. Thanks for keeping that in mind, Chase.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

Well, it didn't kill my cat, but it did kill my single touch cursor motion.

In lines 148, 153, and 158 in the big diff below, the return value should be 0 instead of 1 (according to Henrik). This fixed my issues.

review: Needs Fixing
lp:~oif-team/grail/trunk.v1.0.13 updated
79. By Henrik Rydberg

Make sure contact area is always defined

Some devices do not always send touch_minor after touch_major
has been set. According to the MT protocol, this case should
be treated as if minor is equal to major. This patch makes sure
touch_minor is never zero when touch_major is set.

80. By Henrik Rydberg

Support legacy devices

Simulate MT touch events for legacy devices that support the
DOUBLETAP, TRIPLETAP and QUADTAP events. This allows multi-finger
tap and drag gestures to be emitted, providing a basic level of
MT functionality for legacy devices.

81. By Henrik Rydberg

Discard tapping even when there are zero events between dow
n and up

The current logic assumes there will be at least one frame with
between touch up and touch down or the tap will not be properly
timed out. Fixed with this patch.

Reported-by: Chase Douglas <email address hidden>

82. By Henrik Rydberg

Cancel tapping also on zoom events

The current code cancels tapping when dragging is active. This
patch adds zooming to the set, to inhibit tapping also when a
perfect zoom without dragging is performed.

Reported-by: Chase Douglas <email address hidden>

83. By Henrik Rydberg

Only emit abs events when motion is active

This bug was hidden behind the motion inhibit during tapping,
but resurfaced when tapping from resting finger was introduced.
With this patch, pointer movement is inhibited also when lifting
fingers from the surface.

Ideally, tapping should be treated as a transient event, which would
allow zero pointer event also _before_ the tap, but presently unity
seems to depend on the initial pointer movement as a touch-down event.

84. By Henrik Rydberg

Inhibit taps immediately after a finger is lifted

The intentional tap starts with a finger in the air. This patch
treats the sequence up-down-up as unintentional, unless performed
with a single finger. Fixes the problem with accidental taps during
multi-finger gestures.

85. By Henrik Rydberg

Allow slow tapping

For the benefit of hardware that cannot accurately meet the desirable
response times, allow for tapping times up to 300 ms.

86. By Henrik Rydberg

grail v1.0.13

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2010-09-01 21:01:08 +0000
3+++ configure.ac 2010-09-09 11:04:43 +0000
4@@ -1,7 +1,7 @@
5 # Initialize Autoconf
6 AC_PREREQ([2.60])
7 AC_INIT([Gesture Recognition And Instantiation Library],
8- [1.0.12],
9+ [1.0.13],
10 [],
11 [utouch-grail])
12 AC_CONFIG_SRCDIR([Makefile.am])
13
14=== modified file 'include/grail-touch.h'
15--- include/grail-touch.h 2010-08-19 20:26:11 +0000
16+++ include/grail-touch.h 2010-09-09 11:04:43 +0000
17@@ -72,6 +72,7 @@
18 int state;
19 };
20
21+int touch_caps_is_supported(struct touch_dev *dev, int fd);
22 void touch_caps_init(struct touch_dev *dev);
23 float touch_angle(const struct touch_dev *dev, int orientation);
24 float touch_pressure(const struct touch_dev *dev, int pressure);
25
26=== modified file 'src/touch-caps.c'
27--- src/touch-caps.c 2010-08-31 12:20:32 +0000
28+++ src/touch-caps.c 2010-09-09 11:04:43 +0000
29@@ -21,6 +21,7 @@
30 ****************************************************************************/
31
32 #include <grail-touch.h>
33+#include <errno.h>
34 #include <math.h>
35
36 /* see mtdev-mapping.h */
37@@ -29,6 +30,42 @@
38 #define MTDEV_ORIENTATION 4
39 #define MTDEV_PRESSURE 10
40
41+#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
42+
43+static const int bits_per_long = 8 * sizeof(long);
44+
45+static inline int nlongs(int nbit)
46+{
47+ return (nbit + bits_per_long - 1) / bits_per_long;
48+}
49+
50+static inline int getbit(const unsigned long *map, int key)
51+{
52+ return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01;
53+}
54+
55+int touch_caps_is_supported(struct touch_dev *dev, int fd)
56+{
57+ unsigned long keybits[nlongs(KEY_MAX)];
58+ unsigned long absbits[nlongs(ABS_MAX)];
59+ int rc;
60+
61+ if (dev->mtdev.caps.has_mtdata)
62+ return 1;
63+
64+ SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits));
65+ if (rc < 0)
66+ return 0;
67+ SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits));
68+ if (rc < 0)
69+ return 0;
70+
71+ return getbit(absbits, ABS_X) &&
72+ getbit(absbits, ABS_Y) &&
73+ getbit(keybits, BTN_TOUCH) &&
74+ getbit(keybits, BTN_TOOL_DOUBLETAP);
75+}
76+
77 void touch_caps_init(struct touch_dev *dev)
78 {
79 const struct mtdev_caps *mt = &dev->mtdev.caps;
80
81=== modified file 'src/touch-dev.c'
82--- src/touch-dev.c 2010-08-19 20:26:11 +0000
83+++ src/touch-dev.c 2010-09-09 11:04:43 +0000
84@@ -25,6 +25,9 @@
85 #include <string.h>
86 #include <errno.h>
87
88+/* see mtdev-mapping.h */
89+#define MTDEV_TOUCH_MINOR 1
90+
91 #define SET_PROP(name, value) \
92 if (t->name != value) { \
93 t->name = value; \
94@@ -34,6 +37,9 @@
95 static void finish_touch(struct touch_dev *dev, struct touch_frame *frame)
96 {
97 struct touch *t = &frame->touch[dev->slot];
98+ if (t->touch_major && !t->touch_minor ||
99+ !dev->mtdev.caps.has_abs[MTDEV_TOUCH_MINOR])
100+ SET_PROP(touch_minor, t->touch_major);
101 if (dev->state > 0) {
102 t->active = 1;
103 grail_mask_set(frame->touches, dev->slot);
104@@ -47,13 +53,45 @@
105 dev->state = 0;
106 }
107
108+static void finish_legacy(struct touch_dev *dev, struct touch_frame *frame)
109+{
110+ static int trkid;
111+ int i;
112+ for (i = 0; i < frame->nactive; i++) {
113+ struct touch *t = &frame->touch[i];
114+ t->active = 1;
115+ if (t->id < 0) {
116+ t->id = trkid++ & 0xffff;
117+ frame->ncreate++;
118+ }
119+ if (i > 0) {
120+ SET_PROP(x, frame->touch[0].x);
121+ SET_PROP(y, frame->touch[0].y);
122+ SET_PROP(pressure, frame->touch[0].pressure);
123+ }
124+ grail_mask_set(frame->touches, i);
125+ }
126+ for (i = frame->nactive; i < DIM_TOUCH; i++) {
127+ struct touch *t = &frame->touch[i];
128+ t->active = 0;
129+ if (t->id >= 0) {
130+ t->id = -1;
131+ frame->ndestroy++;
132+ }
133+ grail_mask_clear(frame->touches, i);
134+ }
135+}
136+
137 static void finish_packet(struct touch_dev *dev,
138 const struct input_event *syn)
139 {
140 static const touch_time_t ms = 1000;
141 struct touch_frame *frame = &dev->frame;
142 int i, nslot = 0;
143- finish_touch(dev, frame);
144+ if (dev->mtdev.caps.has_mtdata)
145+ finish_touch(dev, frame);
146+ else
147+ finish_legacy(dev, frame);
148 grail_mask_foreach(i, frame->touches, DIM_TOUCH_BYTES)
149 frame->active[nslot++] = &frame->touch[i];
150 frame->nactive = nslot;
151@@ -71,6 +109,21 @@
152 struct touch_frame *frame = &dev->frame;
153 struct touch *t = &frame->touch[dev->slot];
154 switch (ev->code) {
155+ case ABS_X:
156+ if (dev->mtdev.caps.has_mtdata)
157+ return 0;
158+ SET_PROP(x, ev->value);
159+ return 0;
160+ case ABS_Y:
161+ if (dev->mtdev.caps.has_mtdata)
162+ return 0;
163+ SET_PROP(y, ev->value);
164+ return 0;
165+ case ABS_PRESSURE:
166+ if (dev->mtdev.caps.has_mtdata)
167+ return 0;
168+ SET_PROP(pressure, ev->value);
169+ return 0;
170 case ABS_MT_SLOT:
171 if (ev->value >= 0 && ev->value < DIM_TOUCH) {
172 if (dev->slot != ev->value)
173@@ -122,6 +175,40 @@
174 }
175 }
176
177+static int handle_key_event(struct touch_dev *dev,
178+ const struct input_event *ev)
179+{
180+ struct touch_frame *frame = &dev->frame;
181+ if (dev->mtdev.caps.has_mtdata)
182+ return 0;
183+ switch (ev->code) {
184+ case BTN_TOUCH:
185+ if (ev->value && !frame->nactive)
186+ frame->nactive = 1;
187+ else if (!ev->value && frame->nactive)
188+ frame->nactive = 0;
189+ return 0;
190+ case BTN_TOOL_FINGER:
191+ if (ev->value)
192+ frame->nactive = 1;
193+ return 0;
194+ case BTN_TOOL_DOUBLETAP:
195+ if (ev->value)
196+ frame->nactive = 2;
197+ return 0;
198+ case BTN_TOOL_TRIPLETAP:
199+ if (ev->value)
200+ frame->nactive = 3;
201+ return 0;
202+ case BTN_TOOL_QUADTAP:
203+ if (ev->value)
204+ frame->nactive = 4;
205+ return 0;
206+ default:
207+ return 0;
208+ }
209+}
210+
211 int touch_dev_open(struct touch_dev *dev, int fd)
212 {
213 struct touch_frame *frame = &dev->frame;
214@@ -133,7 +220,7 @@
215 t->id = MT_ID_NULL;
216 }
217 ret = mtdev_open(&dev->mtdev, fd);
218- if (!ret && !dev->mtdev.caps.has_mtdata)
219+ if (!ret && !touch_caps_is_supported(dev, fd))
220 ret = -ENODEV;
221 if (ret)
222 goto error;
223@@ -160,6 +247,8 @@
224 consumed++;
225 } else if (ev.type == EV_ABS) {
226 consumed += handle_abs_event(dev, &ev);
227+ } else if (ev.type == EV_KEY) {
228+ consumed += handle_key_event(dev, &ev);
229 }
230 if (!consumed && dev->event)
231 dev->event(dev, &ev);

Subscribers

People subscribed via source and target branches

to all changes: