diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 8c374345..1057568e 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -1037,7 +1037,7 @@ out: case 1: button = BTN_LEFT; break; case 2: button = BTN_RIGHT; break; default: - button = BTN_MIDDLE; break; + button = BTN_RIGHT; break; break; } diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index 37d98fdc..618d1745 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -632,8 +632,11 @@ tp_init_gesture(struct tp_dispatch *tp) /* two-finger scrolling is always enabled, this flag just * decides whether we detect pinch. semi-mt devices are too * unreliable to do pinch gestures. */ - tp->gesture.enabled = !tp->semi_mt && tp->num_slots > 1; + // Disable gestures other than two finger scroll, get in the way for me + //tp->gesture.enabled = !tp->semi_mt && tp->num_slots > 1; + tp->gesture.enabled = false; + tp->gesture.state = GESTURE_STATE_NONE; snprintf(timer_name, diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 1ad66fb0..c363bad6 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -992,6 +992,11 @@ tp_thumb_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) * A finger that remains at the very bottom of the touchpad becomes * a thumb. */ + + int t_maxsize = max(t->major, t->minor); + if (t_maxsize > 700) + t->thumb.state = THUMB_STATE_YES; + if (t->pressure > tp->thumb.threshold) t->thumb.state = THUMB_STATE_YES; else if (t->point.y > tp->thumb.lower_thumb_line && @@ -2420,6 +2425,10 @@ tp_init_accel(struct tp_dispatch *tp) filter = create_pointer_accelerator_filter_lenovo_x230(tp->device->dpi); else if (libevdev_get_id_bustype(device->evdev) == BUS_BLUETOOTH) filter = create_pointer_accelerator_filter_touchpad(device->dpi, ms2us(50), ms2us(10)); + else if (tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD) { + evdev_log_info(device, "Detected Apple TouchPad with dpi %d, using dedicated accel handler\n", device->dpi); + filter = create_pointer_accelerator_filter_apple_touchpad(device->dpi, 0, 0); + } else filter = create_pointer_accelerator_filter_touchpad(device->dpi, 0, 0); @@ -2537,7 +2546,7 @@ tp_init_scroll(struct tp_dispatch *tp, struct evdev_device *device) /* In mm for touchpads with valid resolution, see tp_init_accel() */ tp->device->scroll.threshold = 0.0; - tp->device->scroll.direction_lock_threshold = 5.0; + tp->device->scroll.direction_lock_threshold = 2.0; } static int @@ -2802,7 +2811,8 @@ tp_init_thumb(struct tp_dispatch *tp) /* detect thumbs by pressure in the bottom 15mm, detect thumbs by * lingering in the bottom 8mm */ - mm.y = h * 0.85; + mm.y = h * 0.60; + edges = evdev_device_mm_to_units(device, &mm); tp->thumb.upper_thumb_line = edges.y; diff --git a/src/evdev.c b/src/evdev.c index c490cae0..f3c737e6 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -363,6 +363,12 @@ evdev_notify_axis(struct evdev_device *device, discrete.y *= -1; } + // My stuff here to slow down scrolling by factor + + double factor = 0.75; + delta.x *= factor; + delta.y *= factor; + pointer_notify_axis(&device->base, time, axes, diff --git a/src/filter.c b/src/filter.c index 206695bb..5f4d136e 100644 --- a/src/filter.c +++ b/src/filter.c @@ -886,7 +886,7 @@ touchpad_accel_profile_linear(struct motion_filter *filter, */ factor = incline * (speed_in - threshold) + 1; } - + /* Cap at the maximum acceleration factor */ factor = min(max_accel, factor); @@ -896,6 +896,43 @@ touchpad_accel_profile_linear(struct motion_filter *filter, return factor * TP_MAGIC_SLOWDOWN; } +double +touchpad_apple_accel_profile(struct motion_filter *filter, + void *data, + double speed_in, /* in device units/µs */ + uint64_t time) +{ + struct pointer_accelerator *accel_filter = + (struct pointer_accelerator *)filter; + const double max_accel = accel_filter->accel; /* unitless factor */ + double factor; /* unitless */ + + /* Convert to mm/s because that's something one can understand */ + speed_in = v_us2s(speed_in) * 25.4/accel_filter->dpi; + + // Convert into speed that my formula used which assumed 1 = distance of trackpad in x (103mm for my pad) + double norm_in = speed_in / 103.0; + + // X adjustment; range on Apple was .07 to .7 (fastest) + double x_factor = 0.385 + 0.315 * filter->speed_adjustment; + + // Power adjustment; range on Apple was 1.1 to 1.5 (fastest) + double power = 1.3 + 0.2 * filter->speed_adjustment; + + // first number is a magic number to get into the scale that is appropriate for the factor + factor = 3.5 * pow(norm_in * x_factor, power); + + // Mininum factor for slow speeds + if (factor < 0.20) { + factor = 0.20; + } + + /* Cap at the maximum acceleration factor */ + factor = min(max_accel, factor); + + return factor; +} + double touchpad_lenovo_x230_accel_profile(struct motion_filter *filter, void *data, @@ -1031,6 +1068,25 @@ create_pointer_accelerator_filter_touchpad(int dpi, return &filter->base; } +struct motion_filter * +create_pointer_accelerator_filter_apple_touchpad(int dpi, + uint64_t event_delta_smooth_threshold, + uint64_t event_delta_smooth_value) +{ + struct pointer_accelerator *filter; + + filter = create_default_filter(dpi); + if (!filter) + return NULL; + + filter->base.interface = &accelerator_interface_touchpad; + filter->profile = touchpad_apple_accel_profile; + filter->event_delta_smooth_threshold = event_delta_smooth_threshold; + filter->event_delta_smooth_value = event_delta_smooth_value; + + return &filter->base; +} + struct motion_filter_interface accelerator_interface_x230 = { .type = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE, .filter = accelerator_filter_x230, diff --git a/src/filter.h b/src/filter.h index 506ab123..522d56a5 100644 --- a/src/filter.h +++ b/src/filter.h @@ -118,6 +118,11 @@ create_pointer_accelerator_filter_touchpad(int dpi, uint64_t event_delta_smooth_threshold, uint64_t event_delta_smooth_value); +struct motion_filter * +create_pointer_accelerator_filter_apple_touchpad(int dpi, + uint64_t event_delta_smooth_threshold, + uint64_t event_delta_smooth_value); + struct motion_filter * create_pointer_accelerator_filter_lenovo_x230(int dpi); @@ -145,7 +150,12 @@ double touchpad_accel_profile_linear(struct motion_filter *filter, void *data, double speed_in, - uint64_t time); + uint64_t time); +double +touchpad_apple_accel_profile(struct motion_filter *filter, + void *data, + double speed_in, /* in device units/µs */ + uint64_t time); double touchpad_lenovo_x230_accel_profile(struct motion_filter *filter, void *data,