[PATCH xf86-input-synaptics 06/12] Calculate cumulative dx and dy from moved touches
Peter Hutterer
peter.hutterer at who-t.net
Wed Feb 22 19:58:40 PST 2012
On Thu, Feb 09, 2012 at 06:53:00PM -0800, Chase Douglas wrote:
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
squash this in with 05/12 and explain what they're for please.
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> otherwise.
Cheers,
Peter
> ---
> src/eventcomm.c | 35 +++++++++++++++++++++++++++++++++--
> test/fake-symbols.c | 5 +++++
> 2 files changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index 8b29c46..97bb84c 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -484,6 +484,18 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
> return rc;
> }
>
> +static Bool
> +EventTouchSlotPreviouslyOpen(SynapticsPrivate *priv, int slot)
> +{
> + int i;
> +
> + for (i = 0; i < priv->num_active_touches; i++)
> + if (priv->open_slots[i] == slot)
> + return TRUE;
> +
> + return FALSE;
> +}
> +
> static void
> EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
> struct input_event *ev)
> @@ -524,8 +536,20 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
> int map = proto_data->axis_map[ev->code - ABS_MT_TOUCH_MAJOR];
> valuator_mask_set(hw->mt_mask[slot_index], map, ev->value);
> if (slot_index >= 0)
> - valuator_mask_set(proto_data->last_mt_vals[slot_index], map,
> - ev->value);
> + {
> + ValuatorMask *mask = proto_data->last_mt_vals[slot_index];
> + int last_val = valuator_mask_get(mask, map);
> +
> + if (EventTouchSlotPreviouslyOpen(priv, slot_index))
> + {
> + if (ev->code == ABS_MT_POSITION_X)
> + hw->cumulative_dx += ev->value - last_val;
> + else if (ev->code == ABS_MT_POSITION_Y)
> + hw->cumulative_dy += ev->value - last_val;
> + }
> +
> + valuator_mask_set(mask, map, ev->value);
> + }
> }
> }
> #endif
> @@ -566,6 +590,13 @@ EventReadHwState(InputInfoPtr pInfo,
>
> SynapticsResetTouchHwState(hw);
>
> + /* Reset cumulative values if buttons were not previously pressed */
> + if (!hw->left && !hw->right && !hw->middle)
> + {
> + hw->cumulative_dx = hw->x;
> + hw->cumulative_dy = hw->y;
> + }
> +
> while (SynapticsReadEvent(pInfo, &ev)) {
> switch (ev.type) {
> case EV_SYN:
> diff --git a/test/fake-symbols.c b/test/fake-symbols.c
> index 23f11df..7e0c6ad 100644
> --- a/test/fake-symbols.c
> +++ b/test/fake-symbols.c
> @@ -462,6 +462,11 @@ _X_EXPORT void valuator_mask_free(ValuatorMask **mask)
> {
> }
>
> +_X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valuator)
> +{
> + return 0;
> +}
> +
> _X_EXPORT void valuator_mask_set(ValuatorMask *mask, int valuator, int data)
> {
> }
> --
> 1.7.8.3
>
More information about the xorg-devel
mailing list