one, two, three, many.

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/eventcomm.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/eventcomm.c b/src/eventcomm.c
index 15f9d2d..f55c88f 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -314,6 +314,29 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event 
*ev)
     return rc;
 }
 
+/**
+ * Count the number of fingers based on the CommData information.
+ * The CommData struct contains the event information based on previous
+ * struct input_events, now we're just counting based on that.
+ *
+ * @param comm Assembled information from previous events.
+ * @return The number of fingers currently set.
+ */
+static int count_fingers(const struct CommData *comm)
+{
+    int fingers = 0;
+
+    if (comm->oneFinger)
+       fingers = 1;
+    else if (comm->twoFingers)
+       fingers = 2;
+    else if (comm->threeFingers)
+       fingers = 3;
+
+    return fingers;
+}
+
+
 static Bool
 EventReadHwState(InputInfoPtr pInfo,
                 struct CommData *comm, struct SynapticsHwState *hwRet)
@@ -329,14 +352,7 @@ EventReadHwState(InputInfoPtr pInfo,
        case EV_SYN:
            switch (ev.code) {
            case SYN_REPORT:
-               if (comm->oneFinger)
-                   hw->numFingers = 1;
-               else if (comm->twoFingers)
-                   hw->numFingers = 2;
-               else if (comm->threeFingers)
-                   hw->numFingers = 3;
-               else
-                   hw->numFingers = 0;
+               hw->numFingers = count_fingers(comm);
                *hwRet = *hw;
                return TRUE;
            }
-- 
1.7.4

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to