diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-14 09:15:42 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-18 14:40:50 +1000 |
commit | d5a15e65b7d2fdda14fb719e3ebf076cce896386 (patch) | |
tree | a2a7b9c423b664d7f444a0ef45e343dda62afbb6 | |
parent | 01241b4247a7ad0974d48412cc0d88e1a09a3c49 (diff) |
Xi: include button state in XIButtonInfo.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | Xi/exevents.c | 1 | ||||
-rw-r--r-- | Xi/xiquerydevice.c | 16 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 107ffce8c..e404b8413 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -686,6 +686,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged { len += sizeof(xXIButtonInfo); len += dce->buttons.num_buttons * sizeof(Atom); /* button names */ + len += ((((dce->buttons.num_buttons + 7)/8) + 3)/4) * 4; } if (dce->num_valuators) len += sizeof(xXIValuatorInfo) * dce->num_valuators; diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index b523f387a..98325e112 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -205,6 +205,7 @@ SizeDeviceClasses(DeviceIntPtr dev) { len += sizeof(xXIButtonInfo); len += dev->button->numButtons * sizeof(Atom); + len += ((((dev->button->numButtons + 7)/8) + 3)/4) * 4; } if (dev->key) @@ -228,11 +229,24 @@ SizeDeviceClasses(DeviceIntPtr dev) int ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) { + unsigned char *bits; + int mask_len; + int i; + + mask_len = (((dev->button->numButtons + 7)/8) + 3)/4; /* 4-byte units*/ + info->type = ButtonClass; info->num_buttons = dev->button->numButtons; - info->length = 2 + info->num_buttons; + info->length = 2 + mask_len + info->num_buttons; info->sourceid = dev->button->sourceid; + bits = (unsigned char*)&info[1]; + memset(bits, 0, mask_len * 4); + + for (i = 0; dev && dev->button && i < dev->button->numButtons; i++) + if (BitIsOn(dev->button->down, i)) + SetBit(bits, i); + /** XXX: button labels */ return info->length * 4; |