aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2008-11-06 14:23:23 +0100
committerHenrik Rydberg <rydberg@euromail.se>2008-11-06 14:23:23 +0100
commit826439bce844fdbc8d7e47c0964cb15fd8a8fe93 (patch)
tree01fb4630ac048ace32b36c308dd0ec62b27f4dcd
parenta773c79d6d767ddfe574ad513ab0276bdd13a717 (diff)
downloadxorg-input-kobomultitouch-826439bce844fdbc8d7e47c0964cb15fd8a8fe93.tar.gz
xorg-input-kobomultitouch-826439bce844fdbc8d7e47c0964cb15fd8a8fe93.tar.bz2
xorg-input-kobomultitouch-826439bce844fdbc8d7e47c0964cb15fd8a8fe93.zip
grab and open/close device, now enters read (and crashes)
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/mtouch.c24
-rw-r--r--src/mtouch.h4
-rw-r--r--src/multitouch.c103
3 files changed, 80 insertions, 51 deletions
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;
+}
+
+/******************************************************/
diff --git a/src/mtouch.h b/src/mtouch.h
index a945162..d036a8f 100644
--- a/src/mtouch.h
+++ b/src/mtouch.h
@@ -9,12 +9,14 @@
struct MTouch {
struct Capabilities caps;
struct HWData hw;
+ bool grabbed;
};
////////////////////////////////////////////////////////
int configure_mtouch(struct MTouch *mt, int fd);
-int init_mtouch(struct MTouch *mt);
+int open_mtouch(struct MTouch *mt, int fd);
+void close_mtouch(struct MTouch *mt, int fd);
////////////////////////////////////////////////////////
diff --git a/src/multitouch.c b/src/multitouch.c
index 9fb6d82..73aaffd 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -27,39 +27,44 @@
static int device_init(LocalDevicePtr local)
{
- struct MTouch *mt = local->private;
- local->fd = xf86OpenSerial(local->options);
- if (local->fd < 0) {
- xf86Msg(X_ERROR, "multitouch: cannot configure device\n");
- return local->fd;
- }
- if (configure_mtouch(mt, local->fd))
- return -1;
- xf86CloseSerial(local->fd);
- return 0;
+ struct MTouch *mt = local->private;
+ local->fd = xf86OpenSerial(local->options);
+ if (local->fd < 0) {
+ xf86Msg(X_ERROR, "multitouch: cannot configure device\n");
+ return local->fd;
+ }
+ if (configure_mtouch(mt, local->fd))
+ return -1;
+ xf86CloseSerial(local->fd);
+ return 0;
}
////////////////////////////////////////////////////////////////////////////
static int device_on(LocalDevicePtr local)
{
- struct MTouch *mt = local->private;
- local->fd = xf86OpenSerial(local->options);
- if (local->fd < 0) {
- xf86Msg(X_ERROR, "multitouch: cannot open device\n");
- return local->fd;
- }
- if (init_mtouch(mt))
- return -1;
- return 0;
+ struct MTouch *mt = local->private;
+ local->fd = xf86OpenSerial(local->options);
+ if (local->fd < 0) {
+ xf86Msg(X_ERROR, "multitouch: cannot open device\n");
+ return local->fd;
+ }
+ if (open_mtouch(mt, local->fd))
+ return -1;
+ xf86AddEnabledDevice(local);
+ return 0;
}
////////////////////////////////////////////////////////////////////////////
static void device_off(LocalDevicePtr local)
{
- if(local->fd >= 0)
- xf86CloseSerial(local->fd);
+ struct MTouch *mt = local->private;
+ if(local->fd < 0)
+ return;
+ xf86RemoveEnabledDevice(local);
+ close_mtouch(mt, local->fd);
+ xf86CloseSerial(local->fd);
}
////////////////////////////////////////////////////////////////////////////
@@ -73,15 +78,15 @@ static void device_close(LocalDevicePtr local)
/* called for each full received packet from the touchpad */
static void read_input(LocalDevicePtr local)
{
- struct MTouch *mt = local->private;
-
- xf86Msg(X_INFO, "read_input called\n");
-
- if (local->fd >= 0) {
- while (!read_hwdata(&mt->hw, local->fd)) {
- // do all the good stuff here
- }
- }
+ struct MTouch *mt = local->private;
+
+ xf86Msg(X_INFO, "read_input called\n");
+
+ if (local->fd >= 0) {
+ while (!read_hwdata(&mt->hw, local->fd)) {
+ // do all the good stuff here
+ }
+ }
}
////////////////////////////////////////////////////////////////////////////
@@ -154,32 +159,32 @@ static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags)
////////////////////////////////////////////////////////////////////////////
static InputDriverRec MULTITOUCH = {
- 1,
- "multitouch",
- NULL,
- preinit,
- uninit,
- NULL,
- 0
+ 1,
+ "multitouch",
+ NULL,
+ preinit,
+ uninit,
+ NULL,
+ 0
};
static XF86ModuleVersionInfo VERSION = {
- "multitouch",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 0, 1, 0,
- ABI_CLASS_XINPUT,
- ABI_XINPUT_VERSION,
- MOD_CLASS_XINPUT,
- {0, 0, 0, 0}
+ "multitouch",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 1, 0,
+ ABI_CLASS_XINPUT,
+ ABI_XINPUT_VERSION,
+ MOD_CLASS_XINPUT,
+ {0, 0, 0, 0}
};
static pointer setup(pointer module, pointer options, int *errmaj, int *errmin)
{
- xf86AddInputDriver(&MULTITOUCH, module, 0);
- return module;
+ xf86AddInputDriver(&MULTITOUCH, module, 0);
+ return module;
}
XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL };