[PATCH xf86-input-synaptics v2 06/12] Calculate cumulative dx and dy from moved touches
Chase Douglas
chase.douglas at canonical.com
Fri Feb 10 12:00:45 PST 2012
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
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 3ef97d5..007052e 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 7f3f0ac..65fad46 100644
--- a/test/fake-symbols.c
+++ b/test/fake-symbols.c
@@ -461,6 +461,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