[PATCH libinput 04/20] touchpad: don't allow tapping while any button is down
From: Peter Hutterer peter.hutte...@who-t.net Immediately set the state to DEAD, waiting for the tap release to go back to idle. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Hans de Goede hdego...@redhat.com --- src/evdev-mt-touchpad-tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index bcc5700..863e004 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -508,7 +508,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time) struct tp_touch *t; int filter_motion = 0; - if (tp-queued TOUCHPAD_EVENT_BUTTON_PRESS) + if (tp-buttons.state != 0) tp_tap_handle_event(tp, TAP_EVENT_BUTTON, time); tp_for_each_touch(tp, t) { -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 11/20] touchpad: Rework is_pointer handling
Move scanning for a suitable touch to be the pointer to tp_process_state and take tp_button_touch_active into account. Note this adds a tp_touch_active helper since we want to do the same checks in other places too (ie to see if a finger should count for 2 finger scrolling). Signed-off-by: Hans de Goede hdego...@redhat.com Acked-by: Peter Hutterer peter.hutte...@who-t.net --- src/evdev-mt-touchpad.c | 47 +++ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 9df4a78..b671211 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -152,8 +152,6 @@ tp_get_touch(struct tp_dispatch *tp, unsigned int slot) static inline void tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t) { - struct tp_touch *tmp; - if (t-state != TOUCH_UPDATE) { tp_motion_history_reset(t); t-dirty = true; @@ -161,15 +159,6 @@ tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t) tp-nfingers_down++; assert(tp-nfingers_down = 1); tp-queued |= TOUCHPAD_EVENT_MOTION; - - tp_for_each_touch(tp, tmp) { - if (tmp-is_pointer) - break; - } - - if (!tmp-is_pointer) { - t-is_pointer = true; - } } } @@ -341,7 +330,6 @@ static void tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t) { unsigned int xdist, ydist; - struct tp_touch *tmp; if (!t-pinned.is_pinned) return; @@ -349,19 +337,9 @@ tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t) xdist = abs(t-x - t-pinned.center_x); ydist = abs(t-y - t-pinned.center_y); - if (xdist * xdist + ydist * ydist + if (xdist * xdist + ydist * ydist = tp-buttons.motion_dist * tp-buttons.motion_dist) - return; - - t-pinned.is_pinned = false; - - tp_for_each_touch(tp, tmp) { - if (tmp-is_pointer) - break; - } - - if (t-state != TOUCH_END !tmp-is_pointer) - t-is_pointer = true; + t-pinned.is_pinned = false; } static void @@ -377,6 +355,13 @@ tp_pin_fingers(struct tp_dispatch *tp) } } +static int +tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t) +{ + return (t-state == TOUCH_BEGIN || t-state == TOUCH_UPDATE) + !t-pinned.is_pinned tp_button_touch_active(tp, t); +} + static void tp_process_state(struct tp_dispatch *tp, uint32_t time) { @@ -409,6 +394,20 @@ tp_process_state(struct tp_dispatch *tp, uint32_t time) if ((tp-queued TOUCHPAD_EVENT_BUTTON_PRESS) !tp-buttons.has_buttons) tp_pin_fingers(tp); + + /* If we don't have a touch as pointer find a suitable one */ + tp_for_each_touch(tp, t) { + if (t-is_pointer) + break; + } + if (!t-is_pointer) { + tp_for_each_touch(tp, t) { + if (tp_touch_active(tp, t)) { + t-is_pointer = true; + break; + } + } + } } static void -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 07/20] touchpad: save the active clickfinger button
From: Peter Hutterer peter.hutte...@who-t.net To avoid having a button left press and a button right release if the number of fingers changes. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Hans de Goede hdego...@redhat.com --- src/evdev-mt-touchpad-buttons.c | 22 +- src/evdev-mt-touchpad.h | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 8946fc7..c3c97b0 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -75,23 +75,27 @@ tp_post_clickfinger_buttons(struct tp_dispatch *tp, uint32_t time) if (current == old) return 0; - switch (tp-nfingers_down) { + if (current) { + switch (tp-nfingers_down) { case 1: button = BTN_LEFT; break; case 2: button = BTN_RIGHT; break; case 3: button = BTN_MIDDLE; break; default: return 0; - } - - if (current) + } + tp-buttons.active = button; state = LIBINPUT_POINTER_BUTTON_STATE_PRESSED; - else + } else { + button = tp-buttons.active; + tp-buttons.active = 0; state = LIBINPUT_POINTER_BUTTON_STATE_RELEASED; + } - pointer_notify_button(tp-device-base, - time, - button, - state); + if (button) + pointer_notify_button(tp-device-base, + time, + button, + state); return 1; } diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index d84c9e8..85cf7e5 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -132,6 +132,7 @@ struct tp_dispatch { uint32_t state; uint32_t old_state; uint32_t motion_dist; /* for pinned touches */ + unsigned int active;/* currently active button, for release event */ } buttons; /* physical buttons */ struct { -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 13/20] touchpad: Use INPUT_PROP_BUTTONPAD instead of checking for buttons
And warn if INPUT_PROP_BUTTONPAD mismatches right/middle buttons presence. Signed-off-by: Hans de Goede hdego...@redhat.com Acked-by: Peter Hutterer peter.hutte...@who-t.net --- src/evdev-mt-touchpad-buttons.c | 34 ++ src/evdev-mt-touchpad.c | 4 ++-- src/evdev-mt-touchpad.h | 7 +++ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index e789a87..ec36280 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -410,9 +410,17 @@ tp_init_buttons(struct tp_dispatch *tp, int width, height; double diagonal; + tp-buttons.is_clickpad = libevdev_has_property(device-evdev, +INPUT_PROP_BUTTONPAD); + if (libevdev_has_event_code(device-evdev, EV_KEY, BTN_MIDDLE) || - libevdev_has_event_code(device-evdev, EV_KEY, BTN_RIGHT)) - tp-buttons.has_buttons = true; + libevdev_has_event_code(device-evdev, EV_KEY, BTN_RIGHT)) { + if (tp-buttons.is_clickpad) + log_bug(clickpad advertising right button (kernel bug?)\n); + } else { + if (!tp-buttons.is_clickpad) + log_bug(non clickpad without right button (kernel bug)?\n); + } width = abs(device-abs.max_x - device-abs.min_x); height = abs(device-abs.max_y - device-abs.min_y); @@ -423,10 +431,7 @@ tp_init_buttons(struct tp_dispatch *tp, if (libevdev_get_id_vendor(device-evdev) == 0x5ac) /* Apple */ tp-buttons.use_clickfinger = true; - tp-buttons.use_softbuttons = !tp-buttons.use_clickfinger - !tp-buttons.has_buttons; - - if (tp-buttons.use_softbuttons) { + if (tp-buttons.is_clickpad !tp-buttons.use_clickfinger) { tp-buttons.area.top_edge = height * .8 + device-abs.min_y; tp-buttons.area.rightbutton_left_edge = width/2 + device-abs.min_x; tp-buttons.timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); @@ -585,21 +590,18 @@ tp_post_softbutton_buttons(struct tp_dispatch *tp, uint32_t time) int tp_post_button_events(struct tp_dispatch *tp, uint32_t time) { - int rc; - if ((tp-queued (TOUCHPAD_EVENT_BUTTON_PRESS|TOUCHPAD_EVENT_BUTTON_RELEASE)) == 0) return 0; - if (tp-buttons.has_buttons) - rc = tp_post_physical_buttons(tp, time); - else if (tp-buttons.use_clickfinger) - rc = tp_post_clickfinger_buttons(tp, time); - else if (tp-buttons.use_softbuttons) - rc = tp_post_softbutton_buttons(tp, time); - + if (tp-buttons.is_clickpad) { + if (tp-buttons.use_clickfinger) + return tp_post_clickfinger_buttons(tp, time); + else + return tp_post_softbutton_buttons(tp, time); + } - return rc; + return tp_post_physical_buttons(tp, time); } int diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index b671211..910bd2a 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -392,7 +392,7 @@ tp_process_state(struct tp_dispatch *tp, uint32_t time) * to allow drag and drop. */ if ((tp-queued TOUCHPAD_EVENT_BUTTON_PRESS) - !tp-buttons.has_buttons) + tp-buttons.is_clickpad) tp_pin_fingers(tp); /* If we don't have a touch as pointer find a suitable one */ @@ -496,7 +496,7 @@ static int tp_post_scroll_events(struct tp_dispatch *tp, uint32_t time) { /* don't scroll if a clickpad is held down */ - if (!tp-buttons.has_buttons + if (tp-buttons.is_buttonpad (tp-buttons.state || tp-buttons.old_state)) return 0; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 04da6a6..5cb9ae2 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -154,19 +154,18 @@ struct tp_dispatch { } accel; struct { - bool has_buttons; /* true for physical LMR buttons */ + bool is_clickpad; /* true for clickpads */ bool use_clickfinger; /* number of fingers decides button number */ - bool use_softbuttons; /* use software-button area */ uint32_t state; uint32_t old_state; uint32_t motion_dist; /* for pinned touches */ unsigned int active;/* currently active button, for release event */ - /* Only used if has_buttons is false. The software button area is always + /* Only used for clickpads. The software button area is always * a horizontal strip across
[PATCH libinput 05/20] touchpad: move button-related code into a separate file
From: Peter Hutterer peter.hutte...@who-t.net This is about to become more complicated with the support for software button areas. Move it to a separate file to have it logically grouped together. No functional changes. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Hans de Goede hdego...@redhat.com --- src/Makefile.am | 1 + src/evdev-mt-touchpad-buttons.c | 146 src/evdev-mt-touchpad.c | 102 ++-- src/evdev-mt-touchpad.h | 11 +++ 4 files changed, 162 insertions(+), 98 deletions(-) create mode 100644 src/evdev-mt-touchpad-buttons.c diff --git a/src/Makefile.am b/src/Makefile.am index 579ed25..ffa6a29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ libinput_la_SOURCES = \ evdev-mt-touchpad.c \ evdev-mt-touchpad.h \ evdev-mt-touchpad-tap.c \ + evdev-mt-touchpad-buttons.c \ evdev-touchpad.c\ filter.c\ filter.h\ diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c new file mode 100644 index 000..8946fc7 --- /dev/null +++ b/src/evdev-mt-touchpad-buttons.c @@ -0,0 +1,146 @@ +/* + * Copyright © 2014 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the copyright holders not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. The copyright holders make + * no representations about the suitability of this software for any + * purpose. It is provided as is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include math.h + +#include evdev-mt-touchpad.h + +#define DEFAULT_BUTTON_MOTION_THRESHOLD 0.02 /* in percent of size */ + +int +tp_process_button(struct tp_dispatch *tp, + const struct input_event *e, + uint32_t time) +{ + uint32_t mask = 1 (e-code - BTN_LEFT); + if (e-value) { + tp-buttons.state |= mask; + tp-queued |= TOUCHPAD_EVENT_BUTTON_PRESS; + } else { + tp-buttons.state = ~mask; + tp-queued |= TOUCHPAD_EVENT_BUTTON_RELEASE; + } + + return 0; +} + +int +tp_init_buttons(struct tp_dispatch *tp, + struct evdev_device *device) +{ + int width, height; + double diagonal; + + if (libevdev_has_event_code(device-evdev, EV_KEY, BTN_MIDDLE) || + libevdev_has_event_code(device-evdev, EV_KEY, BTN_RIGHT)) + tp-buttons.has_buttons = true; + + width = abs(device-abs.max_x - device-abs.min_x); + height = abs(device-abs.max_y - device-abs.min_y); + diagonal = sqrt(width*width + height*height); + + tp-buttons.motion_dist = diagonal * DEFAULT_BUTTON_MOTION_THRESHOLD; + + return 0; +} + +static int +tp_post_clickfinger_buttons(struct tp_dispatch *tp, uint32_t time) +{ + uint32_t current, old, button; + enum libinput_pointer_button_state state; + + current = tp-buttons.state; + old = tp-buttons.old_state; + + if (current == old) + return 0; + + switch (tp-nfingers_down) { + case 1: button = BTN_LEFT; break; + case 2: button = BTN_RIGHT; break; + case 3: button = BTN_MIDDLE; break; + default: + return 0; + } + + if (current) + state = LIBINPUT_POINTER_BUTTON_STATE_PRESSED; + else + state = LIBINPUT_POINTER_BUTTON_STATE_RELEASED; + + pointer_notify_button(tp-device-base, + time, + button, + state); + return 1; +} + +static int +tp_post_physical_buttons(struct tp_dispatch *tp, uint32_t time) +{ + uint32_t current, old, button; + + current = tp-buttons.state; + old = tp-buttons.old_state; + button = BTN_LEFT; + + while (current || old) { + enum libinput_pointer_button_state state; + + if ((current 0x1
[PATCH libinput 06/20] doc: add state machine SVG to EXTRA_DIST
From: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Hans de Goede hdego...@redhat.com --- doc/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 31b673b..75fa98a 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,3 +1,5 @@ +EXTRA_DIST = touchpad-tap-state-machine.svg + if HAVE_DOXYGEN noinst_DATA = html/index.html @@ -12,7 +14,7 @@ clean-local: $(AM_V_at)rm -rf html doc_src= $(shell find html -type f -printf html/%P\n 2/dev/null) -EXTRA_DIST = $(builddir)/html/index.html $(doc_src) +EXTRA_DIST += $(builddir)/html/index.html $(doc_src) endif -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 17/20] touchpad: Ignore fingers in button area for 2 finger scroll
Signed-off-by: Hans de Goede hdego...@redhat.com Acked-by: Peter Hutterer peter.hutte...@who-t.net --- src/evdev-mt-touchpad.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 910bd2a..7333ec9 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -442,7 +442,7 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, uint32_t time) double tmpx, tmpy; tp_for_each_touch(tp, t) { - if (t-dirty) { + if (tp_touch_active(tp, t) t-dirty) { nchanged++; tp_get_delta(t, tmpx, tmpy); @@ -495,12 +495,21 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, uint32_t time) static int tp_post_scroll_events(struct tp_dispatch *tp, uint32_t time) { + struct tp_touch *t; + int nfingers_down = 0; + /* don't scroll if a clickpad is held down */ if (tp-buttons.is_buttonpad (tp-buttons.state || tp-buttons.old_state)) return 0; - if (tp-nfingers_down != 2) { + /* Only count active touches for 2 finger scrolling */ + tp_for_each_touch(tp, t) { + if (tp_touch_active(tp, t)) + nfingers_down++; + } + + if (nfingers_down != 2) { /* terminate scrolling with a zero scroll event to notify * caller that it really ended now */ if (tp-scroll.state != SCROLL_STATE_NONE) { -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 19/20] touchpad: handle_timeouts: Remove unused return value
Signed-off-by: Hans de Goede hdego...@redhat.com Acked-by: Peter Hutterer peter.hutte...@who-t.net --- src/evdev-mt-touchpad-buttons.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 3b8b07b..c40b05c 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -346,22 +346,17 @@ tp_button_handle_state(struct tp_dispatch *tp, uint32_t time) return 0; } -static int +static void tp_button_handle_timeout(struct tp_dispatch *tp, uint32_t now) { struct tp_touch *t; - uint32_t min_timeout = INT_MAX; tp_for_each_touch(tp, t) { if (t-button.timeout != 0 t-button.timeout = now) { tp_button_clear_timer(tp, t); tp_button_handle_event(tp, t, BUTTON_EVENT_TIMEOUT, now); } - if (t-button.timeout != 0) - min_timeout = min(t-button.timeout, min_timeout); } - - return min_timeout == INT_MAX ? 0 : min_timeout; } int -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 00/20] clickpad-improvements v2
Hi All, Here is my improved version of Peter's clickpad-improvements patch-set. Changes in v2: * after a click, lock the finger to its current position Pin all fingers until they move more then the threshold in * touchpad: add clickpad-style software buttons Simplify the state machine used in * touchpad: Add tp_button_touch_active function New patches / improvements on to of Peter's original series Please review. Regards, Hans p.s. Peter is on vacation till April 22nd, this respin of his series is posted with his permission. ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 12/20] Add a log_bug macro
For logging when things happen which should not happen. We may want to do something more fancy in the future but for now this suffices. Modelled after log_bug in libevdev. Signed-off-by: Hans de Goede hdego...@redhat.com Acked-by: Peter Hutterer peter.hutte...@who-t.net --- src/libinput-private.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libinput-private.h b/src/libinput-private.h index 21627b0..f778f6e 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -80,6 +80,7 @@ struct libinput_source; #define log_debug(...) log_msg(LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__) #define log_info(...) log_msg(LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__) #define log_error(...) log_msg(LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__) +#define log_bug(...) log_msg(LIBINPUT_LOG_PRIORITY_ERROR, BUG: __VA_ARGS__) void log_msg(enum libinput_log_priority priority, const char *format, ...); -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 01/20] touchpad: set ntouches for single-touch pads depending on key bits
From: Peter Hutterer peter.hutte...@who-t.net A single-touch touchpad that provides BTN_TOOL_TRIPLETAP has 3 touches, etc. There aren't a lot of these out there, but some touchpads don't have slots but do provide two- or three-finger detection. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Hans de Goede hdego...@redhat.com --- src/evdev-mt-touchpad.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index bbbd8f3..8021db2 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -715,9 +715,29 @@ tp_init_slots(struct tp_dispatch *tp, tp-slot = absinfo-value; tp-has_mt = true; } else { - tp-ntouches = 5; /* FIXME: based on DOUBLETAP, etc. */ + struct map { + unsigned int code; + int ntouches; + } max_touches[] = { + { BTN_TOOL_QUINTTAP, 5 }, + { BTN_TOOL_QUADTAP, 4 }, + { BTN_TOOL_TRIPLETAP, 3 }, + { BTN_TOOL_DOUBLETAP, 2 }, + }; + struct map *m; + tp-slot = 0; tp-has_mt = false; + tp-ntouches = 1; + + ARRAY_FOR_EACH(max_touches, m) { + if (libevdev_has_event_code(device-evdev, + EV_KEY, + m-code)) { + tp-ntouches = m-ntouches; + break; + } + } } tp-touches = calloc(tp-ntouches, sizeof(struct tp_touch)); -- 1.9.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH libinput 09/20] touchpad: add clickpad-style software buttons
From: Peter Hutterer peter.hutte...@who-t.net This is a slightly fancier implementation than the simplest model and ported over from libtouchpad. It implements a state machine for the software buttons with left and right buttons currently implemented. Buttons are oriented left-to-right, in a horizontal bar. No random button placement allowed. In general, the procedure is: - if a finger sets down in the left button area, a click is a left click - if a finger sets down in the right button area, a click is a right click - if a finger leaves the button area, a click is a left click - if a finger starts outside the button area, a click is a left click Two timeouts are used to handle buttons more smoothly: - if a finger sets down in a button area but immediately moves over to a different area, that area takes effect on a click. - if a finger leaves a button area and immediately clicks or moves back into the area, the button still takes effect on a click. - if a finger changes between areas and stays there for a timeout, that area takes effect on a click. HdG: -Simplified the state machine a bit -Renamed the button area states to BOTTOM_foo to make it easier to later add support for a top button area such as can be found one the Thinkpad [2-5]40 series. -Init area.top_edge to INT_MAX in the non soft button case to make the entire state machine a nop in that case Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Signed-off-by: Hans de Goede hdego...@redhat.com --- doc/Makefile.am | 2 +- doc/touchpad-softbutton-state-machine.svg | 173 src/evdev-mt-touchpad-buttons.c | 453 +- src/evdev-mt-touchpad.c | 15 + src/evdev-mt-touchpad.h | 48 src/libinput.h| 40 +++ 6 files changed, 728 insertions(+), 3 deletions(-) create mode 100644 doc/touchpad-softbutton-state-machine.svg diff --git a/doc/Makefile.am b/doc/Makefile.am index 75fa98a..a33638d 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = touchpad-tap-state-machine.svg +EXTRA_DIST = touchpad-tap-state-machine.svg touchpad-softbutton-state-machine.svg if HAVE_DOXYGEN diff --git a/doc/touchpad-softbutton-state-machine.svg b/doc/touchpad-softbutton-state-machine.svg new file mode 100644 index 000..1838e35 --- /dev/null +++ b/doc/touchpad-softbutton-state-machine.svg @@ -0,0 +1,173 @@ +svg xmlns=http://www.w3.org/2000/svg; xmlns:xlink=http://www.w3.org/1999/xlink; width=516px height=759px version=1.1 +defs/ +g transform=translate(0.5,0.5) +path d=M 190 352 L 216 352 fill=none stroke=#00 stroke-miterlimit=10 pointer-events=none/ +path d=M 221 352 L 214 355 L 216 352 L 214 348 Z fill=#00 stroke=#00 stroke-miterlimit=10 pointer-events=none/ +ellipse cx=113 cy=61 rx=49.5 ry=30 fill=#ff stroke=#00 stroke-width=2 pointer-events=none/ +g fill=#00 font-family=Helvetica text-anchor=middle font-size=12px +text x=113 y=51 +NONE/text +text x=113 y=65 +on-entry:/text +text x=113 y=79 +curr = none/text +/g +rect x=40 y=301 width=150 height=101 rx=6 ry=6 fill=#ccffcc stroke=#00 stroke-width=2 pointer-events=none/ +g fill=#00 font-family=Helvetica text-anchor=middle font-size=12px +text x=115 y=335 +BOTTOM_NEW/text +text x=115 y=349 +on-entry:/text +text x=115 y=363 +curr = button/text +text x=115 y=377 +start inner timeout/text +/g +rect x=351 y=303 width=130 height=100 rx=6 ry=6 fill=#ccffcc stroke=#00 stroke-width=2 pointer-events=none/ +g fill=#00 font-family=Helvetica text-anchor=middle font-size=12px +text x=416 y=343 +AREA/text +text x=416 y=357 +on-entry:/text +text x=416 y=371 +curr =area/text +/g +path d=M 243 327 C 245 324 249 322 254 322 L 287 322 C 292 322 296 324 298 327 L 318 350 C 319 351 319 353 318 354 L 298 377 C 296 380 292 382 287 382 L 254 382 C 249 382 245 380 243 377 L 223 354 C 222 353 222 351 223 350 L 243 327 Z fill=#ffd966 stroke=#00 stroke-width=2 stroke-miterlimit=10 pointer-events=none/ +g fill=#00 font-family=Helvetica text-anchor=middle font-size=12px +text x=271 y=349 +finger in/text +text x=271 y=363 +area/text +/g +rect x=50 y=623 width=130 height=100 rx=6 ry=6 fill=#ccffcc stroke=#00 stroke-width=2 pointer-events=none/ +g fill=#00 font-family=Helvetica text-anchor=middle font-size=12px +text x=115 y=677 +BOTTOM/text +/g +path d=M 243 6 C 245 3 249 1 254 1 L 287 1 C 292 1 296 3 298 6 L 318 29 C 319 31 319 32 318 33 L 298 56 C 296 59 292 61 287 61 L 254 61 C 249 61 245 59 243 56 L 223 33 C 222 32 222 31 223 29 L 243 6 Z fill=#ffd966 stroke=#00 stroke-width=2 stroke-miterlimit=10 pointer-events=none/ +g fill=#00 font-family=Helvetica text-anchor=middle font-size=12px +text x=271 y=28 +finger/text +text x=271 y=42 +up/text +/g +path d=M 22 482 C 25 479 29 477 33 477 L 67 477 C 71 477 75 479 78 482 L 98 505 C 99 506 99 508 98 509 L 78 532 C 75 535 71 537
Re: [PATCH libinput 08/20] touchpad: Only enable clickfingers on Apple touchpads
Hi, On 04/15/2014 03:44 PM, Daniel Stone wrote: Hi, On 15 April 2014 13:28, Hans de Goede hdego...@redhat.com wrote: Apple touchpads don't have visible markings for the software button areas that almost all other vendors use. OS X provides clickfinger behaviour instead, where a click with two fingers on the touchpad generate a right button click. Use that same behaviour in libinput. For all other touchpads, use the software button areas introduced in a follow-up commit. Some of the early Samsung Chromebooks had an Apple-style setup: it would be good to expose this as a tuneable so it could be set through configuration. Agreed, but that will have to wait till we have some sort of config framework in place. Creating a config framework is on my / Peter's TODO (who ever gets around to it first). Regards, Hans ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH libinput 0/9] Improvements for clickpad touchpads
Hi Peter, So as you requested I've been looking at your wip/clickpad-improvements branch. I've been mostly reading the code / patches and here is a long list of comments : 1) I like the state-machine concept, and having a diagram. I think this is a good way to deal with this, otherwise we will end up adding layers of kludges until we've something which no one understands and which works most of the time 2) You only handle 2 buttons areas left and right, this won't work for the Thinkpad *40's series. I've been thinking about a way to make your state-machine work with more buttons without exploding the diagram / amount of states. I think that we need to define BUTTON_EVENT_IN_BUTTON0 .. BUTTON_EVENT_IN_BUTTON7, store one of these in t-button.current_button and then have states like BUTTON_STATE_NEW and events / transition conditions like finger in other button area. Then in the switch cases in the statemachine where we now check for the other button, check for all buttons, and put an if there to turn the current button into a break, ie in tp_button_left_handle_event have: switch(event) { case BUTTON_EVENT_IN_BUTTON0: case BUTTON_EVENT_IN_BUTTON1: case BUTTON_EVENT_IN_BUTTON2: case BUTTON_EVENT_IN_BUTTON3: case BUTTON_EVENT_IN_BUTTON4: case BUTTON_EVENT_IN_BUTTON5: case BUTTON_EVENT_IN_BUTTON6: case BUTTON_EVENT_IN_BUTTON7: if (event == t-button.current_button) break; t-button.state = BUTTON_STATE_TO_OTHER_BUTTON; tp_button_set_leave_timer(tp, t); break; This will significantly simplify the state-machine while allowing more buttons, ie BUTTON_STATE_LEFT_TO_RIGHT and BUTTON_STATE_RIGHT_TO_LEFT would become a single BUTTON_STATE_TO_OTHER_BUTTON state, and likewise BUTTON_STATE_LEFT_NEW and BUTTON_STATE_RIGHT_NEW would both simply become BUTTON_STATE_NEW, etc. I can rework the state machine + code to work like this if you agree that this is a good idea. 3) You don't seem to do anything with INPUT_PROP_BUTTONPAD, I'm not sure that is a good idea 4) In pin finger you assume that the finger which is the closest to the bottom edge is the one doing the clicking, this will not work on the Thinkpad *40 series. IE there may be a palm on the touchpad which will be lower then the finger clicking on the trackpoint button areas. I know we don't have palm detection yet, but in general this just feels wrong. Maybe just pin all fingers on a click and rely on unpinning to do its job to allow click + drag ? 5) In tp_post_softbutton_buttons you don't seem to deal with a physical click coming before, or at the same time, as the finger down this means that a user ie using the trackpoint and then doing a quick right click, will get a left click (t-button.state == BUTTON_STATE_RIGHT_NEW) or no click at all (tp-nfingers_down == 0). Note that neither will get corrected later since current == old will be true. To fix this I suggest that we check if all touch button states are stable, and if not set a click pending flag and stop there. Then when ever a touch button state becomes stable check the click pending flag, and if a click is pending process it then. Note that I say all touch button states must be stable because one of the things I expect libinput to fix is moving the pointer with my right input finger and then clicking the right button area with my right thumb. The thumb will then be the last finger down and we want it to be stable too so that we properly report a right click. Note that this scenario also advocates in favor of pinning all fingers, so that any movement of the index finger detected by the tp at this time also does not get reported as this likely is an unwanted side-effect of the click too. Regards, Hans ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH v2 libinput 1/5] test: add litest helper functions for creating uinput devices
Hi, On 04/01/2014 05:47 AM, Peter Hutterer wrote: Both functions accept a series of event types/codes tuples, terminated by -1. For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used as a property to enable. The _abs function als takes an array of absinfo, with absinfo.value determining the axis to change. If none are given, abs axes are initialized with default settings. Both functions abort on failure, so the caller does not need to check the return value. Example code for creating a rel device: struct libevdev_uinput *uinput; struct input_id id = { ... }; uinput = litest_create_uinput_device(foo, id, EV_REL, REL_X, EV_REL, REL_Y, EV_KEY, BTN_LEFT, INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD, -1); libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1); libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0); ... libevdev_uinput_destroy(uinput); Signed-off-by: Peter Hutterer peter.hutte...@who-t.net Looks good: Reviewed-by: Hans de Goede hdego...@redhat.com Regards, Hans --- Changes to v1: - make absinfo a -1-terminated list as well test/litest-bcm5974.c | 45 +++- test/litest-generic-highres-touch.c | 34 +++--- test/litest-synaptics-st.c | 37 +++ test/litest-synaptics.c | 45 +++- test/litest-trackpoint.c| 32 +++--- test/litest-wacom-touch.c | 33 ++ test/litest.c | 88 +++ test/litest.h | 8 ++ test/path.c | 207 9 files changed, 244 insertions(+), 285 deletions(-) diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c index 5a8ce8a..6b7a22b 100644 --- a/test/litest-bcm5974.c +++ b/test/litest-bcm5974.c @@ -95,7 +95,6 @@ static struct litest_device_interface interface = { void litest_create_bcm5974(struct litest_device *d) { - struct libevdev *dev; struct input_absinfo abs[] = { { ABS_X, 1472, 5472, 75 }, { ABS_Y, 1408, 4448, 129 }, @@ -105,36 +104,26 @@ litest_create_bcm5974(struct litest_device *d) { ABS_MT_POSITION_X, 1472, 5472, 75 }, { ABS_MT_POSITION_Y, 1408, 4448, 129 }, { ABS_MT_TRACKING_ID, 0, 65535, 0 }, - { ABS_MT_PRESSURE, 0, 255, 0 } + { ABS_MT_PRESSURE, 0, 255, 0 }, + { .value = -1 }, + }; + struct input_id id = { + .bustype = 0x3, + .vendor = 0x5ac, + .product = 0x249, }; - struct input_absinfo *a; - int rc; d-interface = interface; - - dev = libevdev_new(); - ck_assert(dev != NULL); - - libevdev_set_name(dev, bcm5974); - libevdev_set_id_bustype(dev, 0x3); - libevdev_set_id_vendor(dev, 0x5ac); - libevdev_set_id_product(dev, 0x249); - libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL); - libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_FINGER, NULL); - libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_QUINTTAP, NULL); - libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL); - libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_DOUBLETAP, NULL); - libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_TRIPLETAP, NULL); - libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_QUADTAP, NULL); - - ARRAY_FOR_EACH(abs, a) - libevdev_enable_event_code(dev, EV_ABS, a-value, a); - - rc = libevdev_uinput_create_from_device(dev, - LIBEVDEV_UINPUT_OPEN_MANAGED, - d-uinput); - ck_assert_int_eq(rc, 0); - libevdev_free(dev); + d-uinput = litest_create_uinput_abs_device(bcm5974, id, + abs, + EV_KEY, BTN_LEFT, + EV_KEY, BTN_TOOL_FINGER, + EV_KEY, BTN_TOOL_QUINTTAP, + EV_KEY, BTN_TOUCH, + EV_KEY, BTN_TOOL_DOUBLETAP, + EV_KEY, BTN_TOOL_TRIPLETAP, + EV_KEY, BTN_TOOL_QUADTAP, + -1, -1); } struct litest_test_device litest_bcm5974_device = { diff --git a/test/litest-generic-highres-touch.c b/test/litest-generic-highres-touch.c index 68615c3..bb226d6 100644 --- a/test/litest-generic-highres-touch.c +++ b/test/litest-generic-highres-touch.c @@ -94,9 +94,6 @@ static struct litest_device_interface interface
Re: [PATCH libinput 2/5] test: if no teardown func is set, use the default
Hi, On 04/01/2014 05:47 AM, Peter Hutterer wrote: Reduces the amount of boilerplate code. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- test/litest-bcm5974.c | 2 +- test/litest-generic-highres-touch.c | 2 +- test/litest-keyboard.c | 2 +- test/litest-mouse.c | 2 +- test/litest-synaptics-st.c | 2 +- test/litest-trackpoint.c| 2 +- test/litest-wacom-touch.c | 2 +- test/litest.c | 3 ++- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c index 6b7a22b..ff822f9 100644 --- a/test/litest-bcm5974.c +++ b/test/litest-bcm5974.c @@ -131,6 +131,6 @@ struct litest_test_device litest_bcm5974_device = { .features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON, .shortname = bcm5974, .setup = litest_bcm5974_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_bcm5974, }; Hmm, why not simply delete all the .teardown inits completely ? C guarantees that if a part of a struct is initialized, the rest will be set to 0. Only if no init at all is done then for non globals you may get garbage. Other then that, this patch looks good: Reviewed-by: Hans de Goede hdego...@redhat.com Regards, Hans diff --git a/test/litest-generic-highres-touch.c b/test/litest-generic-highres-touch.c index bb226d6..4d21b0d 100644 --- a/test/litest-generic-highres-touch.c +++ b/test/litest-generic-highres-touch.c @@ -123,6 +123,6 @@ struct litest_test_device litest_generic_highres_touch_device = { .features = LITEST_TOUCH, .shortname = generic-highres-touch, .setup = litest_generic_highres_touch_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_generic_highres_touch, }; diff --git a/test/litest-keyboard.c b/test/litest-keyboard.c index dd91158..ab05014 100644 --- a/test/litest-keyboard.c +++ b/test/litest-keyboard.c @@ -109,6 +109,6 @@ struct litest_test_device litest_keyboard_device = { .features = LITEST_KEYS, .shortname = default keyboard, .setup = litest_keyboard_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_keyboard, }; diff --git a/test/litest-mouse.c b/test/litest-mouse.c index 2fde095..2f70767 100644 --- a/test/litest-mouse.c +++ b/test/litest-mouse.c @@ -70,6 +70,6 @@ struct litest_test_device litest_mouse_device = { .features = LITEST_POINTER | LITEST_BUTTON | LITEST_WHEEL, .shortname = mouse, .setup = litest_mouse_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_mouse, }; diff --git a/test/litest-synaptics-st.c b/test/litest-synaptics-st.c index d13d9a2..de56c22 100644 --- a/test/litest-synaptics-st.c +++ b/test/litest-synaptics-st.c @@ -126,6 +126,6 @@ struct litest_test_device litest_synaptics_touchpad_device = { .features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH, .shortname = synaptics ST, .setup = litest_synaptics_touchpad_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_synaptics_touchpad, }; diff --git a/test/litest-trackpoint.c b/test/litest-trackpoint.c index e0b79c5..1c0fb0a 100644 --- a/test/litest-trackpoint.c +++ b/test/litest-trackpoint.c @@ -61,6 +61,6 @@ struct litest_test_device litest_trackpoint_device = { .features = LITEST_POINTER | LITEST_BUTTON, .shortname = trackpoint, .setup = litest_trackpoint_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_trackpoint, }; diff --git a/test/litest-wacom-touch.c b/test/litest-wacom-touch.c index 01a5a5d..e9119a9 100644 --- a/test/litest-wacom-touch.c +++ b/test/litest-wacom-touch.c @@ -122,6 +122,6 @@ struct litest_test_device litest_wacom_touch_device = { .features = LITEST_TOUCH, .shortname = wacom-touch, .setup = litest_wacom_touch_setup, - .teardown = litest_generic_device_teardown, + .teardown = NULL, .create = litest_create_wacom_touch, }; diff --git a/test/litest.c b/test/litest.c index f7fe24e..6767952 100644 --- a/test/litest.c +++ b/test/litest.c @@ -119,7 +119,8 @@ litest_add_tcase_for_device(struct suite *suite, t-name = strdup(test_name); t-tc = tcase_create(test_name); list_insert(suite-tests, t-node); - tcase_add_checked_fixture(t-tc, dev-setup, dev-teardown); + tcase_add_checked_fixture(t-tc, dev-setup, + dev-teardown ? dev-teardown : litest_generic_device_teardown); tcase_add_test(t-tc, func); suite_add_tcase(suite-suite, t-tc
Re: [PATCH libinput 3/5] test: allow for description-based test devices
, .shortname = synaptics, .setup = litest_synaptics_clickpad_setup, - .teardown = litest_generic_device_teardown, - .create = litest_create_synaptics_clickpad, + .teardown = NULL, + .create = NULL, + .interface = interface, + + .name = SynPS/2 Synaptics TouchPad, + .id = input_id, + .events = events, + .absinfo = absinfo, }; diff --git a/test/litest.c b/test/litest.c index 6767952..23ba76b 100644 --- a/test/litest.c +++ b/test/litest.c @@ -61,6 +61,12 @@ struct suite { static struct litest_device *current_device; +struct libevdev_uinput * +litest_create_uinput_device_from_description(const char *name, + struct input_id *id, + const struct input_absinfo *abs, + const int *events); + Hmm, shouldn't this be either static, or in a header file ? Other then that, this patch looks good: Reviewed-by: Hans de Goede hdego...@redhat.com Regards, Hans struct litest_device *litest_current_device(void) { return current_device; } @@ -342,7 +348,15 @@ litest_create_device(enum litest_device_type which) dev = devices; while (*dev) { if ((*dev)-type == which) { - (*dev)-create(d); + if ((*dev)-create) + (*dev)-create(d); + else { + d-uinput = litest_create_uinput_device_from_description((*dev)-name, + (*dev)-id, + (*dev)-absinfo, + (*dev)-events); + d-interface = (*dev)-interface; + } break; } dev++; @@ -368,10 +382,12 @@ litest_create_device(enum litest_device_type which) ck_assert(d-libinput_device != NULL); libinput_device_ref(d-libinput_device); - d-interface-min[ABS_X] = libevdev_get_abs_minimum(d-evdev, ABS_X); - d-interface-max[ABS_X] = libevdev_get_abs_maximum(d-evdev, ABS_X); - d-interface-min[ABS_Y] = libevdev_get_abs_minimum(d-evdev, ABS_Y); - d-interface-max[ABS_Y] = libevdev_get_abs_maximum(d-evdev, ABS_Y); + if (d-interface) { + d-interface-min[ABS_X] = libevdev_get_abs_minimum(d-evdev, ABS_X); + d-interface-max[ABS_X] = libevdev_get_abs_maximum(d-evdev, ABS_X); + d-interface-min[ABS_Y] = libevdev_get_abs_minimum(d-evdev, ABS_Y); + d-interface-max[ABS_Y] = libevdev_get_abs_maximum(d-evdev, ABS_Y); + } return d; } @@ -410,10 +426,54 @@ litest_event(struct litest_device *d, unsigned int type, libevdev_uinput_write_event(d-uinput, type, code, value); } +static int +auto_assign_value(struct litest_device *d, + const struct input_event *ev, + int slot, int x, int y) +{ + static int tracking_id; + int value = ev-value; + + if (value != LITEST_AUTO_ASSIGN || ev-type != EV_ABS) + return value; + + switch (ev-code) { + case ABS_X: + case ABS_MT_POSITION_X: + value = litest_scale(d, ABS_X, x); + break; + case ABS_Y: + case ABS_MT_POSITION_Y: + value = litest_scale(d, ABS_Y, y); + break; + case ABS_MT_TRACKING_ID: + value = ++tracking_id; + break; + case ABS_MT_SLOT: + value = slot; + break; + } + + return value; +} + + void litest_touch_down(struct litest_device *d, unsigned int slot, int x, int y) { - d-interface-touch_down(d, slot, x, y); + struct input_event *ev; + + if (d-interface-touch_down) { + d-interface-touch_down(d, slot, x, y); + return; + } + + ev = d-interface-touch_down_events; + while (ev (int16_t)ev-type != -1 (int16_t)ev-code != -1) { + int value = auto_assign_value(d, ev, slot, x, y); + litest_event(d, ev-type, ev-code, value); + ev++; + } } void @@ -421,23 +481,43 @@ litest_touch_up(struct litest_device *d, unsigned int slot) { struct input_event *ev; struct input_event up[] = { - { .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot }, + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 }, { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 } }; if (d-interface-touch_up) { d-interface-touch_up(d
Re: [PATCH libinput 5/5] test: switch the remaining devices to a description-based device
Hi, On 04/01/2014 05:47 AM, Peter Hutterer wrote: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- test/litest-bcm5974.c | 147 ++- test/litest-generic-highres-touch.c | 128 test/litest-keyboard.c | 231 +--- test/litest-mouse.c | 48 test/litest-synaptics-st.c | 131 test/litest-trackpoint.c| 39 +++--- test/litest-wacom-touch.c | 127 7 files changed, 419 insertions(+), 432 deletions(-) Looks good: Reviewed-by: Hans de Goede hdego...@redhat.com Regards, Hans p.s. I'm wondering if we should remove support for direct device instantiation, now all devices use the descriptor based approach ? diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c index ff822f9..ab944a7 100644 --- a/test/litest-bcm5974.c +++ b/test/litest-bcm5974.c @@ -34,97 +34,66 @@ static void litest_bcm5974_setup(void) litest_set_current_device(d); } -static void -litest_bcm5974_touch_down(struct litest_device *d, - unsigned int slot, - int x, int y) -{ - static int tracking_id; - struct input_event *ev; - struct input_event down[] = { - { .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 }, - { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 }, - { .type = EV_ABS, .code = ABS_X, .value = x }, - { .type = EV_ABS, .code = ABS_Y, .value = y }, - { .type = EV_ABS, .code = ABS_PRESSURE, .value = 30 }, - { .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot }, - { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = ++tracking_id }, - { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = x }, - { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = y }, - { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, - }; +struct input_event down[] = { + { .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 }, + { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 }, + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = 30 }, + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; - down[2].value = litest_scale(d, ABS_X, x); - down[3].value = litest_scale(d, ABS_Y, y); - down[7].value = litest_scale(d, ABS_X, x); - down[8].value = litest_scale(d, ABS_Y, y); - - ARRAY_FOR_EACH(down, ev) - litest_event(d, ev-type, ev-code, ev-value); -} - -void -litest_bcm5974_move(struct litest_device *d, unsigned int slot, int x, int y) -{ - struct input_event *ev; - struct input_event move[] = { - { .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot }, - { .type = EV_ABS, .code = ABS_X, .value = x }, - { .type = EV_ABS, .code = ABS_Y, .value = y }, - { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = x }, - { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = y }, - { .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 }, - { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 }, - { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, - }; - - move[1].value = litest_scale(d, ABS_X, x); - move[2].value = litest_scale(d, ABS_Y, y); - move[3].value = litest_scale(d, ABS_X, x); - move[4].value = litest_scale(d, ABS_Y, y); - - ARRAY_FOR_EACH(move, ev) - litest_event(d, ev-type, ev-code, ev-value); -} +static struct input_event move[] = { + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 }, + { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; static struct litest_device_interface interface = { - .touch_down = litest_bcm5974_touch_down, - .touch_move = litest_bcm5974_move, + .touch_down_events