Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add libinput support for mouse and touchpad #166

Merged
merged 11 commits into from
Jan 2, 2017
Merged

add libinput support for mouse and touchpad #166

merged 11 commits into from
Jan 2, 2017

Conversation

monsta
Copy link
Contributor

@monsta monsta commented Dec 24, 2016

This is backported from linuxmint/cinnamon-settings-daemon#131 (big thanks to @whot for this).

@clefebvre @flexiondotorg @raveit65 @XRevan86 @sc0w @lukefromdc
Please test it guys if you can. You'll need libinput driver for Xorg installed and taking priority over evdev and Synaptics. You can use xinput tool to check device properties and their values. For example, here's how my old mouse is shown:

monsta@asylum ~ $ xinput --list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Logitech USB-PS/2 Optical Mouse         	id=8	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Power Button                            	id=7	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=9	[slave  keyboard (3)]
monsta@asylum ~ $ xinput --list-props 8
Device 'Logitech USB-PS/2 Optical Mouse':
	Device Enabled (152):	1
	Coordinate Transformation Matrix (154):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
	libinput Accel Speed (285):	-0.069767
	libinput Accel Speed Default (286):	0.000000
	libinput Accel Profiles Available (287):	1, 1
	libinput Accel Profile Enabled (288):	1, 0
	libinput Accel Profile Enabled Default (289):	1, 0
	libinput Natural Scrolling Enabled (290):	0
	libinput Natural Scrolling Enabled Default (291):	0
	libinput Send Events Modes Available (269):	1, 0
	libinput Send Events Mode Enabled (270):	0, 0
	libinput Send Events Mode Enabled Default (271):	0, 0
	libinput Left Handed Enabled (292):	0
	libinput Left Handed Enabled Default (293):	0
	libinput Scroll Methods Available (294):	0, 0, 1
	libinput Scroll Method Enabled (295):	0, 0, 0
	libinput Scroll Method Enabled Default (296):	0, 0, 0
	libinput Button Scrolling Button (297):	2
	libinput Button Scrolling Button Default (298):	274
	libinput Middle Emulation Enabled (299):	1
	libinput Middle Emulation Enabled Default (300):	0
	Device Node (272):	"/dev/input/event3"
	Device Product ID (273):	1133, 49214
	libinput Drag Lock Buttons (301):	<no items>
	libinput Horizonal Scroll Enabled (274):	1

Since m-c-c doesn't have libinput support yet (for example, it only checks for Synaptics presence to determine whether to show touchpad settings tab), you'll probably have to use other tools for changing GSettings keys in org.mate.peripherals-mouse and org.mate.peripherals-touchpad schemas.

Here are some details about differences between old code (for evdev and Synaptics) and libinput support code. Sorry @whot... I have some additional questions for you below, please forgive my ignorance 😄

  • tap to click (4e098ea): when setting this property, libinput part of code doesn't take left-handed and 1/2/3 finger tap properties into account. While left-handed property isn't needed here (libinput manages it on its own), I'm not sure about finger tap ones. It wasn't an issue in Cinnamon since it seems to be MATE-only option (added in Settings for touchpad taps #86). Should we do anything about 1/2/3 finger tap properties in libinput parts of code?

  • edge and two-finger scrolling (c75315d): libinput only allows either one to be enabled at the same time. Following the Cinnamon code, I've made two-finger one preferable. However, each property is set in its own boolean value in libinput (in libinput Scroll Method Enabled property), so could it be theoretically possible for libinput to support both at the same time in some future release?

  • click actions (43bc83e): libinput doesn't support setting two or three finger click, there's only a single "clickfinger" setting (or no finger click if "buttonareas" is set instead). Since it's a single boolean value (in libinput Click Method Enabled property), I guess we have no way to tell libinput whether we prefer two or three finger click. So the question is, which of them will actually work when "clickfinger" is enabled in libinput?

  • left-handed (2bc9262): libinput part of code doesn't use button remapping as libinput handles that by itself. But does libinput check if a device has a single button (or any buttons at all)? In the old code, there are checks for that before making any changes.

  • acceleration (f2b0f0c): libinput doesn't have a setting for a threshold. That setting is called "sensitivity" in mouse and touchpad properties UI, but it really is a "distance in pixels the pointer must move before accelerated mouse/touchpad motion is activated". So does libinput use some internal value for it?

@lukefromdc
Copy link
Member

Most of the laptop settings I cannot easily test, as I develop on a desktop and it is a considerable production to move everything over to it and update. That is done at intervals but not while I am using the desktop.

Of the laptop settings, for me it is really crucial that disable while typing either not default to on or be easily disabled. If I have to set custom values somwhere that can't later be reset in mate-settings-daemon I could easily forget ever having done so and thus miss a failure of such a setting in m-s-d to work.

The disable while typing situation has at times in the past caused me enough trouble when using the laptop to force me to disable syndaemon so as to disable it when normal settings did not work.

@raveit65
Copy link
Member

raveit65 commented Dec 25, 2016

Can we revert version requirement in this branch for testing?
MATE_DESKTOP_REQUIRED_VERSION and LIBMATEKBD_REQUIRED_VERSION
Than it should be possible to use it with 1.16 packages.
I don't want to update my notebook to fedora rawhide yet. My main box have a rawhide installation but no touchpad ;-)
Edit:
m-c-c needs also to be patched
https://github.com/mate-desktop/mate-control-center/blob/master/configure.ac#L65
Edit again:
I noticed that i haven't update my notebook to f25, here i use f24 with mate gtk3 + 1.17 :-)
.... so i can test touchpad settings......but i don't like to use it ;-)

@raveit65
Copy link
Member

Btw. mouse settings seems to be working with m-c-c or dconf-editor, except 'show pointer'.
This setting have no effect, but i don't use it normal and i don't know what effect i should see.
Or do we need evdev driver for this?

@raveit65
Copy link
Member

Ok, i think touchpad and most settings for it are working.
Maybe changing settings for tab-button-one-[two]-[three]-finger do not work.
Sorry, this needs to tested more by someone who like to use a stupid touchpad.

@lukefromdc
Copy link
Member

I can confirm mouse settings working on Debian Unstable except of course "show pointer." Wonder if libinput simply does not support that? I'll test the touchpad settings as soon as I can get this and my other updates over to the laptop

@lukefromdc
Copy link
Member

OK, I can now confirm that touchpad settings also work, though I am by no means certain whether libinput or Synaptics is taking priority on that. i was able to verify that the crucial setting to enable or disable "disable touchpad while typing" is working.

@lukefromdc
Copy link
Member

The touchpad settings work even when org.gnome.desktop.peripherals.touchpad send-events is set to "disabled" in gsettings, reverting the fix that used to be necessary to get the touchpad to show up at all in m-c-c.

@whot
Copy link

whot commented Dec 27, 2016

If you want to test the touchpad code without a touchpad, grab https://github.com/whot/evemu-devices and init any touchpad with sudo evemu-device. That will make a virtual touchpad appear, you can then check whether the right properties are toggled with xinput watch-props "..device name..."
If the properties change, then your code is correct, any other bug would be in the xf86-libinput driver or libinput itself.

As for the original questions:

  • tap: libinput does not expose the same configuration, you can enable tapping or not. You don't have per-finger configuration options, but newer versions expose a libinput_device_config_tap_set_button_map() call to change between LRM and LMR button mappings. iirc that was added after the cinnamon patches.
  • scrolling: libinput only supports either edge or two-finger scrolling, not both. that won't change.
  • click actions: are always 2-finger right 3-finger middle in libinput, no other configuration is available
  • left-handed: libinput only exposes left-handed settings when appropriate, so on one-button devices it won't allow for left-handed mappings. i.e. you don't need to worry about it
  • acceleration: the separate threshold and accel is a legacy from the X protocol, it doesn't exist in libinput, or at least not externally. So that option just doesn't exist.

show pointer: that's something entirely handled by the client, libinput doesn't have a say here. libinput doesn't know where the pointer is anyway.

I think that's all questions answered, sorry, don't have time to review the patches themselves right now. but thanks heaps for implementing this!

@lukefromdc
Copy link
Member

If the separate threshold and acceleration no longer exist with libinput, then they could be combined in the GUI at whatever point all distros are using libinput. Ideally it would detect whether libinput or synaptics was handling the touchpad and show only the relevant options, but that's not something I would be able to code up at this point.

@monsta
Copy link
Contributor Author

monsta commented Jan 2, 2017

About "show pointer": it seems to be broken with GTK+3, I've noticed it a while ago. I remember it was working in GTK+2 build, I've tested it once.

How to check whether libinput is handling your device: use xinput tool as mentioned above. The properties it shows you should start with "libinput" (for both mice and touchpads).

@monsta
Copy link
Contributor Author

monsta commented Jan 2, 2017

@whot: many thanks for the hint about emulation, this is what I've been searching for!

I've used "ETPS/2 Elantech Touchpad" for testing. So far, most options work fine. However, libinput Disable While Typing Enabled and libinput Horizonal Scroll Enabled always stay enabled. I'll test other touchpads later.

@monsta
Copy link
Contributor Author

monsta commented Jan 2, 2017

@whot: thanks for the answers. Looks like no additional code changes are needed here - unless I missed something.

I only have an additional question about that new libinput function (for tapping): would these LRM/LMR mappings be exposed via X properties somehow?

libinput touchpads are recognized by checking if they have
tapping property - same as done here:
linuxmint/cinnamon-settings-daemon@7e48221
note: libinput function doesn't use additional arguments
since no button remapping is needed for it

adapted from:
linuxmint/cinnamon-settings-daemon@8551023
note: libinput does not allow for both edge and twofinger scrolling
to be enabled simultaneously. We prefer twofinger scrolling. The same
goes for horizontal scrolling, it picks the setting for whatever scroll
method we applied.

adapted from:
linuxmint/cinnamon-settings-daemon@8244209
note: libinput does not allow for configuration of the click actions,
the options are just "software buttons" or "clickfinger". If any
clickfinger actions are set, we enable clickfinger, otherwise software
buttons.

adapted from:
linuxmint/cinnamon-settings-daemon@6394ea6
note: libinput function doesn't have button remapping code,
it's handled in libinput already

adapted from:
linuxmint/cinnamon-settings-daemon@c35f952
note: threshold setting is ignored as libinput doesn't have it

adapted from:
linuxmint/cinnamon-settings-daemon@1e7d504
@monsta monsta merged commit 3d5b274 into master Jan 2, 2017
@monsta monsta deleted the dev-libinput branch January 2, 2017 13:57
@monsta monsta mentioned this pull request Jan 2, 2017
@raveit65
Copy link
Member

raveit65 commented Jan 2, 2017

time for a new release....
@flexiondotorg
We need access to server to upload several new releases :-)

@monsta
Copy link
Contributor Author

monsta commented Jan 2, 2017

That's for sure...

@whot
Copy link

whot commented Jan 2, 2017

@monsta: yep, the tapping button map is exposed as "libinput Tapping Button Mapping Enabled", see https://cgit.freedesktop.org/xorg/driver/xf86-input-libinput/tree/include/libinput-properties.h#n47

@monsta
Copy link
Contributor Author

monsta commented Jan 3, 2017

Oh indeed, I see it in my Debian Testing VM (with libinput driver 0.23.0).
Your emulation is awesome, I can use it even in VirtualBox 😄

@monsta
Copy link
Contributor Author

monsta commented Jan 3, 2017

Found out why I couldn't change libinput Disable While Typing Enabled on a virtual touchpad - was my stupid mistake... fixed in 7f86fca.

@raveit65
Copy link
Member

raveit65 commented Jan 3, 2017

@whot
I just tested changes again with my notebook on f24.
For me acceleration is too slow with libinput. I need to stroke 4 times over the touchpad with my finger to reach the other side of the screen (17 inch).
Device is ETPS/2 Elantech Touchpad.
libinput Accel Speed is 1.00
Is this normal?

@whot
Copy link

whot commented Jan 3, 2017

@raveit65 we had some recent fixes in libinput for that, see https://who-t.blogspot.com.au/2016/12/libinput-touchpad-pointer-acceleration.html. That's only on master so far, not in a released version yet.

@monsta
Copy link
Contributor Author

monsta commented Jan 3, 2017

@whot: hmm, looks like I can't get the horizontal scroll property to change because there's "Horizonal" instead of "Horizontal" in the property name...

@whot
Copy link

whot commented Jan 3, 2017

@monsta: that was fixed in xf86-input-libinput-0.20.0, but that one is only in f25, not f24

@raveit65
Copy link
Member

raveit65 commented Jan 4, 2017

@whot
Ok, fine, our support for libinput will be available with mate-1.18 which is for f26.
So fixes for acceleration will hopefully released than.
Mostly i upgraded older releases (f25) only if everything works well after the f26 release.
I guess rhel7 will use synaptics driver until his EOL?

@whot
Copy link

whot commented Jan 4, 2017

yeah, at least by default. don't think I'll switch it to libinput, too many changes.

@monsta
Copy link
Contributor Author

monsta commented Jan 4, 2017

I'm using Mint 18.1 (based on Ubuntu 16.04), and xorg-input-libinput is 0.18.0 here. I presume I need this commit to patch it?

@whot
Copy link

whot commented Jan 5, 2017

yep, that's the one

@monsta
Copy link
Contributor Author

monsta commented Jan 5, 2017

Ok, it works. I'd like to send the patch to Ubuntu maintainers, but not sure which package(s) might use the #define (and would require rebuilding).

@whot
Copy link

whot commented Jan 5, 2017

google suggests apt-cache rdepends should tell you what requires the driver. Easiest would be to just rebuild all of them.

@monsta
Copy link
Contributor Author

monsta commented Jan 7, 2017

Yeah, I know that tool, and it shows nothing here... but I remember it didn't always give me all the reverse deps in the past, so I'm not surprised. I think I'll just ask Ubuntu guys about the packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants