diff --git a/xkbcat.c b/xkbcat.c index 5e28cc2..f671576 100644 --- a/xkbcat.c +++ b/xkbcat.c @@ -72,12 +72,12 @@ int main(int argc, char * argv[]) { { // Register to receive XInput events Window root = DefaultRootWindow(disp); XIEventMask m; - m.deviceid = XIAllMasterDevices; + m.deviceid = XIAllDevices; m.mask_len = XIMaskLen(XI_LASTEVENT); m.mask = calloc(m.mask_len, sizeof(char)); // Raw key presses correspond to physical key-presses, without // processing steps such as auto-repeat. - XISetMask(m.mask, XI_RawKeyPress); + XISetMask(m.mask, XI_KeyPress); if (printKeyUps) XISetMask(m.mask, XI_RawKeyRelease); XISelectEvents(disp, root, &m, 1 /*number of masks*/); XSync(disp, false); @@ -117,7 +117,7 @@ int main(int argc, char * argv[]) { if (cookie->type == GenericEvent && cookie->extension == xiOpcode) { if (cookie->evtype == XI_RawKeyRelease - || cookie->evtype == XI_RawKeyPress) { + || cookie->evtype == XI_KeyPress) { XIRawEvent *ev = cookie->data; // Ask X what it calls that key; skip if unknown. @@ -142,9 +142,17 @@ int main(int argc, char * argv[]) { char *str = XKeysymToString(s); if (NULL == str) continue; + if (cookie->evtype == XI_RawKeyRelease && ev->deviceid != ev->sourceid) continue; + // Output line - if (printKeyUps) printf("%s", - cookie->evtype == XI_RawKeyPress ? "+" : "-"); + if (printKeyUps) { + if (cookie->evtype == XI_KeyPress) { + XIDeviceEvent* dev_ev = cookie->data; + printf("%s", (dev_ev->flags & XIKeyRepeat) ? "=" : "+"); + } else { + printf("-"); + } + } printf("%s\n", str); fflush(stdout); }