Last active
December 11, 2015 22:49
-
-
Save yasar11732/4672593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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