[PATCH 4/8] evdev-touchpad: Don't push FSM events from process_absolute

Alexander E. Patrakov patrakov at gmail.com
Mon Aug 5 03:34:33 PDT 2013


From: "Alexander E. Patrakov" <patrakov at gmail.com>

In the multitouch case on Sony trackpads, not all touches are valid.
However, the information needed to filter out invalid touches is
consistent only on the SYN_REPORT event.
---
 src/evdev-touchpad.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/evdev-touchpad.c b/src/evdev-touchpad.c
index aafa705..a9b21b8 100644
--- a/src/evdev-touchpad.c
+++ b/src/evdev-touchpad.c
@@ -122,6 +122,7 @@ struct touchpad_dispatch {
 	} hw_abs;
 
 	bool has_moved;
+	uint16_t touch_state;
 
 	int has_pressure;
 	struct {
@@ -416,6 +417,18 @@ touchpad_update_state(struct touchpad_dispatch *touchpad, uint32_t time)
 	int center_x, center_y;
 	double dx = 0.0, dy = 0.0;
 
+	/* For multitouch case, this will be a bitmask */
+	uint16_t touch_state = touchpad->hw_abs.is_pressed;
+
+	if (touch_state && !touchpad->touch_state)
+		push_fsm_event(touchpad, FSM_EVENT_TOUCH);
+	if (!touch_state && touchpad->touch_state) {
+		push_fsm_event(touchpad, FSM_EVENT_RELEASE);
+		touchpad->has_moved = false;
+	}
+
+	touchpad->touch_state = touch_state;
+
 	if (touchpad->last_finger_state != touchpad->finger_state) {
 		touchpad->motion_count = 0;
 		touchpad->hw_abs.x_valid = touchpad->hw_abs.y_valid = false;
@@ -498,19 +511,14 @@ static void
 on_touch(struct touchpad_dispatch *touchpad)
 {
 	touchpad->hw_abs.is_pressed = true;
-
-	push_fsm_event(touchpad, FSM_EVENT_TOUCH);
 }
 
 static void
 on_release(struct touchpad_dispatch *touchpad)
 {
-
-	touchpad->has_moved = touchpad->hw_abs.is_pressed = false;
-	touchpad->hw_abs.x_valid = touchpad->hw_abs.y_valid = false;
+	touchpad->hw_abs.is_pressed = false;
 	touchpad->hw_abs.is_moving = false;
-
-	push_fsm_event(touchpad, FSM_EVENT_RELEASE);
+	touchpad->hw_abs.x_valid = touchpad->hw_abs.y_valid = false;
 }
 
 static inline void
@@ -721,6 +729,7 @@ touchpad_init(struct touchpad_dispatch *touchpad,
 	touchpad->hw_abs.is_pressed = false;
 	touchpad->hw_abs.is_moving = false;
 	touchpad->has_moved = false;
+	touchpad->touch_state = 0;
 
 	touchpad->last_finger_state = 0;
 	touchpad->finger_state = 0;
-- 
1.8.3.2



More information about the wayland-devel mailing list