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>
This commit is contained in:
Chase Douglas
2012-02-09 10:43:08 -08:00
committed by Peter Hutterer
parent 420e0abef6
commit 500243ac60
4 changed files with 44 additions and 2 deletions

View File

@@ -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:

View File

@@ -120,6 +120,8 @@ SynapticsCopyHwState(struct SynapticsHwState *dst,
dst->x = src->x;
dst->y = src->y;
dst->z = src->z;
dst->cumulative_dx = src->cumulative_dx;
dst->cumulative_dy = src->cumulative_dy;
dst->numFingers = src->numFingers;
dst->fingerWidth = src->fingerWidth;
dst->left = src->left & BTN_EMULATED_FLAG ? 0 : src->left;

View File

@@ -56,6 +56,8 @@ struct SynapticsHwState {
int x; /* X position of finger */
int y; /* Y position of finger */
int z; /* Finger pressure */
int cumulative_dx; /* Cumulative delta X for clickpad dragging */
int cumulative_dy; /* Cumulative delta Y for clickpad dragging */
int numFingers;
int fingerWidth;

View File

@@ -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)
{
}