public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: Peter Osterlund <petero2@telia.com>
Cc: Vojtech Pavlik <vojtech@suse.cz>,
	Linus Torvalds <torvalds@osdl.org>,
	linux-kernel@vger.kernel.org,
	Dmitry Torokhov <dtor_core@ameritech.net>
Subject: Re: Broken synaptics mouse..
Date: Sun, 21 Sep 2003 19:27:58 +0200	[thread overview]
Message-ID: <20030921172758.GA21014@ucw.cz> (raw)
In-Reply-To: <m2fziqukhi.fsf@p4.localdomain>

On Sun, Sep 21, 2003 at 07:20:09PM +0200, Peter Osterlund wrote:

> > I'd really prefer to contain the ugliness in mousedev.c, which then
> > could be removed completely in 2.8 or so, when XFree and GPM is already
> > well adapted to the event interface.
> 
> That's certainly possible too. See patch below. Note though that this
> patch has the disadvantage mentioned by Dmitry:
> 
>         We also can't just emulate relative events as everything is
>         multiplexed into /dev/input/mice and I can see many people
>         using Synaptics via /dev/input/eventX and everything else via
>         /dev/input/mice as it nicely handles hot plugging (at least I
>         use it this way).

You can use EVIOCGRAB for the time being in the XFree86 synaptics
driver, this way you'll prevent its events coming into mousedev the
moment it's opened by XFree86, which is probably exactly what one wants.

For the future, I'd really like to get rid of /dev/input/mice, exactly
because it's not possible to configure which devices should be mixed in
there. A userspace solution might be better.

I'll get myself a Synaptics-equipped notebook on Monday, test this, and
if it looks OK, I'll merge it.

One thing I don't particularly like is the check for product ==
PSMOUSE_SYNAPTICS, since it's very non-generic. Also, ABS_PRESSURE is
defined on most tablets ...

We should define a standard set of features (ABS_*, BTN_*) that a
touchpad should have, and what they should mean. I fear the current
Synaptics driver gets some of it wrong. (Like the axis orientation,
which is defined to be the same as the USB HID spec, or the fact that
invalid ABS_* values should not be reported).

>  linux-petero/drivers/input/mousedev.c |  102 +++++++++++++++++++++++++---------
>  1 files changed, 76 insertions(+), 26 deletions(-)
> 
> diff -puN drivers/input/mousedev.c~mousedev-synaptics drivers/input/mousedev.c
> --- linux/drivers/input/mousedev.c~mousedev-synaptics	2003-09-21 14:55:34.000000000 +0200
> +++ linux-petero/drivers/input/mousedev.c	2003-09-21 18:58:47.000000000 +0200
> @@ -26,6 +26,8 @@
>  #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
>  #include <linux/miscdevice.h>
>  #endif
> +#include <linux/serio.h>
> +#include "mouse/psmouse.h"		    /* For the PSMOUSE_SYNAPTICS definition */
>  
>  MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
>  MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
> @@ -58,6 +60,7 @@ struct mousedev_list {
>  	unsigned long buttons;
>  	unsigned char ready, buffer, bufsiz;
>  	unsigned char mode, imexseq, impsseq;
> +	int finger;
>  };
>  
>  #define MOUSEDEV_SEQ_LEN	6
> @@ -73,12 +76,76 @@ static struct mousedev mousedev_mix;
>  static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
>  static int yres = CONFIG_INPUT_MOUSEDEV_SCREEN_Y;
>  
> +static void mousedev_abs_event(struct input_handle *handle, struct mousedev_list *list, unsigned int code, int value)
> +{
> +	int size;
> +
> +	/* Ignore joysticks */
> +	if (test_bit(BTN_TRIGGER, handle->dev->keybit))
> +		return;
> +
> +	/* Handle touchpad data */
> +	if (test_bit(ABS_PRESSURE, handle->dev->absbit) &&
> +	    (handle->dev->id.product == PSMOUSE_SYNAPTICS)) {
> +		switch (code) {
> +		case ABS_PRESSURE:
> +			if (!list->finger) {
> +				if (value > 30)
> +					list->finger = 1;
> +			} else {
> +				if (value < 25)
> +					list->finger = 0;
> +				else if (list->finger < 3)
> +					list->finger++;
> +			}
> +			break;
> +		case ABS_X:
> +			if (list->finger >= 3) {
> +				list->dx += (value - list->oldx) / 8;
> +			}
> +			list->oldx = value;
> +			break;
> +		case ABS_Y:
> +			if (list->finger >= 3) {
> +				list->dy += (value - list->oldy) / 8;
> +			}
> +			list->oldy = value;
> +			break;
> +		}
> +		return;
> +	}
> +
> +	/* Handle tablet like devices */
> +	switch (code) {
> +	case ABS_X:
> +		size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
> +		if (size != 0) {
> +			list->dx += (value * xres - list->oldx) / size;
> +			list->oldx += list->dx * size;
> +		} else {
> +			list->dx += value - list->oldx;
> +			list->oldx += list->dx;
> +		}
> +		break;
> +	case ABS_Y:
> +		size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
> +		if (size != 0) {
> +			list->dy -= (value * yres - list->oldy) / size;
> +			list->oldy -= list->dy * size;
> +		} else {
> +			list->dy -= value - list->oldy;
> +			list->oldy -= list->dy;
> +		}
> +		break;
> +	}
> +}
> +
>  static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
>  {
>  	struct mousedev *mousedevs[3] = { handle->private, &mousedev_mix, NULL };
>  	struct mousedev **mousedev = mousedevs;
>  	struct mousedev_list *list;
> -	int index, size, wake;
> +	int index, wake;
>  
>  	while (*mousedev) {
>  
> @@ -87,31 +154,7 @@ static void mousedev_event(struct input_
>  		list_for_each_entry(list, &(*mousedev)->list, node)
>  			switch (type) {
>  				case EV_ABS:
> -					if (test_bit(BTN_TRIGGER, handle->dev->keybit))
> -						break;
> -					switch (code) {
> -						case ABS_X:	
> -							size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
> -							if (size != 0) {
> -								list->dx += (value * xres - list->oldx) / size;
> -								list->oldx += list->dx * size;
> -							} else {
> -								list->dx += value - list->oldx;
> -								list->oldx += list->dx;
> -							}
> -							break;
> -
> -						case ABS_Y:
> -							size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
> -							if (size != 0) {
> -								list->dy -= (value * yres - list->oldy) / size;
> -								list->oldy -= list->dy * size;
> -							} else {
> -								list->dy -= value - list->oldy;
> -								list->oldy -= list->dy;
> -							}
> -							break;
> -					}
> +					mousedev_abs_event(handle, list, code, value);
>  					break;
>  
>  				case EV_REL:
> @@ -473,6 +516,13 @@ static struct input_device_id mousedev_i
>  		.absbit = { BIT(ABS_X) | BIT(ABS_Y) },
>  	},	/* A tablet like device, at least touch detection, two absolute axes */
>  
> +	{
> +		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT | INPUT_DEVICE_ID_MATCH_PRODUCT,
> +		.evbit = { BIT(EV_KEY) | BIT(EV_ABS) },
> +		.absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) },
> +		.id.product = PSMOUSE_SYNAPTICS,
> +	},	/* A synaptics touchpad */
> +
>  	{ }, 	/* Terminating entry */
>  };
>  
> 
> _
> 
> -- 
> Peter Osterlund - petero2@telia.com
> http://w1.894.telia.com/~u89404340

-- 
Vojtech Pavlik
SuSE Labs, SuSE CR

  reply	other threads:[~2003-09-21 17:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.44.0309110744030.28410-100000@home.osdl.org>
2003-09-18 23:43 ` Broken synaptics mouse Peter Osterlund
2003-09-19  5:05   ` Dmitry Torokhov
2003-09-19 11:48   ` Vojtech Pavlik
2003-09-21 17:20     ` Peter Osterlund
2003-09-21 17:27       ` Vojtech Pavlik [this message]
2003-09-21 19:29         ` Peter Osterlund
2003-09-21 19:34           ` Vojtech Pavlik
2003-09-21 20:26             ` Peter Osterlund
2003-09-21 20:42               ` Vojtech Pavlik
2003-09-21 23:16         ` Dmitry Torokhov
2003-09-22  5:31           ` Vojtech Pavlik
2003-09-22  5:58             ` Dmitry Torokhov
2003-09-22  6:09               ` Vojtech Pavlik
2003-10-01 10:03   ` Pavel Machek
2003-10-01 15:38     ` Peter Osterlund
     [not found] <xgHm.3mL.27@gated-at.bofh.it>
     [not found] ` <xlGW.2qw.15@gated-at.bofh.it>
2003-09-19 15:39   ` Ruben Puettmann
2003-09-21 21:17 Ricardo Galli
2003-09-21 21:41 ` Peter Osterlund
  -- strict thread matches above, loose matches on Subject: below --
2003-09-21 22:15 Ricardo Galli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030921172758.GA21014@ucw.cz \
    --to=vojtech@suse.cz \
    --cc=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petero2@telia.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox