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
1=== modified file 'src/evemu-impl.h'
2--- src/evemu-impl.h 2011-02-03 02:29:13 +0000
3+++ src/evemu-impl.h 2011-02-28 21:08:14 +0000
4@@ -21,6 +21,8 @@
5 #include <evemu.h>
6 #include <linux/uinput.h>
7
8+#define EVBIT_NBITS EV_CNT
9+#define EVBIT_NBYTES ((EV_CNT + 7) / 8)
10 #define EVPLAY_NBITS KEY_CNT
11 #define EVPLAY_NBYTES ((EVPLAY_NBITS + 7) / 8)
12
13@@ -29,6 +31,7 @@
14 char name[UINPUT_MAX_NAME_SIZE];
15 struct input_id id;
16 unsigned char prop[EVPLAY_NBYTES];
17+ unsigned char evmask[EVBIT_NBYTES];
18 unsigned char mask[EV_CNT][EVPLAY_NBYTES];
19 int pbytes, mbytes[EV_CNT];
20 struct input_absinfo abs[ABS_CNT];
21
22=== modified file 'src/evemu.c'
23--- src/evemu.c 2011-02-03 02:29:13 +0000
24+++ src/evemu.c 2011-02-28 21:08:14 +0000
25@@ -164,9 +164,15 @@
26 return (dev->prop[code >> 3] >> (code & 7)) & 1;
27 }
28
29+static int evemu_has_type(const struct evemu_device *dev, int type)
30+{
31+ return (dev->evmask[type >> 3] >> (type & 7)) & 1;
32+}
33+
34 int evemu_has_event(const struct evemu_device *dev, int type, int code)
35 {
36- return (dev->mask[type][code >> 3] >> (code & 7)) & 1;
37+ return (evemu_has_type(dev, type) &&
38+ (dev->mask[type][code >> 3] >> (code & 7)) & 1);
39 }
40
41 int evemu_extract(struct evemu_device *dev, int fd)
42@@ -193,7 +199,12 @@
43 dev->pbytes = rc;
44 }
45
46- for (i = 0; i < EV_CNT; i++) {
47+ SYSCALL(rc = ioctl(fd, EVIOCGBIT(0, EVBIT_NBYTES), bits));
48+ if (rc < 0)
49+ return rc;
50+ copy_bits(dev->evmask, bits, rc);
51+
52+ for (i = EV_KEY; i < EV_CNT; i++) {
53 SYSCALL(rc = ioctl(fd, EVIOCGBIT(i, sizeof(bits)), bits));
54 if (rc < 0)
55 continue;
56@@ -221,6 +232,15 @@
57 mask[i + 4], mask[i + 5], mask[i + 6], mask[i + 7]);
58 }
59
60+static void write_evmask(FILE * fp, const unsigned char *evmask)
61+{
62+ int i;
63+ fprintf(fp, "T:");
64+ for (i = 0; i < EVBIT_NBYTES; i++)
65+ fprintf(fp, " %02x", evmask[i]);
66+ fprintf(fp, "\n");
67+}
68+
69 static void write_mask(FILE * fp, int index,
70 const unsigned char *mask, int bytes)
71 {
72@@ -249,7 +269,9 @@
73
74 write_prop(fp, dev->prop, dev->pbytes);
75
76- for (i = 0; i < EV_CNT; i++)
77+ write_evmask(fp, dev->evmask);
78+
79+ for (i = EV_KEY; i < EV_CNT; i++)
80 write_mask(fp, i, dev->mask[i], dev->mbytes[i]);
81
82 for (i = 0; i < ABS_CNT; i++)
83@@ -271,6 +293,21 @@
84 }
85 }
86
87+static void read_evmask(struct evemu_device *dev, FILE *fp)
88+{
89+ unsigned int mask[8];
90+ int i;
91+ if (fscanf(fp, "B: 00 %02x %02x %02x %02x %02x %02x %02x %02x\n",
92+ mask + 0, mask + 1, mask + 2, mask + 3, mask + 4, mask + 5,
93+ mask + 6, mask + 7) > 0)
94+ for (i = 0; i < EVBIT_NBYTES; i++)
95+ dev->evmask[i] = mask[i];
96+ else if (fscanf(fp, "T: %02x %02x %02x %02x\n", mask + 0, mask + 1,
97+ mask + 2, mask + 3) > 0)
98+ for (i = 0; i < EVBIT_NBYTES; i++)
99+ dev->evmask[i] = mask[i];
100+}
101+
102 static void read_mask(struct evemu_device *dev, FILE *fp)
103 {
104 unsigned int mask[8];
105@@ -315,6 +352,8 @@
106
107 read_prop(dev, fp);
108
109+ read_evmask(dev, fp);
110+
111 read_mask(dev, fp);
112
113 read_abs(dev, fp);
114@@ -395,9 +434,6 @@
115 int ret = 0;
116
117 switch(type) {
118- case EV_SYN:
119- SYSCALL(ret = ioctl(fd, UI_SET_EVBIT, code));
120- break;
121 case EV_KEY:
122 SYSCALL(ret = ioctl(fd, UI_SET_KEYBIT, code));
123 break;
124@@ -441,6 +477,19 @@
125 return 0;
126 }
127
128+static int set_evmask(const struct evemu_device *dev, int fd)
129+{
130+ int ret, i;
131+ for (i = 0; i < EVBIT_NBITS; i++) {
132+ if (!evemu_has_type(dev, i))
133+ continue;
134+ SYSCALL(ret = ioctl(fd, UI_SET_EVBIT, i));
135+ if (ret < 0)
136+ return ret;
137+ }
138+ return 0;
139+}
140+
141 static int set_mask(const struct evemu_device *dev, int type, int fd)
142 {
143 int bits = 8 * dev->mbytes[type];
144@@ -476,6 +525,10 @@
145 if (ret < 0)
146 return ret;
147
148+ ret = set_evmask(dev, fd);
149+ if (ret < 0)
150+ return ret;
151+
152 for (i = 0; i < EV_CNT; i++) {
153 ret = set_mask(dev, i, fd);
154 if (ret < 0)

Subscribers

People subscribed via source and target branches

to all changes: