return 0;
}
-static void
-tp_post_button_events(struct tp_dispatch *tp, uint32_t time)
+static int
+tp_post_clickfinger_buttons(struct tp_dispatch *tp, uint32_t time)
{
uint32_t current, old, button;
+ enum libinput_pointer_button_state state;
- if ((tp->queued &
- (TOUCHPAD_EVENT_BUTTON_PRESS|TOUCHPAD_EVENT_BUTTON_RELEASE)) == 0)
- return;
+ 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;
current >>= 1;
old >>= 1;
}
+
+ return 0;
+}
+
+static 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
+ rc = tp_post_clickfinger_buttons(tp, time);
+
+ return rc;
}
static void
struct tp_touch *t = tp_current_touch(tp);
double dx, dy;
+ if (tp_post_button_events(tp, time) != 0)
+ return;
+
if (tp_tap_handle_state(tp, time) != 0)
return;
li_fixed_from_double(dx),
li_fixed_from_double(dy));
}
-
- tp_post_button_events(tp, time);
}
static void
tp->hysteresis.margin_y =
diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR;
+ if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_RIGHT) ||
+ libevdev_has_event_code(device->evdev, EV_KEY, BTN_RIGHT))
+ tp->buttons.has_buttons = true;
+
if (tp_init_scroll(tp) != 0)
return -1;
int main (int argc, char **argv) {
litest_add("pointer:motion", pointer_motion_relative, LITEST_POINTER, LITEST_ANY);
- litest_add("pointer:button", pointer_button, LITEST_BUTTON, LITEST_ANY);
+ litest_add("pointer:button", pointer_button, LITEST_BUTTON, LITEST_CLICKPAD);
litest_add("pointer:scroll", pointer_scroll_wheel, LITEST_WHEEL, LITEST_ANY);
return litest_run(argc, argv);