[PATCH v2 libinput 4/6] evdev: enable middle button configuration on some devices

Hans de Goede hdegoede at redhat.com
Thu Apr 16 01:03:23 PDT 2015


Hi,

On 16-04-15 07:39, Peter Hutterer wrote:
> Devices that have left and right buttons but no middle button get middle
> button emulation (without config). Devices that have a middle button too get
> a config option but default to off. Most mice have LMR set as buttons,
> regardless whether they have a middle button.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> Reviewed-by: Hans de Goede <hdegoede at redhat.com>
> ---
> Changes to v1:
> - use extra variables to make the code clearer, no functional changes
>    otherwise

Looks good:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

>
>   src/evdev.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 6ca874a..da33eae 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1143,6 +1143,24 @@ fallback_dispatch_create(struct libinput_device *device)
>   	evdev_init_calibration(evdev_device, dispatch);
>   	evdev_init_sendevents(evdev_device, dispatch);
>
> +	/* BTN_MIDDLE is set on mice even when it's not present. So
> +	 * we can only use the absense of BTN_MIDDLE to mean something, i.e.
> +	 * we enable it by default on anything that only has L&R.
> +	 * If we have L&R and no middle, we don't expose it as config
> +	 * option */
> +	if (libevdev_has_event_code(evdev_device->evdev, EV_KEY, BTN_LEFT) &&
> +	    libevdev_has_event_code(evdev_device->evdev, EV_KEY, BTN_RIGHT)) {
> +		bool has_middle = libevdev_has_event_code(evdev_device->evdev,
> +							  EV_KEY,
> +							  BTN_MIDDLE);
> +		bool want_config = has_middle;
> +		bool enable_by_default = !has_middle;
> +
> +		evdev_init_middlebutton(evdev_device,
> +					enable_by_default,
> +					want_config);
> +	}
> +
>   	return dispatch;
>   }
>
>


More information about the wayland-devel mailing list