I want to use the
EVIOCGRAB function in a C based program, and from googling around I have found various bits of example source code that use the function, but I am struggling to find explicit documentation that correctly describes how to correctly use it.
I see that from ioctl(2),
ioctl function is defined as
int ioctl(int d, unsigned long request, …);
The third argument is an untyped pointer to memory. It's traditionally char *argp (from the days before void * was valid C), and will be so named for this discussion.
And I hoped to find
EVIOCGRAB listed in ioctl_list(2), but it wasn't.
So I don't know what the third argument should be for the
EVIOCGRAB function. After seeing various bits of example code all I can do is assume that a non-zero value grabs the device and that a zero value releases it.
Which I got from random code examples like
int grab = 1; ioctl(fd, EVIOCGRAB, &grab); .. ioctl(fd, EVIOCGRAB, NULL);
ioctl(fd, EVIOCGRAB, (void*)1); .. ioctl(fd, EVIOCGRAB, (void*)0);
ioctl(fd, EVIOCGRAB, 1); .. ioctl(fd, EVIOCGRAB, 0);
(Which seems to smell a bit of cargo cult programming.)
So where can I find a definitive explanation of the
EVIOCGRAB control parameter?