diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2012-03-23 10:51:58 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-03-26 11:58:09 +1000 |
commit | da461b91659d0c64aa6827e065aee2682116a57e (patch) | |
tree | 71f69569b24935eccbf7c687fd1d787c00da447d | |
parent | bc95d90be17d52726b85c785a8e7503512e8fa3d (diff) |
Count number of multitouch touches for multitouch finger count
The evdev protocol only goes up to three touches for non-multitouch
devices. If you perform a four touch tap, the finger count will only go
up to three touches if you roll your fingers, or will always be 0 if all
four touches land at the same time.
This change ensures the correct finger count is reported.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/eventcomm.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c index cd89180..28d034f 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -78,6 +78,7 @@ struct eventcomm_proto_data int axis_map[MT_ABS_SIZE]; int cur_slot; ValuatorMask **last_mt_vals; + int num_touches; #endif }; @@ -571,6 +572,7 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw, if (ev->value >= 0) { hw->slot_state[slot_index] = SLOTSTATE_OPEN; + proto_data->num_touches++; if (slot_index >= 0) valuator_mask_copy(hw->mt_mask[slot_index], @@ -580,7 +582,10 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw, "Attempted to copy values from out-of-range " "slot, touch events may be incorrect.\n"); } else + { hw->slot_state[slot_index] = SLOTSTATE_CLOSE; + proto_data->num_touches--; + } } else { int map = proto_data->axis_map[ev->code - ABS_MT_TOUCH_MAJOR]; @@ -613,10 +618,17 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw, * @param comm Assembled information from previous events. * @return The number of fingers currently set. */ -static int count_fingers(const struct CommData *comm) +static int count_fingers(InputInfoPtr pInfo, const struct CommData *comm) { + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; + struct eventcomm_proto_data *proto_data = priv->proto_data; int fingers = 0; +#ifdef HAVE_MULTITOUCH + if (priv->has_touch) + return proto_data->num_touches; +#endif + if (comm->oneFinger) fingers = 1; else if (comm->twoFingers) @@ -659,7 +671,7 @@ EventReadHwState(InputInfoPtr pInfo, case EV_SYN: switch (ev.code) { case SYN_REPORT: - hw->numFingers = count_fingers(comm); + hw->numFingers = count_fingers(pInfo, comm); hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000; SynapticsCopyHwState(hwRet, hw); return TRUE; |