Skip to content

Instantly share code, notes, and snippets.

@yasar11732
Last active December 11, 2015 22:49
Show Gist options
  • Save yasar11732/4672593 to your computer and use it in GitHub Desktop.
Save yasar11732/4672593 to your computer and use it in GitHub Desktop.
/* Includes were here */
/* This functions recieves XI_RawButtonPress event */
void handle_raw_event(XIRawEvent *ev) {
if(ev->detail == 1) {/* I am only interested in left button clicks */
printf("%u\n",time(NULL));
int i;
for(i=0; i< ev->valuators.mask_len * 8; i++) {
if(XIMaskIsSet(ev->valuators.mask,i)) {printf("Mask %d is set.\n",i);}
}
}
}
int main() {
/* Open display, select input etc. was here */
while(working) {
XEvent ev;
usleep(10000);
while(XPending(dpy)) {
XNextEvent(dpy, &ev);
if (XGetEventData(dpy, &ev.xcookie))
{
switch(ev.xcookie.evtype)
{
case XI_RawButtonPress:
handle_raw_event(ev.xcookie.data);
break;
}
}
XFreeEventData(dpy, &ev.xcookie);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment