Bring features of xinput list-props to libinput-list-devices

Peter Hutterer peter.hutterer at who-t.net
Sun Jul 17 22:35:25 UTC 2016


On Sun, Jul 17, 2016 at 11:49:27PM +0200, William Gathoye wrote:
> Hello everyone,
> 
> I have just made a simple patch to libinput-list-devices.
> 
> The latter brings back a feature available in xinput when used in
> combination with Xorg drivers instead of libinput.
> 
> - The maximum number of finger detected
> - Reports if 3 fingers are detected
> 
> Just a few question though. In
> 
> xinput list-props "CyPS/2 Cypress Trackpad"
> [...]
> 	Coordinate Transformation Matrix (140): 1.000000, 0.000000, 0.000000,
> 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
> [...]
>         libinput Scroll Methods Available (286):        1, 1, 0
> 
> what are the Coordinate Transformation Matrix about?

It's a property initialised by the X server to apply transformation to the
input devices. for absolute devices this allows for rotation, scaling, etc.
for relative devices it only allows for rotation. This isn't a libinput
feature though, it's been part of the X server for a number of years, google
should provide you with plenty of info on where to use it. though with a
touchpad, you won't need it .

> I assume "libinput Scroll Methods Available" bits are respectively for
> two fingers, three fingers and four fingers scrolling detection right?

man libinput brings up the man page for the xf86-input-libinput driver and
lists the property as:
  libinput Scroll Methods Available
    3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge",
    "button".  Indicates  which scroll methods are available on this device.

> Also as I added the constant LIBINPUT_CONFIG_SCROLL_3FG, I had to adapt
> the code which was using LIBINPUT_CONFIG_SCROLL_*2*FG. Also I don't know
> if four, fingers, needs to be implemented.
> 
> I dont know if my changes are correct. Mr Hutterer, please correct me if
> I'm wrong, this is a great exercise for me, as I'm always willing to learn.

we have 2-finger scrolling as special method, but for anything 3 fingers and
more we switch to gestures, specifically pinch+rotate and swipe (note: a
2fg scroll is nothing but a swipe gesture but it was there first before we
had gesture support, hence the different handling). if you want to use
3-finger scroll you'll need to convert from the swipe gesture to scroll
events in the caller. but implementing a specific 3-finger scroll support is
not something I want to have in libinput, it's too much of a niche case. 2fg
scroll is well established.

> diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
> index a910bec..ba465f0 100644
> --- a/src/evdev-mt-touchpad-gestures.c
> +++ b/src/evdev-mt-touchpad-gestures.c
> @@ -380,6 +380,9 @@ tp_gesture_handle_state_scroll(struct tp_dispatch *tp, uint64_t time)
>  	if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
>  		return GESTURE_STATE_SCROLL;
>  
> +	if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_3FG)
> +		return GESTURE_STATE_SCROLL;
> +
>  	delta = tp_get_average_touches_delta(tp);
>  
>  	/* scroll is not accelerated */
> @@ -516,11 +519,14 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
>  }
>  
>  void
> -tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
> +tp_gesture_stop_multifinger_scroll(struct tp_dispatch *tp, uint64_t time)
>  {
>  	if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
>  		return;
>  
> +	if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_3FG)
> +		return;
> +
>  	evdev_stop_scroll(tp->device,
>  			  time,
>  			  LIBINPUT_POINTER_AXIS_SOURCE_FINGER);
> @@ -545,7 +551,7 @@ tp_gesture_end(struct tp_dispatch *tp, uint64_t time, bool cancelled)
>  				 __func__);
>  		break;
>  	case GESTURE_STATE_SCROLL:
> -		tp_gesture_stop_twofinger_scroll(tp, time);
> +		tp_gesture_stop_multifinger_scroll(tp, time);
>  		break;
>  	case GESTURE_STATE_PINCH:
>  		gesture_notify_pinch_end(&tp->device->base, time,
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index a7b5a87..b8bdd2e 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -660,7 +660,7 @@ tp_palm_detect_multifinger(struct tp_dispatch *tp, struct tp_touch *t, uint64_t
>  		return false;
>  
>  	/* If we have at least one other active non-palm touch make this
> -	 * touch non-palm too. This avoids palm detection during two-finger
> +	 * touch non-palm too. This avoids palm detection during multifinger
>  	 * scrolling.
>  	 *
>  	 * Note: if both touches start in the palm zone within the same
> @@ -1851,7 +1851,7 @@ tp_scroll_config_scroll_method_set_method(struct libinput_device *device,
>  		return LIBINPUT_CONFIG_STATUS_SUCCESS;
>  
>  	tp_edge_scroll_stop_events(tp, time);
> -	tp_gesture_stop_twofinger_scroll(tp, time);
> +	tp_gesture_stop_multifinger_scroll(tp, time);
>  
>  	tp->scroll.method = method;
>  
> diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> index fe1f1b3..d9b2b8c 100644
> --- a/src/evdev-mt-touchpad.h
> +++ b/src/evdev-mt-touchpad.h
> @@ -522,7 +522,7 @@ void
>  tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time);
>  
>  void
> -tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
> +tp_gesture_stop_multifinger_scroll(struct tp_dispatch *tp, uint64_t time);
>  
>  bool
>  tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t);
> diff --git a/src/libinput.c b/src/libinput.c
> index a8240bd..4ee788b 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -3772,6 +3772,7 @@ libinput_device_config_scroll_set_method(struct libinput_device *device,
>  	switch (method) {
>  	case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
>  	case LIBINPUT_CONFIG_SCROLL_2FG:
> +	case LIBINPUT_CONFIG_SCROLL_3FG:
>  	case LIBINPUT_CONFIG_SCROLL_EDGE:
>  	case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
>  		break;
> diff --git a/src/libinput.h b/src/libinput.h
> index 83e58b6..d4d1cd9 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -4700,6 +4700,11 @@ enum libinput_config_scroll_method {
>  	 */
>  	LIBINPUT_CONFIG_SCROLL_EDGE = (1 << 1),
>  	/**
> +	 * Send scroll events when three fingers are logically down on the
> +	 * device.
> +	 */
> +	LIBINPUT_CONFIG_SCROLL_3FG = 3,
> +	/**

if you look at the other values in this struct they're bitmasks, a value of
3 would be equivalent to 2fg and edge scroll set at the same time.
generally any time a value is specified as bitshift you can assume it's a
mask. and the same is usually true for a hex value that are multiples of 2
(0x2, 0x4, 0x8, ...).

aside from this it looks roughly correct, but I've only skimmed the patch
and not switched my brain on for the gesture state. As I said, multifinger
scrolling is not something libinput will get in the foreseeable future,
sorry.

Cheers,
   Peter

>  	 * Send scroll events when a button is down and the device moves
>  	 * along a scroll-capable axis.
>  	 */
> diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c
> index 2869dd7..938c2a7 100644
> --- a/tools/libinput-list-devices.c
> +++ b/tools/libinput-list-devices.c
> @@ -151,9 +151,11 @@ scroll_defaults(struct libinput_device *device)
>  	method = libinput_device_config_scroll_get_default_method(device);
>  
>  	xasprintf(&str,
> -		 "%s%s%s%s%s%s",
> +		 "%s%s%s%s%s%s%s%s",
>  		 (method == LIBINPUT_CONFIG_SCROLL_2FG) ? "*" : "",
>  		 (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) ? "two-finger " : "",
> +		 (method == LIBINPUT_CONFIG_SCROLL_3FG) ? "*" : "",
> +		 (scroll_methods & LIBINPUT_CONFIG_SCROLL_3FG) ? "three-finger " : "",
>  		 (method == LIBINPUT_CONFIG_SCROLL_EDGE) ? "*" : "",
>  		 (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE) ? "edge " : "",
>  		 (method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) ? "*" : "",
> @@ -308,8 +310,11 @@ print_device_notify(struct libinput_event *ev)
>  		printf("tablet-pad");
>  	printf("\n");
>  
> +    if (libinput_device_config_tap_get_finger_count(dev) > 0)
> +        printf("Max. fingers:     %d\n",
> +        libinput_device_config_tap_get_finger_count(dev));
>  	printf("Tap-to-click:     %s\n", tap_default(dev));
> -	printf("Tap-and-drag:     %s\n",  drag_default(dev));
> +	printf("Tap-and-drag:     %s\n", drag_default(dev));
>  	printf("Tap drag lock:    %s\n", draglock_default(dev));
>  	printf("Left-handed:      %s\n", left_handed_default(dev));
>  	printf("Nat.scrolling:    %s\n", nat_scroll_default(dev));
> diff --git a/tools/shared.c b/tools/shared.c
> index 29af9ef..9b4ac66 100644
> --- a/tools/shared.c
> +++ b/tools/shared.c
> @@ -97,7 +97,7 @@ tools_usage()
>  	       "--enable-dwt\n"
>  	       "--disable-dwt..... enable/disable disable-while-typing\n"
>  	       "--set-click-method=[none|clickfinger|buttonareas] .... set the desired click method\n"
> -	       "--set-scroll-method=[none|twofinger|edge|button] ... set the desired scroll method\n"
> +	       "--set-scroll-method=[none|twofinger|threefinger|edge|button] ... set the desired scroll method\n"
>  	       "--set-scroll-button=BTN_MIDDLE ... set the button to the given button code\n"
>  	       "--set-profile=[adaptive|flat].... set pointer acceleration profile\n"
>  	       "--set-speed=<value>.... set pointer acceleration speed\n"
> @@ -272,6 +272,9 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
>  			} else if (streq(optarg, "twofinger")) {
>  				options->scroll_method =
>  				LIBINPUT_CONFIG_SCROLL_2FG;
> +			} else if (streq(optarg, "threefinger")) {
> +				options->scroll_method =
> +				LIBINPUT_CONFIG_SCROLL_3FG;
>  			} else if (streq(optarg, "edge")) {
>  				options->scroll_method =
>  				LIBINPUT_CONFIG_SCROLL_EDGE;





> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel



More information about the wayland-devel mailing list