[PATCH synaptics] Fix st->mt scaling
Chase Douglas
chase.douglas at canonical.com
Thu Mar 29 10:21:09 PDT 2012
On 03/29/2012 05:12 AM, Leon Shaw wrote:
> From: Leon Shaw <shaw.leon at gmail.com>
Hi Leon,
Please include a description of the problem and how this fix addresses
it in the commit message. If there is a bug in the bug tracker, please
include the url too.
What device are you seeing this issue on?
> 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);
proto_data->st_min[0] == priv->minx, so we can get rid of
proto_daata->st_min. This would then become:
if (axis == 0)
return (value - priv->minx) * proto_data->st_to_mt_scale[axis] +
priv->minx;
else
return (value - priv->miny) * proto_data->st_to_mt_scale[axis] +
priv->miny;
I don't think this is correct. priv->min* are in mt coordinates, but
value is in st coordinates. You're subtracting two values in different
coordinate systems, which won't work.
I'm not real sure what the bug you're seeing is, please provide more
information so we can tell what's wrong.
> }
>
> 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;
More information about the xorg-devel
mailing list