-
Notifications
You must be signed in to change notification settings - Fork 19
Support autorepeat #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate key event would be sent so filtering with deviceid and sourceid |
||
|
|
||
| // 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) ? "=" : "+"); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to output of |
||
| } else { | ||
| printf("-"); | ||
| } | ||
| } | ||
| printf("%s\n", str); | ||
| fflush(stdout); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XI_KeyPresswon't be capturable with master devices only