summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Osterlund <petero2@telia.com>2003-11-12 20:49:36 +0100
committerPeter Osterlund <petero2@telia.com>2006-04-09 04:01:23 +0200
commit0a3ab4831d47ccde9f1ccfefbac16a0de1bbcf99 (patch)
treeee30099706179e0373dca035707ed6c7b2680070
parent5181449a9ffb449ac55d943ab2b6905f97558d4f (diff)
Replaced the oneFinger, twoFingers and threeFingers
variables in SynapticsHwState with a single variable numFingers. This is more logical, the old variables only existed because of implementation details in the 2.6 kernel interface.
-rw-r--r--synaptics.c39
-rw-r--r--synaptics.h8
2 files changed, 24 insertions, 23 deletions
diff --git a/synaptics.c b/synaptics.c
index 3657111..f168934 100644
--- a/synaptics.c
+++ b/synaptics.c
@@ -736,7 +736,7 @@ SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
priv->avg_width += (hw->fingerWidth - priv->avg_width + 1) / 2;
if (finger && !priv->finger_flag) {
int safe_width = MAX(hw->fingerWidth, priv->avg_width);
- if (hw->twoFingers || hw->threeFingers)
+ if (hw->numFingers > 1)
finger = TRUE; /* more than one finger -> not a palm */
else if ((safe_width < 6) && (priv->prev_z < para->finger_high))
finger = TRUE; /* thin finger, distinct touch -> not a palm */
@@ -785,14 +785,7 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState* hw)
para->x = hw->x;
para->y = hw->y;
para->z = hw->z;
- if (hw->oneFinger)
- para->numFingers = 1;
- else if (hw->twoFingers)
- para->numFingers = 2;
- else if (hw->threeFingers)
- para->numFingers = 3;
- else
- para->numFingers = 0;
+ para->numFingers = hw->numFingers;
para->fingerWidth = hw->fingerWidth;
para->left = hw->left;
para->right = hw->right;
@@ -913,9 +906,9 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState* hw)
if (finger && /* finger is on the surface */
(timeleft > 0)) { /* tap time is not succeeded */
/* count fingers when reported */
- if (hw->twoFingers && (priv->finger_count == 0))
+ if ((hw->numFingers == 2) && (priv->finger_count == 0))
priv->finger_count = 2;
- if (hw->threeFingers)
+ if (hw->numFingers == 3)
priv->finger_count = 3;
} else { /* reset finger counts */
priv->finger_count = 0;
@@ -1269,6 +1262,14 @@ SynapticsParseEventData(LocalDevicePtr local, SynapticsPrivate *priv,
case EV_SYN:
switch (ev.code) {
case SYN_REPORT:
+ if (priv->oneFinger)
+ priv->hwState.numFingers = 1;
+ else if (priv->twoFingers)
+ priv->hwState.numFingers = 2;
+ else if (priv->threeFingers)
+ priv->hwState.numFingers = 3;
+ else
+ priv->hwState.numFingers = 0;
*hw = priv->hwState;
return Success;
}
@@ -1312,13 +1313,13 @@ SynapticsParseEventData(LocalDevicePtr local, SynapticsPrivate *priv,
priv->hwState.multi[7] = v;
break;
case BTN_TOOL_FINGER:
- priv->hwState.oneFinger = v;
+ priv->oneFinger = v;
break;
case BTN_TOOL_DOUBLETAP:
- priv->hwState.twoFingers = v;
+ priv->twoFingers = v;
break;
case BTN_TOOL_TRIPLETAP:
- priv->hwState.threeFingers = v;
+ priv->threeFingers = v;
break;
}
break;
@@ -1439,9 +1440,7 @@ SynapticsParseRawPacket(LocalDevicePtr local, SynapticsPrivate *priv,
hw->y = YMAX_NOMINAL + YMIN_NOMINAL - hw->y;
- hw->oneFinger = FALSE;
- hw->twoFingers = FALSE;
- hw->threeFingers = FALSE;
+ hw->numFingers = 0;
hw->fingerWidth = 0;
if (hw->z > 0) {
@@ -1465,15 +1464,15 @@ SynapticsParseRawPacket(LocalDevicePtr local, SynapticsPrivate *priv,
switch (w) {
case 0:
- hw->twoFingers = TRUE;
+ hw->numFingers = 2;
hw->fingerWidth = 5;
break;
case 1:
- hw->threeFingers = TRUE;
+ hw->numFingers = 3;
hw->fingerWidth = 5;
break;
default:
- hw->oneFinger = TRUE;
+ hw->numFingers = 1;
hw->fingerWidth = w;
break;
}
diff --git a/synaptics.h b/synaptics.h
index 87a3c11..6538807 100644
--- a/synaptics.h
+++ b/synaptics.h
@@ -57,9 +57,7 @@ struct SynapticsHwState {
int x; /* X position of finger */
int y; /* Y position of finger */
int z; /* Finger pressure */
- Bool oneFinger;
- Bool twoFingers;
- Bool threeFingers;
+ int numFingers;
int fingerWidth;
Bool left;
@@ -147,6 +145,10 @@ typedef struct _SynapticsPrivateRec
palm/finger contact disappears */
int prev_z; /* previous z value, for palm detection */
int avg_width; /* weighted average of previous fingerWidth values */
+
+ Bool oneFinger; /* Used by SynapticsParseEventData to */
+ Bool twoFingers; /* keep track of the number of fingers */
+ Bool threeFingers; /* on the touchpad. */
} SynapticsPrivate;