From a593f31943b8837fbd0b2b1804bf5bfe45d15768 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Jan 2004 00:38:25 +0100 Subject: [PATCH] Handle touchpads with a scroll region on the right side where very large X coordinates (typically 8176=0x1ff0) are reported. --- synaptics.c | 16 ++++++++++++++++ synaptics.h | 1 + 2 files changed, 17 insertions(+) diff --git a/synaptics.c b/synaptics.c index 588b3c0..ac0cc74 100644 --- a/synaptics.c +++ b/synaptics.c @@ -90,6 +90,8 @@ #define YMIN_NOMINAL 1408 #define YMAX_NOMINAL 4448 +#define XMAX_VALID 6143 + #define MAX_UNSYNC_PACKETS 10 /* i.e. 10 to 60 bytes */ typedef enum { @@ -354,6 +356,8 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) local->name); } + priv->largest_valid_x = MIN(priv->synpara->right_edge, XMAX_NOMINAL); + priv->buffer = XisbNew(local->fd, 200); DBG(9, XisbTrace(priv->buffer, 1)); @@ -858,6 +862,18 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState* hw) hw->up = hw->down = FALSE; } + /* + * Some touchpads have a scroll wheel region where a very large X + * coordinate is reported. For such touchpads, we adjust the X + * coordinate to eliminate the discontinuity. + */ + if (hw->x <= XMAX_VALID) { + if (priv->largest_valid_x < hw->x) + priv->largest_valid_x = hw->x; + } else { + hw->x = priv->largest_valid_x; + } + edge = edge_detection(priv, hw->x, hw->y); finger = SynapticsDetectFinger(priv, hw); diff --git a/synaptics.h b/synaptics.h index 156d66a..3c14b11 100644 --- a/synaptics.h +++ b/synaptics.h @@ -144,6 +144,7 @@ typedef struct _SynapticsPrivateRec SynapticsTapRec touch_on; /* data when the touchpad is touched */ SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */ + int largest_valid_x; /* Largest valid X coordinate seen so far */ int scroll_y; /* last y-scroll position */ int scroll_x; /* last x-scroll position */ unsigned long count_packet_finger; /* packet counter with finger on the touchpad */