...
 
Commits (5)
......@@ -2,7 +2,7 @@ AC_PREREQ([2.64])
m4_define([libinput_major_version], [1])
m4_define([libinput_minor_version], [0])
m4_define([libinput_micro_version], [0])
m4_define([libinput_micro_version], [2])
m4_define([libinput_version],
[libinput_major_version.libinput_minor_version.libinput_micro_version])
......@@ -31,7 +31,7 @@ AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
# b) If interfaces have been changed or added, but binary compatibility has
# been preserved, change to C+1:0:A+1
# c) If the interface is the same as the previous version, change to C:R+1:A
LIBINPUT_LT_VERSION=15:2:5
LIBINPUT_LT_VERSION=15:3:5
AC_SUBST(LIBINPUT_LT_VERSION)
AM_SILENT_RULES([yes])
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -69,6 +69,7 @@ tap_state_to_str(enum tp_tap_state state)
CASE_RETURN_STRING(TAP_STATE_TAPPED);
CASE_RETURN_STRING(TAP_STATE_TOUCH_2);
CASE_RETURN_STRING(TAP_STATE_TOUCH_2_HOLD);
CASE_RETURN_STRING(TAP_STATE_TOUCH_2_RELEASE);
CASE_RETURN_STRING(TAP_STATE_TOUCH_3);
CASE_RETURN_STRING(TAP_STATE_TOUCH_3_HOLD);
CASE_RETURN_STRING(TAP_STATE_DRAGGING);
......@@ -275,12 +276,8 @@ tp_tap_touch2_handle_event(struct tp_dispatch *tp,
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_RELEASE:
tp->tap.state = TAP_STATE_HOLD;
if (t->tap.state == TAP_TOUCH_STATE_TOUCH) {
tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_RELEASED);
}
tp_tap_clear_timer(tp);
tp->tap.state = TAP_STATE_TOUCH_2_RELEASE;
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_MOTION:
tp_tap_clear_timer(tp);
......@@ -322,6 +319,35 @@ tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp,
}
}
static void
tp_tap_touch2_release_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
{
switch (event) {
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_TOUCH_2_HOLD;
t->tap.state = TAP_TOUCH_STATE_DEAD;
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_RELEASE:
tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_RELEASED);
tp->tap.state = TAP_STATE_IDLE;
break;
case TAP_EVENT_MOTION:
case TAP_EVENT_TIMEOUT:
tp->tap.state = TAP_STATE_HOLD;
break;
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
case TAP_EVENT_THUMB:
break;
}
}
static void
tp_tap_touch3_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
......@@ -570,21 +596,11 @@ tp_tap_multitap_down_handle_event(struct tp_dispatch *tp,
break;
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_DRAGGING_2;
tp_tap_notify(tp,
tp->tap.multitap_last_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_MOTION:
case TAP_EVENT_TIMEOUT:
tp->tap.state = TAP_STATE_DRAGGING;
tp_tap_notify(tp,
tp->tap.multitap_last_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_BUTTON:
......@@ -649,6 +665,9 @@ tp_tap_handle_event(struct tp_dispatch *tp,
case TAP_STATE_TOUCH_2_HOLD:
tp_tap_touch2_hold_handle_event(tp, t, event, time);
break;
case TAP_STATE_TOUCH_2_RELEASE:
tp_tap_touch2_release_handle_event(tp, t, event, time);
break;
case TAP_STATE_TOUCH_3:
tp_tap_touch3_handle_event(tp, t, event, time);
break;
......
......@@ -97,6 +97,7 @@ enum tp_tap_state {
TAP_STATE_TAPPED,
TAP_STATE_TOUCH_2,
TAP_STATE_TOUCH_2_HOLD,
TAP_STATE_TOUCH_2_RELEASE,
TAP_STATE_TOUCH_3,
TAP_STATE_TOUCH_3_HOLD,
TAP_STATE_DRAGGING_OR_DOUBLETAP,
......
......@@ -114,6 +114,8 @@ filter_get_speed(struct motion_filter *filter)
#define X230_THRESHOLD v_ms2us(0.4) /* in units/us */
#define X230_ACCELERATION 2.0 /* unitless factor */
#define X230_INCLINE 1.1 /* unitless factor */
#define X230_MAGIC_SLOWDOWN 0.4 /* unitless */
#define X230_TP_MAGIC_LOW_RES_FACTOR 4.0 /* unitless */
/*
* Pointer acceleration filter constants
......@@ -420,6 +422,21 @@ accelerator_filter_x230(struct motion_filter *filter,
return accelerated;
}
static struct normalized_coords
accelerator_filter_constant_x230(struct motion_filter *filter,
const struct normalized_coords *unaccelerated,
void *data, uint64_t time)
{
struct normalized_coords normalized;
const double factor =
X230_MAGIC_SLOWDOWN/X230_TP_MAGIC_LOW_RES_FACTOR;
normalized.x = factor * unaccelerated->x;
normalized.y = factor * unaccelerated->y;
return normalized;
}
static struct normalized_coords
touchpad_constant_filter(struct motion_filter *filter,
const struct normalized_coords *unaccelerated,
......@@ -631,26 +648,22 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
double speed_in,
uint64_t time)
{
/* Keep the magic factor from touchpad_accel_profile_linear. */
const double X230_MAGIC_SLOWDOWN = 0.4; /* unitless */
/* Those touchpads presents an actual lower resolution that what is
* advertised. We see some jumps from the cursor due to the big steps
* in X and Y when we are receiving data.
* Apply a factor to minimize those jumps at low speed, and try
* keeping the same feeling as regular touchpads at high speed.
* It still feels slower but it is usable at least */
const double TP_MAGIC_LOW_RES_FACTOR = 4.0; /* unitless */
double factor; /* unitless */
struct pointer_accelerator *accel_filter =
(struct pointer_accelerator *)filter;
double f1, f2; /* unitless */
const double max_accel = accel_filter->accel *
TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
X230_TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
const double threshold = accel_filter->threshold /
TP_MAGIC_LOW_RES_FACTOR; /* units/us */
const double incline = accel_filter->incline * TP_MAGIC_LOW_RES_FACTOR;
X230_TP_MAGIC_LOW_RES_FACTOR; /* units/us */
const double incline = accel_filter->incline * X230_TP_MAGIC_LOW_RES_FACTOR;
/* Note: the magic values in this function are obtained by
* trial-and-error. No other meaning should be interpreted.
......@@ -658,14 +671,14 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
* pointer_accel_profile_linear(), look at the git history of that
* function for an explaination of what the min/max/etc. does.
*/
speed_in *= X230_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR;
speed_in *= X230_MAGIC_SLOWDOWN / X230_TP_MAGIC_LOW_RES_FACTOR;
f1 = min(1, v_us2ms(speed_in) * 5);
f2 = 1 + (v_us2ms(speed_in) - v_us2ms(threshold)) * incline;
factor = min(max_accel, f2 > 1 ? f2 : f1);
return factor * X230_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR;
return factor * X230_MAGIC_SLOWDOWN / X230_TP_MAGIC_LOW_RES_FACTOR;
}
double
......@@ -795,7 +808,7 @@ create_pointer_accelerator_filter_touchpad(int dpi)
struct motion_filter_interface accelerator_interface_x230 = {
.filter = accelerator_filter_x230,
.filter_constant = accelerator_filter_noop,
.filter_constant = accelerator_filter_constant_x230,
.restart = accelerator_restart,
.destroy = accelerator_destroy,
.set_speed = accelerator_set_speed,
......
......@@ -191,7 +191,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_move)
litest_touch_move_to(dev, 0, 50, 50, 70, 50, 10, 4);
libinput_dispatch(li);
for (ntaps = 0; ntaps <= range; ntaps++) {
for (ntaps = 0; ntaps < range; ntaps++) {
event = libinput_get_event(li);
ptrev = litest_is_button_event(event,
BTN_LEFT,
......@@ -261,7 +261,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_2fg)
litest_touch_down(dev, 1, 70, 50);
libinput_dispatch(li);
for (ntaps = 0; ntaps <= range; ntaps++) {
for (ntaps = 0; ntaps < range; ntaps++) {
event = libinput_get_event(li);
ptrev = litest_is_button_event(event,
BTN_LEFT,
......@@ -393,7 +393,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_timeout)
litest_timeout_tap();
libinput_dispatch(li);
for (ntaps = 0; ntaps <= range; ntaps++) {
for (ntaps = 0; ntaps < range; ntaps++) {
event = libinput_get_event(li);
ptrev = litest_is_button_event(event,
BTN_LEFT,
......@@ -464,7 +464,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap)
litest_timeout_tap();
libinput_dispatch(li);
for (ntaps = 0; ntaps <= range; ntaps++) {
for (ntaps = 0; ntaps < range; ntaps++) {
event = libinput_get_event(li);
ptrev = litest_is_button_event(event,
BTN_LEFT,
......@@ -537,7 +537,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap_click)
litest_timeout_tap();
libinput_dispatch(li);
for (ntaps = 0; ntaps <= range; ntaps++) {
for (ntaps = 0; ntaps < range; ntaps++) {
event = libinput_get_event(li);
ptrev = litest_is_button_event(event,
BTN_LEFT,
......@@ -966,6 +966,50 @@ START_TEST(touchpad_2fg_tap_inverted)
}
END_TEST
START_TEST(touchpad_2fg_tap_n_hold_first)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
litest_drain_events(dev->libinput);
litest_touch_down(dev, 0, 50, 50);
litest_touch_down(dev, 1, 70, 70);
litest_touch_up(dev, 1);
libinput_dispatch(li);
litest_assert_empty_queue(li);
litest_timeout_tap();
litest_assert_empty_queue(li);
}
END_TEST
START_TEST(touchpad_2fg_tap_n_hold_second)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
litest_drain_events(dev->libinput);
litest_touch_down(dev, 0, 50, 50);
litest_touch_down(dev, 1, 70, 70);
litest_touch_up(dev, 0);
libinput_dispatch(li);
litest_assert_empty_queue(li);
litest_timeout_tap();
litest_assert_empty_queue(li);
}
END_TEST
START_TEST(touchpad_2fg_tap_quickrelease)
{
struct litest_device *dev = litest_current_device();
......@@ -1755,6 +1799,8 @@ litest_setup_tests(void)
litest_add("touchpad:tap", touchpad_2fg_tap_n_drag_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:tap", touchpad_2fg_tap_n_hold_first, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:tap", touchpad_2fg_tap_n_hold_second, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:tap", touchpad_2fg_tap_quickrelease, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT);
litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_CLICKPAD);
litest_add("touchpad:tap", touchpad_2fg_tap_click, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_SINGLE_TOUCH|LITEST_CLICKPAD);
......