Re: [PATCH xf86-input-synaptics 1/2] Count number of multitouch touches for multitouch finger count

2012-03-25 Thread Peter Hutterer
On Fri, Mar 23, 2012 at 10:51:58AM -0700, Chase Douglas wrote:
> 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 
> ---
> I test build with HAVE_MULTITOUCH undefined to be sure it didn't break
> anything.

merged, thanks.

Cheers,
  Peter
> 
>  src/eventcomm.c |   16 ++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index 3721c91..b485377 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -72,6 +72,7 @@ struct eventcomm_proto_data
>  int axis_map[MT_ABS_SIZE];
>  int cur_slot;
>  ValuatorMask **last_mt_vals;
> +int num_touches;
>  #endif
>  };
>  
> @@ -565,6 +566,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],
> @@ -574,7 +576,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];
> @@ -607,10 +612,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)
> @@ -653,7 +665,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;
> -- 
> 1.7.9.1
> 
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH xf86-input-synaptics 1/2] Count number of multitouch touches for multitouch finger count

2012-03-23 Thread Chase Douglas
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 
---
I test build with HAVE_MULTITOUCH undefined to be sure it didn't break
anything.

 src/eventcomm.c |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/eventcomm.c b/src/eventcomm.c
index 3721c91..b485377 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -72,6 +72,7 @@ struct eventcomm_proto_data
 int axis_map[MT_ABS_SIZE];
 int cur_slot;
 ValuatorMask **last_mt_vals;
+int num_touches;
 #endif
 };
 
@@ -565,6 +566,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],
@@ -574,7 +576,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];
@@ -607,10 +612,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)
@@ -653,7 +665,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;
-- 
1.7.9.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel