[PATCH synaptics] Fix st->mt scaling
Leon Shaw
shaw.leon at gmail.com
Thu Mar 29 05:12:10 PDT 2012
From: Leon Shaw <shaw.leon at gmail.com>
Signed-off-by: Leon Shaw <shaw.leon at gmail.com>
---
src/eventcomm.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 28d034f..2d03743 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -71,7 +71,7 @@ struct eventcomm_proto_data
* exists for readability of the code.
*/
BOOL need_grab;
- int st_to_mt_offset[2];
+ int st_min[2];
double st_to_mt_scale[2];
#ifdef HAVE_MULTITOUCH
struct mtdev *mtdev;
@@ -396,6 +396,8 @@ event_query_axis_ranges(InputInfoPtr pInfo)
event_get_abs(pInfo, pInfo->fd, ABS_Y, &priv->miny, &priv->maxy,
&priv->synpara.hyst_y, &priv->resy);
+ proto_data->st_min[0] = priv->minx;
+ proto_data->st_min[1] = priv->miny;
priv->has_pressure = FALSE;
priv->has_width = FALSE;
SYSCALL(rc = ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits));
@@ -429,10 +431,8 @@ event_query_axis_ranges(InputInfoPtr pInfo)
event_get_abs(pInfo, pInfo->fd, ABS_MT_POSITION_Y, &priv->miny,
&priv->maxy, &priv->synpara.hyst_y, &priv->resy);
- proto_data->st_to_mt_offset[0] = priv->minx - st_minx;
proto_data->st_to_mt_scale[0] =
(priv->maxx - priv->minx) / (st_maxx - st_minx);
- proto_data->st_to_mt_offset[1] = priv->miny - st_miny;
proto_data->st_to_mt_scale[1] =
(priv->maxy - priv->miny) / (st_maxy - st_miny);
}
@@ -641,9 +641,11 @@ static int count_fingers(InputInfoPtr pInfo, const struct CommData *comm)
static inline double
-apply_st_scaling(struct eventcomm_proto_data *proto_data, int value, int axis)
+apply_st_scaling(SynapticsPrivate *priv, int value, int axis)
{
- return value * proto_data->st_to_mt_scale[axis] + proto_data->st_to_mt_offset[axis];
+ struct eventcomm_proto_data *proto_data = priv->proto_data;
+ return (value - proto_data->st_min[axis]) * proto_data->st_to_mt_scale[axis] +
+ (axis ? priv->miny : priv->minx);
}
Bool
@@ -738,10 +740,10 @@ EventReadHwState(InputInfoPtr pInfo,
if (ev.code < ABS_MT_SLOT) {
switch (ev.code) {
case ABS_X:
- hw->x = apply_st_scaling(proto_data, ev.value, 0);
+ hw->x = apply_st_scaling(priv, ev.value, 0);
break;
case ABS_Y:
- hw->y = apply_st_scaling(proto_data, ev.value, 1);
+ hw->y = apply_st_scaling(priv, ev.value, 1);
break;
case ABS_PRESSURE:
hw->z = ev.value;
--
1.7.9.5
More information about the xorg-devel
mailing list