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: 220 lines (+126/-3)
4 files modified
configure.ac (+1/-1)
include/grail-touch.h (+1/-0)
src/touch-caps.c (+37/-0)
src/touch-dev.c (+87/-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 Resubmitting
Review via email: mp+34788@code.launchpad.net

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

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 :

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 :

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.

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-08 09:41:45 +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-08 09:41:45 +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-08 09:41:45 +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-08 09:41:45 +0000
84@@ -34,6 +34,8 @@
85 static void finish_touch(struct touch_dev *dev, struct touch_frame *frame)
86 {
87 struct touch *t = &frame->touch[dev->slot];
88+ if (t->touch_major && !t->touch_minor)
89+ SET_PROP(touch_minor, t->touch_major);
90 if (dev->state > 0) {
91 t->active = 1;
92 grail_mask_set(frame->touches, dev->slot);
93@@ -47,13 +49,45 @@
94 dev->state = 0;
95 }
96
97+static void finish_legacy(struct touch_dev *dev, struct touch_frame *frame)
98+{
99+ static int trkid;
100+ int i;
101+ for (i = 0; i < frame->nactive; i++) {
102+ struct touch *t = &frame->touch[i];
103+ t->active = 1;
104+ if (t->id < 0) {
105+ t->id = trkid++ & 0xffff;
106+ frame->ncreate++;
107+ }
108+ if (i > 0) {
109+ SET_PROP(x, frame->touch[0].x);
110+ SET_PROP(y, frame->touch[0].y);
111+ SET_PROP(pressure, frame->touch[0].pressure);
112+ }
113+ grail_mask_set(frame->touches, i);
114+ }
115+ for (i = frame->nactive; i < DIM_TOUCH; i++) {
116+ struct touch *t = &frame->touch[i];
117+ t->active = 0;
118+ if (t->id >= 0) {
119+ t->id = -1;
120+ frame->ndestroy++;
121+ }
122+ grail_mask_clear(frame->touches, i);
123+ }
124+}
125+
126 static void finish_packet(struct touch_dev *dev,
127 const struct input_event *syn)
128 {
129 static const touch_time_t ms = 1000;
130 struct touch_frame *frame = &dev->frame;
131 int i, nslot = 0;
132- finish_touch(dev, frame);
133+ if (dev->mtdev.caps.has_mtdata)
134+ finish_touch(dev, frame);
135+ else
136+ finish_legacy(dev, frame);
137 grail_mask_foreach(i, frame->touches, DIM_TOUCH_BYTES)
138 frame->active[nslot++] = &frame->touch[i];
139 frame->nactive = nslot;
140@@ -71,6 +105,21 @@
141 struct touch_frame *frame = &dev->frame;
142 struct touch *t = &frame->touch[dev->slot];
143 switch (ev->code) {
144+ case ABS_X:
145+ if (dev->mtdev.caps.has_mtdata)
146+ return 0;
147+ SET_PROP(x, ev->value);
148+ return 1;
149+ case ABS_Y:
150+ if (dev->mtdev.caps.has_mtdata)
151+ return 0;
152+ SET_PROP(y, ev->value);
153+ return 1;
154+ case ABS_PRESSURE:
155+ if (dev->mtdev.caps.has_mtdata)
156+ return 0;
157+ SET_PROP(pressure, ev->value);
158+ return 1;
159 case ABS_MT_SLOT:
160 if (ev->value >= 0 && ev->value < DIM_TOUCH) {
161 if (dev->slot != ev->value)
162@@ -122,6 +171,40 @@
163 }
164 }
165
166+static int handle_key_event(struct touch_dev *dev,
167+ const struct input_event *ev)
168+{
169+ struct touch_frame *frame = &dev->frame;
170+ if (dev->mtdev.caps.has_mtdata)
171+ return 0;
172+ switch (ev->code) {
173+ case BTN_TOUCH:
174+ if (ev->value && !frame->nactive)
175+ frame->nactive = 1;
176+ else if (!ev->value && frame->nactive)
177+ frame->nactive = 0;
178+ return 1;
179+ case BTN_TOOL_FINGER:
180+ if (ev->value)
181+ frame->nactive = 1;
182+ return 1;
183+ case BTN_TOOL_DOUBLETAP:
184+ if (ev->value)
185+ frame->nactive = 2;
186+ return 1;
187+ case BTN_TOOL_TRIPLETAP:
188+ if (ev->value)
189+ frame->nactive = 3;
190+ return 1;
191+ case BTN_TOOL_QUADTAP:
192+ if (ev->value)
193+ frame->nactive = 4;
194+ return 1;
195+ default:
196+ return 0;
197+ }
198+}
199+
200 int touch_dev_open(struct touch_dev *dev, int fd)
201 {
202 struct touch_frame *frame = &dev->frame;
203@@ -133,7 +216,7 @@
204 t->id = MT_ID_NULL;
205 }
206 ret = mtdev_open(&dev->mtdev, fd);
207- if (!ret && !dev->mtdev.caps.has_mtdata)
208+ if (!ret && !touch_caps_is_supported(dev, fd))
209 ret = -ENODEV;
210 if (ret)
211 goto error;
212@@ -160,6 +243,8 @@
213 consumed++;
214 } else if (ev.type == EV_ABS) {
215 consumed += handle_abs_event(dev, &ev);
216+ } else if (ev.type == EV_KEY) {
217+ consumed += handle_key_event(dev, &ev);
218 }
219 if (!consumed && dev->event)
220 dev->event(dev, &ev);

Subscribers

People subscribed via source and target branches

to all changes: