diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-08-19 13:43:21 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-09-04 08:10:37 +1000 |
commit | a629e9fb42433c01daf2278381dcf5bbe1557c16 (patch) | |
tree | 953b6b652229d62c3a3b6f7a66f8dd0356211270 | |
parent | 342a38c9c1aa6291d51485de00880359eee95588 (diff) |
Use finger state as an enum, not as a bool.
SynapticsDetectFinger mixed using finger as an FS_* enum and as a bool if
palm detect was on.
Reshuffle the conditions that it stays as-is or is reset to FS_UNTOUCHED,
whichever is appropriate.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Christoph Brill <egore911@egore911.de>
-rw-r--r-- | src/synaptics.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/synaptics.c b/src/synaptics.c index c56b0e0..597aad2 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -1232,11 +1232,11 @@ HandleMidButtonEmulation(SynapticsPrivate *priv, struct SynapticsHwState *hw, in return mid; } -static int +static enum FingerState SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw) { SynapticsParameters *para = &priv->synpara; - int finger; + enum FingerState finger; /* finger detection thru pressure and threshold */ if (hw->z > para->finger_press && priv->finger_state < FS_PRESSED) @@ -1264,25 +1264,25 @@ SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw) priv->avg_width += (hw->fingerWidth - priv->avg_width + 1) / 2; if (finger && !priv->finger_state) { int safe_width = MAX(hw->fingerWidth, priv->avg_width); - 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 */ - else if ((safe_width < 7) && (priv->prev_z < para->finger_high / 2)) - finger = TRUE; /* thin finger, distinct touch -> not a palm */ - else if (hw->z > priv->prev_z + 1) /* z not stable, may be a palm */ - finger = FALSE; + + if (hw->numFingers > 1 || /* more than one finger -> not a palm */ + ((safe_width < 6) && (priv->prev_z < para->finger_high)) || /* thin finger, distinct touch -> not a palm */ + ((safe_width < 7) && (priv->prev_z < para->finger_high / 2)))/* thin finger, distinct touch -> not a palm */ + { + /* leave finger value as is */ + } else if (hw->z > priv->prev_z + 1) /* z not stable, may be a palm */ + finger = FS_UNTOUCHED; else if (hw->z < priv->prev_z - 5) /* z not stable, may be a palm */ - finger = FALSE; + finger = FS_UNTOUCHED; else if (hw->z > para->palm_min_z) /* z too large -> probably palm */ - finger = FALSE; + finger = FS_UNTOUCHED; else if (hw->fingerWidth > para->palm_min_width) /* finger width too large -> probably palm */ - finger = FALSE; + finger = FS_UNTOUCHED; } priv->prev_z = hw->z; if (priv->palm) - finger = FALSE; + finger = FS_UNTOUCHED; return finger; } |