Merge lp:~oif-team/evemu/fix-evbit-handling into lp:evemu

Proposed by Chase Douglas
Status: Rejected
Rejected by: Chase Douglas
Proposed branch: lp:~oif-team/evemu/fix-evbit-handling
Merge into: lp:evemu
Diff against target: 154 lines (+62/-6)
2 files modified
src/evemu-impl.h (+3/-0)
src/evemu.c (+59/-6)
To merge this branch: bzr merge lp:~oif-team/evemu/fix-evbit-handling
Reviewer Review Type Date Requested Status
Henrik Rydberg (community) Disapprove
Review via email: mp+51624@code.launchpad.net

Description of the change

Fix evbit handling in device property files.

To post a comment you must log in.
Revision history for this message
Henrik Rydberg (rydberg) wrote :

Rendering existing bug reports and accumulated data invalid because someone wants a "E:" instead of a "A:" in a report costs much more than it gains. I am disapproving this change.

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

Oh, I forgot - "E:" is also used in other related contexts (events files), creating a different kind of confusion.

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

Certainly it can be renamed. However, I fail to see how this invalidates existing bug reports and accumulated data.

This is a real bug that I spent a good 30 minutes trying to figure out, and I only figured it out because I had done extensive work with uinput in the past. This isn't just a cosmetic issue.

We can quite easily rename this to something other than "E:". How about "T:" for types?

28. By Chase Douglas

Rename evbit line from "E:" to "T:" (name clash with event records)

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

How about adding the line "The first B: line lists the used event types" to the documentation and be done with it. It solves the real problem, without changing file formats.

And the less time we spend on this non-issue, the less time get wasted.

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

The documentation isn't enough. A developer should be able to look at a device prop file and figure this out themselves. If we couldn't do this in a backwards compatible way, then documenting the issue might be a reasonable approach. However, the proposed merge keeps all backwards compatibility and fixes things going forward. No more time needs to be spent on the issue if the merge is approved, and I'm unaware of any technical reason not to.

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

Documentation should be enough. Right now, there are at least two ways to interpret the letter "B:" one is that it means something with bitmask, and the numbers correspond to something. There is nothing documented saying all B:s have to means the same thing, and indeed, they don't. Thus, a change of letters only switches confusion to some other place.

The main reason to not change this is not technical, but a matter of stability. The file format is already in use. This alone makes a request like this branch raise all red flags. When combined with the fact that indeed, the whole issue is just a matter of interpretation, it makes it even more important to say no.

I am disapproving this again, to underline that fact that I really, really, think this is both a silly and harmful change.

review: Disapprove

Unmerged revisions

28. By Chase Douglas

Rename evbit line from "E:" to "T:" (name clash with event records)

27. By Chase Douglas

Output EVBIT bits on a separate line

The current code outputs the EVBIT bits on the EV_SYN mask line (the line
that begins with "B: 00"). This is incorrect as the EVBIT bits have
nothing to do with EV_SYN.

This change creates a new "E:" line that outputs the EVBIT bits. The
"B: 00" will not be printed any longer, since there's no EVDEV protocol
handling for EV_SYN. The change is backwards compatible with the old
format. Creating a device with an older file will still work properly.

Fixes LP: #726773

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/evemu-impl.h'
--- src/evemu-impl.h 2011-02-03 02:29:13 +0000
+++ src/evemu-impl.h 2011-02-28 21:08:14 +0000
@@ -21,6 +21,8 @@
21#include <evemu.h>21#include <evemu.h>
22#include <linux/uinput.h>22#include <linux/uinput.h>
2323
24#define EVBIT_NBITS EV_CNT
25#define EVBIT_NBYTES ((EV_CNT + 7) / 8)
24#define EVPLAY_NBITS KEY_CNT26#define EVPLAY_NBITS KEY_CNT
25#define EVPLAY_NBYTES ((EVPLAY_NBITS + 7) / 8)27#define EVPLAY_NBYTES ((EVPLAY_NBITS + 7) / 8)
2628
@@ -29,6 +31,7 @@
29 char name[UINPUT_MAX_NAME_SIZE];31 char name[UINPUT_MAX_NAME_SIZE];
30 struct input_id id;32 struct input_id id;
31 unsigned char prop[EVPLAY_NBYTES];33 unsigned char prop[EVPLAY_NBYTES];
34 unsigned char evmask[EVBIT_NBYTES];
32 unsigned char mask[EV_CNT][EVPLAY_NBYTES];35 unsigned char mask[EV_CNT][EVPLAY_NBYTES];
33 int pbytes, mbytes[EV_CNT];36 int pbytes, mbytes[EV_CNT];
34 struct input_absinfo abs[ABS_CNT];37 struct input_absinfo abs[ABS_CNT];
3538
=== modified file 'src/evemu.c'
--- src/evemu.c 2011-02-03 02:29:13 +0000
+++ src/evemu.c 2011-02-28 21:08:14 +0000
@@ -164,9 +164,15 @@
164 return (dev->prop[code >> 3] >> (code & 7)) & 1;164 return (dev->prop[code >> 3] >> (code & 7)) & 1;
165}165}
166166
167static int evemu_has_type(const struct evemu_device *dev, int type)
168{
169 return (dev->evmask[type >> 3] >> (type & 7)) & 1;
170}
171
167int evemu_has_event(const struct evemu_device *dev, int type, int code)172int evemu_has_event(const struct evemu_device *dev, int type, int code)
168{173{
169 return (dev->mask[type][code >> 3] >> (code & 7)) & 1;174 return (evemu_has_type(dev, type) &&
175 (dev->mask[type][code >> 3] >> (code & 7)) & 1);
170}176}
171177
172int evemu_extract(struct evemu_device *dev, int fd)178int evemu_extract(struct evemu_device *dev, int fd)
@@ -193,7 +199,12 @@
193 dev->pbytes = rc;199 dev->pbytes = rc;
194 }200 }
195201
196 for (i = 0; i < EV_CNT; i++) {202 SYSCALL(rc = ioctl(fd, EVIOCGBIT(0, EVBIT_NBYTES), bits));
203 if (rc < 0)
204 return rc;
205 copy_bits(dev->evmask, bits, rc);
206
207 for (i = EV_KEY; i < EV_CNT; i++) {
197 SYSCALL(rc = ioctl(fd, EVIOCGBIT(i, sizeof(bits)), bits));208 SYSCALL(rc = ioctl(fd, EVIOCGBIT(i, sizeof(bits)), bits));
198 if (rc < 0)209 if (rc < 0)
199 continue;210 continue;
@@ -221,6 +232,15 @@
221 mask[i + 4], mask[i + 5], mask[i + 6], mask[i + 7]);232 mask[i + 4], mask[i + 5], mask[i + 6], mask[i + 7]);
222}233}
223234
235static void write_evmask(FILE * fp, const unsigned char *evmask)
236{
237 int i;
238 fprintf(fp, "T:");
239 for (i = 0; i < EVBIT_NBYTES; i++)
240 fprintf(fp, " %02x", evmask[i]);
241 fprintf(fp, "\n");
242}
243
224static void write_mask(FILE * fp, int index,244static void write_mask(FILE * fp, int index,
225 const unsigned char *mask, int bytes)245 const unsigned char *mask, int bytes)
226{246{
@@ -249,7 +269,9 @@
249269
250 write_prop(fp, dev->prop, dev->pbytes);270 write_prop(fp, dev->prop, dev->pbytes);
251271
252 for (i = 0; i < EV_CNT; i++)272 write_evmask(fp, dev->evmask);
273
274 for (i = EV_KEY; i < EV_CNT; i++)
253 write_mask(fp, i, dev->mask[i], dev->mbytes[i]);275 write_mask(fp, i, dev->mask[i], dev->mbytes[i]);
254276
255 for (i = 0; i < ABS_CNT; i++)277 for (i = 0; i < ABS_CNT; i++)
@@ -271,6 +293,21 @@
271 }293 }
272}294}
273295
296static void read_evmask(struct evemu_device *dev, FILE *fp)
297{
298 unsigned int mask[8];
299 int i;
300 if (fscanf(fp, "B: 00 %02x %02x %02x %02x %02x %02x %02x %02x\n",
301 mask + 0, mask + 1, mask + 2, mask + 3, mask + 4, mask + 5,
302 mask + 6, mask + 7) > 0)
303 for (i = 0; i < EVBIT_NBYTES; i++)
304 dev->evmask[i] = mask[i];
305 else if (fscanf(fp, "T: %02x %02x %02x %02x\n", mask + 0, mask + 1,
306 mask + 2, mask + 3) > 0)
307 for (i = 0; i < EVBIT_NBYTES; i++)
308 dev->evmask[i] = mask[i];
309}
310
274static void read_mask(struct evemu_device *dev, FILE *fp)311static void read_mask(struct evemu_device *dev, FILE *fp)
275{312{
276 unsigned int mask[8];313 unsigned int mask[8];
@@ -315,6 +352,8 @@
315352
316 read_prop(dev, fp);353 read_prop(dev, fp);
317354
355 read_evmask(dev, fp);
356
318 read_mask(dev, fp);357 read_mask(dev, fp);
319358
320 read_abs(dev, fp);359 read_abs(dev, fp);
@@ -395,9 +434,6 @@
395 int ret = 0;434 int ret = 0;
396435
397 switch(type) {436 switch(type) {
398 case EV_SYN:
399 SYSCALL(ret = ioctl(fd, UI_SET_EVBIT, code));
400 break;
401 case EV_KEY:437 case EV_KEY:
402 SYSCALL(ret = ioctl(fd, UI_SET_KEYBIT, code));438 SYSCALL(ret = ioctl(fd, UI_SET_KEYBIT, code));
403 break;439 break;
@@ -441,6 +477,19 @@
441 return 0;477 return 0;
442}478}
443479
480static int set_evmask(const struct evemu_device *dev, int fd)
481{
482 int ret, i;
483 for (i = 0; i < EVBIT_NBITS; i++) {
484 if (!evemu_has_type(dev, i))
485 continue;
486 SYSCALL(ret = ioctl(fd, UI_SET_EVBIT, i));
487 if (ret < 0)
488 return ret;
489 }
490 return 0;
491}
492
444static int set_mask(const struct evemu_device *dev, int type, int fd)493static int set_mask(const struct evemu_device *dev, int type, int fd)
445{494{
446 int bits = 8 * dev->mbytes[type];495 int bits = 8 * dev->mbytes[type];
@@ -476,6 +525,10 @@
476 if (ret < 0)525 if (ret < 0)
477 return ret;526 return ret;
478527
528 ret = set_evmask(dev, fd);
529 if (ret < 0)
530 return ret;
531
479 for (i = 0; i < EV_CNT; i++) {532 for (i = 0; i < EV_CNT; i++) {
480 ret = set_mask(dev, i, fd);533 ret = set_mask(dev, i, fd);
481 if (ret < 0)534 if (ret < 0)

Subscribers

People subscribed via source and target branches

to all changes: