From 66cd2b5c639028d020decfb2fd5dab2c7ccf4bd1 Mon Sep 17 00:00:00 2001 From: Tim Richardson Date: Wed, 11 Apr 2018 09:41:40 +1000 Subject: [PATCH 1/2] Add a specific quirk rule for P50 because sharing it with other machines caused strange behaviour (not investigated). Fixed some typos. most printf statements are commented out. This works quite well with an accel speed setting of 1 restore blank line to libinput.c --- src/evdev-mt-touchpad.c | 18 ++++++++++-------- src/evdev.c | 1 + src/evdev.h | 3 ++- src/filter.c | 15 ++++++++------- src/libinput.c | 2 +- udev/90-libinput-model-quirks.hwdb | 7 ++++++- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index bdc41a64..45f818f0 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -91,6 +91,7 @@ tp_calculate_motion_speed(struct tp_dispatch *tp, struct tp_touch *t) struct phys_coords mm; double distance; double speed; + const unsigned int HISTORY_COUNT_THRESHOLD = 4; /* Don't do this on single-touch or semi-mt devices */ if (!tp->has_mt || tp->semi_mt) @@ -105,8 +106,9 @@ tp_calculate_motion_speed(struct tp_dispatch *tp, struct tp_touch *t) * is reset whenever a new finger is down, so we'd be resetting the * speed and failing. */ - if (t->history.count < 4) + if (t->history.count < HISTORY_COUNT_THRESHOLD) { return; + } /* TODO: we probably need a speed history here so we can average * across a few events */ @@ -433,7 +435,7 @@ tp_get_delta(struct tp_touch *t) if (t->history.count <= 1) return zero; - + delta.x = tp_motion_history_offset(t, 0)->point.x - tp_motion_history_offset(t, 1)->point.x; delta.y = tp_motion_history_offset(t, 0)->point.y - @@ -1396,10 +1398,10 @@ static inline bool tp_need_motion_history_reset(struct tp_dispatch *tp) { bool rc = false; - + const unsigned int NON_MOTION_EVENT_COUNT = 10; /* Changing the numbers of fingers can cause a jump in the * coordinates, always reset the motion history for all touches when - * that happens. + * that happens. If this evaluates as true, then the history count is set to 0 */ if (tp->nfingers_down != tp->old_nfingers_down) return true; @@ -1409,9 +1411,9 @@ tp_need_motion_history_reset(struct tp_dispatch *tp) reset that touch to non-dirty effectively swallowing that event and restarting with the next event again. */ - if (tp->device->model_flags & EVDEV_MODEL_LENOVO_T450_TOUCHPAD) { + if (tp->device->model_flags & EVDEV_MODEL_LENOVO_P50_TOUCHPAD) { if (tp->queued & TOUCHPAD_EVENT_MOTION) { - if (tp->quirks.nonmotion_event_count > 10) { + if (tp->quirks.nonmotion_event_count > NON_MOTION_EVENT_COUNT) { tp->queued &= ~TOUCHPAD_EVENT_MOTION; rc = true; } @@ -1449,7 +1451,7 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t) delta.x = abs(t->point.x - last->point.x); delta.y = abs(t->point.y - last->point.y); mm = evdev_device_unit_delta_to_mm(tp->device, &delta); - + return hypot(mm.x, mm.y) > JUMP_THRESHOLD_MM; } @@ -1830,7 +1832,7 @@ tp_suspend(struct tp_dispatch *tp, struct evdev_device *device) { tp_clear_state(tp); - /* On devices with top softwarebuttons we don't actually suspend the + /* On devices with top software buttons we don't actually suspend the * device, to keep the "trackpoint" buttons working. tp_post_events() * will only send events for the trackpoint while suspended. */ diff --git a/src/evdev.c b/src/evdev.c index d33bf78e..e0a68491 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1282,6 +1282,7 @@ evdev_read_model_flags(struct evdev_device *device) MODEL(TABLET_NO_PROXIMITY_OUT), MODEL(MS_NANO_TRANSCEIVER), MODEL(TABLET_NO_TILT), + MODEL(LENOVO_P50_TOUCHPAD), #undef MODEL { "ID_INPUT_TRACKBALL", EVDEV_MODEL_TRACKBALL }, { NULL, EVDEV_MODEL_DEFAULT }, diff --git a/src/evdev.h b/src/evdev.h index be74dfc5..d23abcf7 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -126,7 +126,8 @@ enum evdev_device_model { EVDEV_MODEL_LOGITECH_MARBLE_MOUSE = (1 << 26), EVDEV_MODEL_TABLET_NO_PROXIMITY_OUT = (1 << 27), EVDEV_MODEL_MS_NANO_TRANSCEIVER = (1 << 28), - EVDEV_MODEL_TABLET_NO_TILT = (1 << 28), + EVDEV_MODEL_TABLET_NO_TILT = (1 << 29), + EVDEV_MODEL_LENOVO_P50_TOUCHPAD = (1 << 30), }; enum evdev_button_scroll_state { diff --git a/src/filter.c b/src/filter.c index 206695bb..01b15add 100644 --- a/src/filter.c +++ b/src/filter.c @@ -382,17 +382,17 @@ calculate_acceleration(struct pointer_accelerator *accel, { double factor; - /* Use Simpson's rule to calculate the avarage acceleration between + /* Use Simpson's rule to calculate the average acceleration between * the previous motion and the most recent. */ factor = acceleration_profile(accel, data, velocity, time); + factor += acceleration_profile(accel, data, last_velocity, time); factor += 4.0 * acceleration_profile(accel, data, (last_velocity + velocity) / 2, time); - factor = factor / 6.0; - + return factor; /* unitless factor */ } @@ -423,7 +423,7 @@ calculate_acceleration_factor(struct pointer_accelerator *accel, accel->last_velocity, time); accel->last_velocity = velocity; - + return accel_factor; } @@ -874,7 +874,7 @@ touchpad_accel_profile_linear(struct motion_filter *filter, } else if (speed_in < threshold) { factor = 1; } else { - /* Acceleration function above the threshold: + /* Acceleration function above the threshold: y = ax' + b where T is threshold x is speed_in @@ -885,6 +885,7 @@ touchpad_accel_profile_linear(struct motion_filter *filter, => x' := (x - T) */ factor = incline * (speed_in - threshold) + 1; + } /* Cap at the maximum acceleration factor */ @@ -1123,7 +1124,7 @@ trackpoint_normalize_deltas(const struct trackpoint_accelerator *accel_filter, const struct device_float_coords *delta) { struct device_float_coords scaled = *delta; - + scaled.x *= accel_filter->scale_factor; scaled.y *= accel_filter->scale_factor; @@ -1337,7 +1338,7 @@ accelerator_set_speed_flat(struct motion_filter *filter, assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0); - /* Speed rage is 0-200% of the nominal speed, with 0 mapping to the + /* Speed range is 0-200% of the nominal speed, with 0 mapping to the * nominal speed. Anything above 200 is pointless, we're already * skipping over ever second pixel at 200% speed. */ diff --git a/src/libinput.c b/src/libinput.c index 8fb0ba92..5dbf3122 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -2219,7 +2219,7 @@ pointer_notify_motion(struct libinput_device *device, .delta = *delta, .delta_raw = *raw, }; - + post_device_event(device, time, LIBINPUT_EVENT_POINTER_MOTION, &motion_event->base); diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb index d23784bb..afe48bdc 100644 --- a/udev/90-libinput-model-quirks.hwdb +++ b/udev/90-libinput-model-quirks.hwdb @@ -217,10 +217,15 @@ libinput:name:TPPS/2 IBM TrackPoint:dmi:*svnLENOVO:*:pvrThinkPadT440s* # T450s trackpoint libinput:name:TPPS/2 IBM TrackPoint:dmi:*svnLENOVO:*:pvrThinkPadT450s* LIBINPUT_ATTR_TRACKPOINT_RANGE=50 + +# Lenovo P50 +libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadP50* + LIBINPUT_MODEL_LENOVO_P50_TOUCHPAD=1 + LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD=150 # Lenovo T450/T460 and all other Lenovos of the *50 and *60 generation, # including the X1 Carbon 3rd gen -libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadP50*: + libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPad??50*: libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPad??60*: libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadX1Carbon3rd:* -- 2.14.1 From 0407577f5fe2c2029c9bd822ad1fb3488fddeb17 Mon Sep 17 00:00:00 2001 From: Tim Richardson Date: Wed, 11 Apr 2018 07:59:29 +1000 Subject: [PATCH 2/2] add a couple of directories to .gitignore .gitignore tweaks --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index d35d0c3e..b51833fe 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,13 @@ *.trs *.gcda *.gcno +.settings tags +/builddir/ +/build/ +/Debug/ +/help/ +/.cproject +/.project +/tim_notes.txt +.externalToolBuilders -- 2.14.1