Re: disable appletouch when plugging in mouse
Johannes Berg <johannes@sipsolutions.net> writes:
> Bah, as nice as the script is, it messes up the appletouch driver
> because the touchpad's values drift over time and if we disable it the
> driver won't know.
You could try opening the evdev and doing an exclusive grab (code
attached). This definitely prevents the events from getting to
/dev/input/mice, but I don't know if it'll stop other fds on the same
evdev from getting them.
/* based on code posted to linux-kernel by Peter Osterlund */
/* pass it a /dev/input/eventN node */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
/* From linux/include/linux/input.h */
struct input_event {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
};
#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
int main(int argc, char* argv[])
{
int fd;
if (argc != 2) {
fprintf(stderr, "no device specified\n");
exit(1);
}
if ((fd = open(argv[1], O_RDONLY)) < 0) {
perror("open");
exit(1);
}
if (ioctl(fd, EVIOCGRAB, 1) < 0) {
perror("ioctl");
exit(1);
}
for (;;) {
struct input_event ev;
read(fd, &ev, sizeof(ev));
}
close(fd);
return 0;
}
--
Paul Collins
Melbourne, Australia
Dag vijandelijk luchtschip de huismeester is dood
Reply to: