summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-06-15 20:00:41 +0930
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-06-18 10:17:08 +0930
commitd21155a3e9b51df946766926bc6155c8972c4439 (patch)
treee0273dd5288f36aedeacd5a4ebfb9116e5080902 /Xi
parent2b9c829bdebd16910bdf48b9d64862e3d34f5b7f (diff)
input: fix up usage of button->down, used to be a bitmask, is now an array.
device->button->down used to be a 32-byte bitmask with one bit for each button. This has changed into a 256-byte array, with one byte assigned for each button. Some of the callers were still using this array as a bitmask however, this is fixed with this patch. Thanks to Keith Packard for pointing this out. See also: http://lists.freedesktop.org/archives/xorg/2008-June/036202.html
Diffstat (limited to 'Xi')
-rw-r--r--Xi/exevents.c10
-rw-r--r--Xi/queryst.c6
2 files changed, 10 insertions, 6 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 6f88b57f3..4736a1284 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1153,9 +1153,11 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
ev->num_valuators = 0;
if (b) {
+ int i;
ev->classes_reported |= (1 << ButtonClass);
ev->num_buttons = b->numButtons;
- memmove((char *)&ev->buttons[0], (char *)b->down, 4);
+ for (i = 0; i < 32; i++)
+ SetBitIf(ev->buttons, b->down, i);
} else if (k) {
ev->classes_reported |= (1 << KeyClass);
ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode;
@@ -1270,11 +1272,13 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
first += 3;
nval -= 3;
if (nbuttons > 32) {
+ int i;
(ev - 1)->deviceid |= MORE_EVENTS;
bev = (deviceButtonStateNotify *) ev++;
bev->type = DeviceButtonStateNotify;
bev->deviceid = dev->id;
- memmove((char *)&bev->buttons[0], (char *)&b->down[4], 28);
+ for (i = 32; i < MAP_LENGTH; i++)
+ SetBitIf(bev->buttons, b->down, i);
}
if (nval > 0) {
(ev - 1)->deviceid |= MORE_EVENTS;
@@ -1692,7 +1696,7 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
return BadValue;
for (i = 0; i < nElts; i++)
- if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
+ if ((b->map[i + 1] != map[i]) && (b->down[i + 1]))
return MappingBusy;
for (i = 0; i < nElts; i++)
b->map[i + 1] = map[i];
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 71ab79be8..268bdd78b 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -119,7 +119,7 @@ ProcXQueryDeviceState(ClientPtr client)
total_length += (sizeof(xValuatorState) + (v->numAxes * sizeof(int)));
num_classes++;
}
- buf = (char *)xalloc(total_length);
+ buf = (char *)xcalloc(total_length, 1);
if (!buf)
return BadAlloc;
savbuf = buf;
@@ -139,8 +139,8 @@ ProcXQueryDeviceState(ClientPtr client)
tb->class = ButtonClass;
tb->length = sizeof(xButtonState);
tb->num_buttons = b->numButtons;
- for (i = 0; i < 32; i++)
- tb->buttons[i] = b->down[i];
+ for (i = 0; i < MAP_LENGTH; i++)
+ SetBitIf(tb->buttons, b->down, i);
buf += sizeof(xButtonState);
}