Commit 6f5d9902 authored by Peter Hutterer's avatar Peter Hutterer

tablet: hook up tip events

Behavior for axis events in the same event frame as the BTN_TOUCH is to
always send axis events before any tip state.
Behavior for button events in the same event frame as the BTN_TOUCH is to
order button events to happen when the tip is in proximity, i.e. after the tip
event on tip down and before the tip event on tip up.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 1318ffad
......@@ -425,6 +425,8 @@ tablet_update_button(struct tablet_dispatch *tablet,
uint32_t enable)
{
switch (evcode) {
case BTN_TOUCH:
return;
case BTN_LEFT:
case BTN_RIGHT:
case BTN_MIDDLE:
......@@ -433,7 +435,6 @@ tablet_update_button(struct tablet_dispatch *tablet,
case BTN_FORWARD:
case BTN_BACK:
case BTN_TASK:
case BTN_TOUCH:
case BTN_STYLUS:
case BTN_STYLUS2:
break;
......@@ -496,11 +497,10 @@ tablet_process_key(struct tablet_dispatch *tablet,
break;
case BTN_TOUCH:
if (e->value)
tablet_set_status(tablet, TABLET_TOOL_IN_CONTACT);
tablet_set_status(tablet, TABLET_TOOL_ENTERING_CONTACT);
else
tablet_unset_status(tablet, TABLET_TOOL_IN_CONTACT);
/* Fall through */
tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
break;
case BTN_LEFT:
case BTN_RIGHT:
case BTN_MIDDLE:
......@@ -622,7 +622,6 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
copy_button_cap(tablet, tool, BTN_STYLUS2);
if (libwacom_stylus_get_num_buttons(s) >= 1)
copy_button_cap(tablet, tool, BTN_STYLUS);
copy_button_cap(tablet, tool, BTN_TOUCH);
}
if (libwacom_stylus_has_wheel(s))
......@@ -707,7 +706,6 @@ tool_set_bits(const struct tablet_dispatch *tablet,
case LIBINPUT_TOOL_TYPE_ERASER:
copy_button_cap(tablet, tool, BTN_STYLUS);
copy_button_cap(tablet, tool, BTN_STYLUS2);
copy_button_cap(tablet, tool, BTN_TOUCH);
break;
case LIBINPUT_TOOL_TYPE_MOUSE:
case LIBINPUT_TOOL_TYPE_LENS:
......@@ -843,7 +841,8 @@ sanitize_tablet_axes(struct tablet_dispatch *tablet)
clear_bit(tablet->changed_axes, LIBINPUT_TABLET_AXIS_DISTANCE);
tablet->axes[LIBINPUT_TABLET_AXIS_DISTANCE] = 0;
} else if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_AXIS_PRESSURE) &&
!tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT)) {
(!tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT) &&
!tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT))) {
/* Make sure that the last axis value sent to the caller is a 0 */
if (tablet->axes[LIBINPUT_TABLET_AXIS_PRESSURE] == 0)
clear_bit(tablet->changed_axes,
......@@ -881,6 +880,8 @@ tablet_flush(struct tablet_dispatch *tablet,
0,
sizeof(tablet->button_state.stylus_buttons));
tablet_set_status(tablet, TABLET_BUTTONS_RELEASED);
if (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT))
tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
} else if (tablet_has_status(tablet, TABLET_AXES_UPDATED) ||
tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) {
sanitize_tablet_axes(tablet);
......@@ -890,6 +891,16 @@ tablet_flush(struct tablet_dispatch *tablet,
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
}
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT)) {
tablet_notify_tip(&device->base,
time,
tool,
LIBINPUT_TOOL_TIP_DOWN,
tablet->axes);
tablet_unset_status(tablet, TABLET_TOOL_ENTERING_CONTACT);
tablet_set_status(tablet, TABLET_TOOL_IN_CONTACT);
}
if (tablet_has_status(tablet, TABLET_BUTTONS_RELEASED)) {
tablet_notify_buttons(tablet,
device,
......@@ -908,6 +919,16 @@ tablet_flush(struct tablet_dispatch *tablet,
tablet_unset_status(tablet, TABLET_BUTTONS_PRESSED);
}
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT)) {
tablet_notify_tip(&device->base,
time,
tool,
LIBINPUT_TOOL_TIP_UP,
tablet->axes);
tablet_unset_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
tablet_unset_status(tablet, TABLET_TOOL_IN_CONTACT);
}
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
memset(tablet->changed_axes, 0, sizeof(tablet->changed_axes));
tablet_notify_proximity(&device->base,
......
......@@ -38,7 +38,9 @@ enum tablet_status {
TABLET_TOOL_IN_CONTACT = 1 << 3,
TABLET_TOOL_LEAVING_PROXIMITY = 1 << 4,
TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 5,
TABLET_TOOL_ENTERING_PROXIMITY = 1 << 6
TABLET_TOOL_ENTERING_PROXIMITY = 1 << 6,
TABLET_TOOL_ENTERING_CONTACT = 1 << 7,
TABLET_TOOL_LEAVING_CONTACT = 1 << 8,
};
struct button_state {
......@@ -48,7 +50,7 @@ struct button_state {
struct tablet_dispatch {
struct evdev_dispatch base;
struct evdev_device *device;
unsigned char status;
unsigned int status;
unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)];
double axes[LIBINPUT_TABLET_AXIS_MAX + 1];
double deltas[LIBINPUT_TABLET_AXIS_MAX + 1];
......
......@@ -2330,6 +2330,21 @@ litest_is_gesture_event(struct libinput_event *event,
return gevent;
}
struct libinput_event_tablet * litest_is_tablet_event(
struct libinput_event *event,
enum libinput_event_type type)
{
struct libinput_event_tablet *tevent;
litest_assert(event != NULL);
litest_assert_int_eq(libinput_event_get_type(event), type);
tevent = libinput_event_get_tablet_event(event);
litest_assert(tevent != NULL);
return tevent;
}
void
litest_assert_tablet_button_event(struct libinput *li, unsigned int button,
enum libinput_button_state state)
......
......@@ -402,6 +402,9 @@ struct libinput_event_gesture * litest_is_gesture_event(
struct libinput_event *event,
enum libinput_event_type type,
int nfingers);
struct libinput_event_tablet * litest_is_tablet_event(
struct libinput_event *event,
enum libinput_event_type type);
void litest_assert_button_event(struct libinput *li,
unsigned int button,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment