[PATCH libinput v3 10/17] touchpad: Use INPUT_PROP_BUTTONPAD instead of checking for buttons
Hans de Goede
hdegoede at redhat.com
Tue May 20 07:34:58 PDT 2014
And warn if INPUT_PROP_BUTTONPAD mismatches right/middle buttons presence.
Also fix the bcm5974 to properly advertise INPUT_PROP_BUTTONPAD.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad-buttons.c | 34 ++++++++++++++++++----------------
src/evdev-mt-touchpad.c | 4 ++--
src/evdev-mt-touchpad.h | 7 +++----
test/litest-bcm5974.c | 1 +
4 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index e47a55e..76e6843 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -407,9 +407,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);
@@ -420,10 +428,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);
@@ -583,21 +588,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 = 0;
-
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 924ba16..f5e0300 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -409,7 +409,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);
}
@@ -499,7 +499,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_clickpad &&
(tp->buttons.state || tp->buttons.old_state))
return 0;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 5509e93..78a74df 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 the touchpad. Depending on the
* rightbutton_left_edge value, the buttons are split according to the
* edge settings.
- */
+ */
struct {
int32_t top_edge;
int32_t rightbutton_left_edge;
diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c
index 25d59ac..43605aa 100644
--- a/test/litest-bcm5974.c
+++ b/test/litest-bcm5974.c
@@ -92,6 +92,7 @@ static int events[] = {
EV_KEY, BTN_TOOL_DOUBLETAP,
EV_KEY, BTN_TOOL_TRIPLETAP,
EV_KEY, BTN_TOOL_QUADTAP,
+ INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
-1, -1
};
--
1.9.0
More information about the wayland-devel
mailing list