summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-02-06 11:32:56 -0800
committerChase Douglas <chase.douglas@canonical.com>2012-02-11 18:53:28 +0100
commitc5d453a17f2f313567d9b23f745075ad4140b6f5 (patch)
tree997697434451f5ca4258ad61dfbe6879345c7918
parent31d7ce941b10b9afd426a2cbb4a9f5cb60df687d (diff)
Handle clickpad press
For click action, touch counts are shifted by one. When pressing the left button with one touch, click action one is fired as normal. However, when clicking with two touches, click action one is still fired. This is because the user often uses one touch to position and another to click, without lifting the positioning touch. When clicking with three touches, click action two is fired, and four touches fires click action three. Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r--src/synaptics.c103
-rw-r--r--src/synapticsstr.h4
2 files changed, 75 insertions, 32 deletions
diff --git a/src/synaptics.c b/src/synaptics.c
index 7c5e5fc..45c5289 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1561,6 +1561,36 @@ SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
}
static void
+handle_clickfinger(SynapticsParameters *para, struct SynapticsHwState *hw)
+{
+ int action = 0;
+ switch(hw->numFingers){
+ case 1:
+ action = para->click_action[F1_CLICK1];
+ break;
+ case 2:
+ action = para->click_action[F2_CLICK1];
+ break;
+ case 3:
+ action = para->click_action[F3_CLICK1];
+ break;
+ }
+ switch(action){
+ case 1:
+ hw->left = 1;
+ break;
+ case 2:
+ hw->left = 0;
+ hw->middle = 1;
+ break;
+ case 3:
+ hw->left = 0;
+ hw->right = 1;
+ break;
+ }
+}
+
+static void
SelectTapButton(SynapticsPrivate *priv, edge_type edge)
{
TapEvent tap;
@@ -1682,6 +1712,8 @@ GetTimeOut(SynapticsPrivate *priv)
return para->tap_time_2;
case TS_4:
return para->locked_drag_time;
+ case TS_CLICKPAD_PRESS:
+ return para->clickpad_timeout;
default:
return -1; /* No timeout */
}
@@ -1729,6 +1761,15 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
SetTapState(priv, TS_1, now);
break;
case TS_1:
+ if (para->clickpad) {
+ if (hw->right || hw->middle) {
+ SetTapState(priv, TS_CLICKPAD_MOVE, now);
+ } else if (hw->left) {
+ is_timeout = FALSE;
+ SetTapState(priv, TS_CLICKPAD_PRESS, now);
+ goto restart;
+ }
+ }
if (move) {
SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
SetTapState(priv, TS_MOVE, now);
@@ -1752,6 +1793,11 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
}
break;
case TS_MOVE:
+ if (para->clickpad && hw->left) {
+ is_timeout = FALSE;
+ SetTapState(priv, TS_CLICKPAD_PRESS, now);
+ goto restart;
+ }
if (move && priv->moving_state == MS_TRACKSTICK) {
SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
}
@@ -1834,6 +1880,30 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
SetTapState(priv, TS_START, now);
}
break;
+ case TS_CLICKPAD_PRESS:
+ if (hw->numFingers > 1)
+ hw->numFingers--;
+ if (hw->right || hw->middle) {
+ SetTapState(priv, TS_CLICKPAD_MOVE, now);
+ goto restart;
+ }
+ if (!hw->left) {
+ handle_clickfinger(para, hw);
+ priv->tap_button_state = TBS_BUTTON_DOWN_UP;
+ SetTapState(priv, TS_1, now);
+ } else if (move || is_timeout) {
+ SetTapState(priv, TS_CLICKPAD_MOVE, now);
+ goto restart;
+ } else
+ hw->left = 0;
+ break;
+ case TS_CLICKPAD_MOVE:
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ if (!hw->left && !hw->right && !hw->middle) {
+ SetMovingState(priv, MS_FALSE, now);
+ SetTapState(priv, TS_MOVE, now);
+ }
+ break;
}
timeout = GetTimeOut(priv);
@@ -2004,6 +2074,7 @@ ComputeDeltas(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
case TS_1:
case TS_3:
case TS_5:
+ case TS_CLICKPAD_PRESS:
moving_state = MS_TOUCHPAD_RELATIVE;
break;
default:
@@ -2358,36 +2429,6 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
return delay;
}
-static void
-handle_clickfinger(SynapticsParameters *para, struct SynapticsHwState *hw)
-{
- int action = 0;
- switch(hw->numFingers){
- case 1:
- action = para->click_action[F1_CLICK1];
- break;
- case 2:
- action = para->click_action[F2_CLICK1];
- break;
- case 3:
- action = para->click_action[F3_CLICK1];
- break;
- }
- switch(action){
- case 1:
- hw->left = 1;
- break;
- case 2:
- hw->left = 0;
- hw->middle = 1;
- break;
- case 3:
- hw->left = 0;
- hw->right = 1;
- break;
- }
-}
-
/* Update the hardware state in shared memory. This is read-only these days,
* nothing in the driver reads back from SHM. SHM configuration is a thing of the past.
@@ -2470,7 +2511,7 @@ update_hw_button_state(const InputInfoPtr pInfo, struct SynapticsHwState *hw,
hw->middle |= HandleMidButtonEmulation(priv, hw, now, delay);
/* Fingers emulate other buttons */
- if(hw->left && hw->numFingers >= 1){
+ if(!para->clickpad && hw->left && hw->numFingers >= 1){
handle_clickfinger(para, hw);
}
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 140bcf0..1ea09a0 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -99,7 +99,9 @@ enum TapState {
TS_3, /* After second touch */
TS_DRAG, /* Pointer drag enabled */
TS_4, /* After release when "locked drags" enabled */
- TS_5 /* After touch when "locked drags" enabled */
+ TS_5, /* After touch when "locked drags" enabled */
+ TS_CLICKPAD_PRESS, /* After left button press, when clickpad */
+ TS_CLICKPAD_MOVE, /* After left button press and move, when clickpad */
};
enum TapButtonState {