summaryrefslogtreecommitdiff
path: root/src/eventcomm.c
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-02-09 10:43:08 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2012-03-14 08:47:05 +1000
commit500243ac60ffeb5372e2edbce2f4443a07877d2e (patch)
tree139b80e15d4fd3c6916ef29bc1dce793931bd614 /src/eventcomm.c
parent420e0abef663729b3ce6e9d26360e616b7270ba6 (diff)
Add cumulative_d{x,y} to SynapticsHwState
These values will be used for clickpad press and drag with two fingers. While the clickpad button is not pressed, cumulative_d{x,y} will match x and y values. Once the clickpad button is pressed, cumulative_d{x,y} will be updated with the relative motion of each active touch on the touchpad. This allows for dragging with one finger while another finger stays stationary holding the clickpad button down. This is an easier and less latent approach than trying to guess which touch was the "dragging" touch. [fixed build error for mt off] Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/eventcomm.c')
-rw-r--r--src/eventcomm.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index d031eb4..d52cb6c 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -525,6 +525,20 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
return rc;
}
+#ifdef HAVE_MULTITOUCH
+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;
+}
+#endif
+
static void
EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
struct input_event *ev)
@@ -565,8 +579,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
@@ -614,6 +640,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: