Middle Mouse Button Emulation

I want to have my system read a simultaneous left/right click as a middle mouse button because my mouse wheel is broken and doesn’t work well. I’m currently using XFCE and, unlike in KDE Plasma, I see no easy way to do this. I’ve had trouble doing so with help from AI and online sources, and I have not yet encountered an existing post here that contains the solution to my problem. I’ve attempted using xinput set-prop 13 "libinput Middle Emulation Enabled" 1 but to no avail. To be clear, I want to do this for my wireless logitech mouse, as opposed to the touchpad I have built in on my laptop. Please let me know what info you need in order to help!

Are you sure your device ID is really 13?

Run xinput by itself to find the mouse’s ID, then replace 13 with that number.

I’ve never encountered a broken mouse wheel which couldn’t be fixed by disassembling it and giving a proper cleaning.

But my kudos for your attempt to work around the issue :wink:

I’m using soolar for my logitech mx ergo, and that device manager allows the creation of custom rule sets documented here.

I am sure. I did as you suggested and confirmed this.

EDIT: I’m dumb, I should actually include the output for xinput:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Logitech Wireless Keyboard PID:4023     	id=12	[slave  pointer  (2)]
⎜   ↳ Logitech Wireless Mouse                 	id=13	[slave  pointer  (2)]
⎜   ↳ PNP0C50:00 04F3:30AA Mouse              	id=14	[slave  pointer  (2)]
⎜   ↳ PNP0C50:00 04F3:30AA Touchpad           	id=15	[slave  pointer  (2)]
⎜   ↳ ETPS/2 Elantech Touchpad                	id=17	[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)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Video Bus                               	id=8	[slave  keyboard (3)]
    ↳ Lid Switch                              	id=9	[slave  keyboard (3)]
    ↳ Power Button                            	id=10	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=11	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=16	[slave  keyboard (3)]
    ↳ MSI WMI hotkeys                         	id=18	[slave  keyboard (3)]
    ↳ Logitech Wireless Keyboard PID:4023     	id=19	[slave  keyboard (3)]
    ↳ Logitech Wireless Mouse                 	id=20	[slave  keyboard (3)]
    ↳ Corsair CORSAIR VOID ELITE Wireless Gaming Dongle	id=21	[slave  keyboard (3)]

Of course you will note the Logitech Wireless Mouse with an id of 20 under Virtual core keyboard but on further examination there are no buttons to map, so I’m assuming it has to do with the bluetooth connection aspect of the mouse.

Run xinput --list-props 13, and if "libinput Middle Emulation Enabled" is not present, it seems libinput doesn’t know how to do that for your mouse (and KDE warns that this feature adds 50ms of click latency)

A quick way to do this is by xinput --list-props 13 | grep "libinput Middle Emulation Enabled"

Also, changes with xinput do not save. However, I tested middle click emulation and it works fine for me, so YMMV. (I turned it off right after lol).

It looks like setting libinput Middle Emulation Enabled to 1 works. How do I make sure this change is permanent, since as you pointed out, xinput changes don’t save? Also, how do I make it so that I not only can simulate a mouse click like this, but use leftandright click to scroll?

(if that’s too much work for you, just put the command in ~/.xprofile or ~/.bashrc, but make sure to replace 13 with "Logitech Wireless Mouse", as the id may change.)

Alright, so I was able to get my leftandright middle mouse click into ~/.bashrc so that’s all set I think. I even got my mouse wheel input disabled with solaar, so that’s also working (I enabled scroll wheel diversion). Now I’m just trying to apply what the libinput wiki page discusses in section 3.6 “Scroll with mouse by holding a button”. Following its example, I created a mouse config file found on the following path: /etc/X11/xorg.conf.d/00-mouse.conf

This config file has seemingly done nothing, and so I’m wondering where I’ve gone wrong. The wiki, so far as I’ve seen thus far, does not seem to have further details about writing such a config file. I’ll double check to see if I missed anything, but would appreciate some help on this final aspect of my problem.

EDIT: As I’m wracking my brain about this, I wonder if I’ve put the wrong information in one of the fields. Here are the contents of my config file:

Section "InputClass"
	Identifier "Logitech Wireless Mouse"
	MatchIsPointer "on"
	Option "ScrollMethod" "button"
	Option "ScrollButton" "3"
EndSection

It’s possible that Option "ScrollButton" does not like the emulated 3 button press, but unlikely.

Just so you know, you need to log in and out (or restart) for those file to be read.

Alright, it looks like setting Option "ScrollButton" to “2” did the trick. I didn’t know about the logging out and back in part, so that was important to seeing the result. Seeing how my left and right click acts as a middle mouse click and can be held down to scroll with, I’m considering this a closed matter. Thank you!

Summary (for anyone seeing this thread for their own troubleshooting): I made a leftandright click act as a middle mouse click by using xinput to set libinput Middle Emulation Enabled to 1. I added the command xinput set-prop pointer:"Logitech Wireless Mouse" "libinput Middle Emulation Enabled" 1 to ~/.bashrc to make sure the change stuck without me having to manually run the command everytime I rebooted my system. I also made a terminal open on startup since only then would the command in ~/.bashrc run. For making my leftandright click scroll like a mouse wheel when I hold it down and move the mouse, I created a config file in /etc/X11/xorg.conf.d/ called 00-mouse.conf and put the following information in it:

Section "InputClass"
	Identifier "Logitech Wireless Mouse"
	MatchIsPointer "on"
	Option "ScrollMethod" "button"
	Option "ScrollButton" "2"
EndSection

I then logged out and back in to see those changes take effect. Hopefully this helps someone else! It is also worth noting that, for some reason, that using solaar to enabled Scroll Wheel Diversion on my mouse disabled my mouse wheel scroll, which was helpful because my mouse wheel is wonky. Furthermore, I seem to need to launch solaar once to make sure it loads up that setting for my mouse after I’ve rebooted, although I’m not really sure how that works.

I also made a terminal open on startup since only then would the command in ~/.bashrc run

This is why you should probably use ~/.xprofile, as almost all display managers will source that for you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.