From 826439bce844fdbc8d7e47c0964cb15fd8a8fe93 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 6 Nov 2008 14:23:23 +0100 Subject: grab and open/close device, now enters read (and crashes) Signed-off-by: Henrik Rydberg --- src/mtouch.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/mtouch.c') diff --git a/src/mtouch.c b/src/mtouch.c index 2d05921..a74a1f6 100644 --- a/src/mtouch.c +++ b/src/mtouch.c @@ -14,9 +14,31 @@ int configure_mtouch(struct MTouch *mt, int fd) /******************************************************/ -int init_mtouch(struct MTouch *mt) +int open_mtouch(struct MTouch *mt, int fd) { + int rc; + if (mt->grabbed) + return 0; + SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1)); + if (rc < 0) { + xf86Msg(X_WARNING, "multitouch: cannot grab device\n"); + return rc; + } + mt->grabbed = 1; return 0; } /******************************************************/ + +void close_mtouch(struct MTouch *mt, int fd) +{ + int rc; + if (!mt->grabbed) + return 0; + SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0)); + if (rc < 0) + xf86Msg(X_WARNING, "multitouch: cannot ungrab device\n"); + mt->grabbed = 0; +} + +/******************************************************/ -- cgit v1.2.3