diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-04-30 15:05:50 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-05-08 14:17:58 +1000 |
commit | e4b1571d487cb67bab64e1ee890bddcd02437ddf (patch) | |
tree | 4d9db750b526be108c1651de6951c894b24aa99b /src | |
parent | 609b6728effb53006b2d0be1fac55d4ab1f269d2 (diff) |
eventcomm: if we can't grab the device, assume it's not a touchpad.
If a device is configured in the xorg.conf, it will get added once in the
config, once through HAL. Since we grab the device, the second device will be
mute. And confuses tools and users alike.
So let's just assume that if we can't grab the device, it doesn't exist.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Christoph Brill <egore911@egore911.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/eventcomm.c | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c index 70ee18c..b7a47d8 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -58,6 +58,14 @@ static void EventDeviceOnHook(LocalDevicePtr local, SynapticsParameters *para) { + SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + BOOL *need_grab; + + if (!priv->proto_data) + priv->proto_data = xcalloc(1, sizeof(BOOL)); + + need_grab = (BOOL*)priv->proto_data; + if (para->grab_event_device) { /* Try to grab the event device so that data don't leak to /dev/input/mice */ int ret; @@ -67,47 +75,62 @@ EventDeviceOnHook(LocalDevicePtr local, SynapticsParameters *para) local->name, errno); } } + + *need_grab = FALSE; } static Bool -event_query_is_touchpad(int fd) +event_query_is_touchpad(int fd, BOOL grab) { - int ret; + int ret = FALSE; unsigned long evbits[NBITS(EV_MAX)] = {0}; unsigned long absbits[NBITS(ABS_MAX)] = {0}; unsigned long keybits[NBITS(KEY_MAX)] = {0}; + if (grab) + { + SYSCALL(ret = ioctl(fd, EVIOCGRAB, (pointer)1)); + if (ret < 0) + return FALSE; + } + /* Check for ABS_X, ABS_Y, ABS_PRESSURE and BTN_TOOL_FINGER */ SYSCALL(ret = ioctl(fd, EVIOCGBIT(0, sizeof(evbits)), evbits)); if (ret < 0) - return FALSE; + goto unwind; if (!TEST_BIT(EV_SYN, evbits) || !TEST_BIT(EV_ABS, evbits) || !TEST_BIT(EV_KEY, evbits)) - return FALSE; + goto unwind; SYSCALL(ret = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits)); if (ret < 0) - return FALSE; + goto unwind; if (!TEST_BIT(ABS_X, absbits) || !TEST_BIT(ABS_Y, absbits)) - return FALSE; + goto unwind; SYSCALL(ret = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits)); if (ret < 0) - return FALSE; + goto unwind; /* we expect touchpad either report raw pressure or touches */ if (!TEST_BIT(ABS_PRESSURE, absbits) && !TEST_BIT(BTN_TOUCH, keybits)) - return FALSE; + goto unwind; /* all Synaptics-like touchpad report BTN_TOOL_FINGER */ if (!TEST_BIT(BTN_TOOL_FINGER, keybits)) - return FALSE; + goto unwind; if (TEST_BIT(BTN_TOOL_PEN, keybits)) - return FALSE; /* Don't match wacom tablets */ + goto unwind; /* Don't match wacom tablets */ - return TRUE; + ret = TRUE; + +unwind: + if (grab) + SYSCALL(ioctl(fd, EVIOCGRAB, (pointer)0)); + + return ret; } typedef struct { @@ -229,7 +252,10 @@ event_query_axis_ranges(LocalDevicePtr local) static Bool EventQueryHardware(LocalDevicePtr local) { - if (!event_query_is_touchpad(local->fd)) + SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + BOOL *need_grab = (BOOL*)priv->proto_data; + + if (!event_query_is_touchpad(local->fd, (need_grab) ? *need_grab : TRUE)) return FALSE; xf86Msg(X_PROBED, "%s: touchpad found\n", local->name); @@ -386,7 +412,10 @@ static int EventDevOnly(const struct dirent *dir) { static void EventReadDevDimensions(LocalDevicePtr local) { - if (event_query_is_touchpad(local->fd)) + SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + BOOL *need_grab = (BOOL*)priv->proto_data; + + if (event_query_is_touchpad(local->fd, (need_grab) ? *need_grab : TRUE)) event_query_axis_ranges(local); event_query_info(local); } @@ -422,7 +451,7 @@ EventAutoDevProbe(LocalDevicePtr local) if (fd < 0) continue; - if (event_query_is_touchpad(fd)) { + if (event_query_is_touchpad(fd, TRUE)) { touchpad_found = TRUE; xf86Msg(X_PROBED, "%s auto-dev sets device to %s\n", local->name, fname); |