mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 23:20:29 +01:00
touchpad: Use INPUT_PROP_BUTTONPAD instead of checking for buttons
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@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
55d84420e2
commit
f6c3731f8a
4 changed files with 24 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -410,7 +410,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);
|
||||
}
|
||||
|
||||
|
|
@ -500,7 +500,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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue