[PATCH synaptics 1/2] Reset all hardware state on DEVICE_OFF (#49161)

Peter Hutterer peter.hutterer at who-t.net
Sun Apr 29 20:21:22 PDT 2012


Reset all state on DeviceOff to avoid stuck buttons on resume.

X.Org Bug 49161 <http://bugs.freedesktop.org/show_bug.cgi?id=49161>

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c |   36 +++++++++++++++++++++++++++++++++++-
 src/synproto.c  |   23 +++++++++++++++++++++++
 src/synproto.h  |    1 +
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index 51ecda5..935650d 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1074,6 +1074,39 @@ DeviceOn(DeviceIntPtr dev)
     return Success;
 }
 
+static void
+SynapticsReset(SynapticsPrivate *priv)
+{
+    SynapticsResetHwState(priv->hwState);
+    SynapticsResetHwState(priv->local_hw_state);
+    SynapticsResetHwState(priv->old_hw_state);
+    SynapticsResetHwState(priv->comm.hwState);
+
+    memset(priv->move_hist, 0, sizeof(priv->move_hist));
+    priv->hyst_center_x = 0;
+    priv->hyst_center_y = 0;
+    memset(&priv->scroll, 0, sizeof(priv->scroll));
+    priv->count_packet_finger = 0;
+    priv->finger_state = FS_UNTOUCHED;
+    priv->last_motion_millis = 0;
+    priv->tap_state = TS_START;
+    priv->tap_button = 0;
+    priv->tap_button_state = TBS_BUTTON_UP;
+    priv->moving_state = MS_FALSE;
+    priv->vert_scroll_edge_on = FALSE;
+    priv->horiz_scroll_edge_on = FALSE;
+    priv->vert_scroll_twofinger_on = FALSE;
+    priv->horiz_scroll_twofinger_on = FALSE;
+    priv->circ_scroll_on = FALSE;
+    priv->circ_scroll_vert = FALSE;
+    priv->mid_emu_state = MBE_OFF;
+    priv->nextRepeat = 0;
+    priv->lastButtons = 0;
+    priv->prev_z = 0;
+    priv->prevFingers = 0;
+}
+
+
 static Bool
 DeviceOff(DeviceIntPtr dev)
 {
@@ -1086,7 +1119,8 @@ DeviceOff(DeviceIntPtr dev)
     if (pInfo->fd != -1) {
 	TimerCancel(priv->timer);
 	xf86RemoveEnabledDevice(pInfo);
-        SynapticsResetTouchHwState(priv->hwState);
+	SynapticsReset(priv);
+
         if (priv->proto_ops->DeviceOffHook &&
             !priv->proto_ops->DeviceOffHook(pInfo))
             rc = !Success;
diff --git a/src/synproto.c b/src/synproto.c
index 4f44f4d..cf54c4d 100644
--- a/src/synproto.c
+++ b/src/synproto.c
@@ -134,6 +134,29 @@ SynapticsCopyHwState(struct SynapticsHwState *dst,
 }
 
 void
+SynapticsResetHwState(struct SynapticsHwState *hw)
+{
+    hw->millis = 0;
+    hw->x = 0;
+    hw->y = 0;
+    hw->z = 0;
+    hw->cumulative_dx = 0;
+    hw->cumulative_dy = 0;
+    hw->numFingers = 0;
+    hw->fingerWidth = 0;
+
+    hw->left = 0;
+    hw->right = 0;
+    hw->up = 0;
+    hw->down = 0;
+
+    hw->middle = 0;
+    memset(hw->multi, 0, sizeof(hw->multi));
+
+    SynapticsResetTouchHwState(hw);
+}
+
+void
 SynapticsResetTouchHwState(struct SynapticsHwState *hw)
 {
 #ifdef HAVE_MULTITOUCH
diff --git a/src/synproto.h b/src/synproto.h
index e16aeb0..7f80bcd 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -119,6 +119,7 @@ extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate *priv);
 extern void SynapticsHwStateFree(struct SynapticsHwState **hw);
 extern void SynapticsCopyHwState(struct SynapticsHwState *dst,
                                  const struct SynapticsHwState *src);
+extern void SynapticsResetHwState(struct SynapticsHwState *hw);
 extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw);
 
 extern Bool SynapticsIsSoftButtonAreasValid(int *values);
-- 
1.7.10



More information about the xorg-devel mailing list