sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.86k stars 161 forks source link

Mouse button scrolling support ? #590

Open miradnanali opened 1 year ago

miradnanali commented 1 year ago

For decades, I've used the left+right mouse buttons to scroll in X applications.

This can be done from the command prompt in X11 as follows:

xinput set-prop 'Logitech USB Optical Mouse' 'libinput Middle Emulation Enabled' 1 
xinput set-prop 'Logitech USB Optical Mouse' 'libinput Scroll Method Enabled'    0, 0, 1

Or in X configuration files as:

Section "InputClass"
    Identifier  "Mouse"
    MatchIsPointer "yes"
    Option "MiddleEmulation" "true"
    Option "ScrollMethod" "button"
    Option "ScrollButton" "2"
EndSection

Now in Wayland + KDE Plasma, I can run :

sudo libinput list-devices | egrep -B4 ':\s+pointer\s+$'

qdbus org.kde.KWin /org/kde/KWin/InputDevice/event6 org.kde.KWin.InputDevice.scrollOnButtonDown true

qdbus org.kde.KWin /org/kde/KWin/InputDevice/event6 org.kde.KWin.InputDevice.middleEmulation true

However, there's no easy way built-in to map mouse buttons 8 and 9 to pageup and pagedown, and the default binding of these keys to Forward and Back is quite annoying and causes different effects depending on the application receiving the events.

This problem is where input-remapper shines, it works perfectly for that. I can configure middle mouse button emulation, too. But I lose button scrolling.

Is there any way to remap those mouse buttons, and get button scrolling at the same time?

Thanks!

sezanzeb commented 1 year ago

qdbus org.kde.KWin /org/kde/KWin/InputDevice/event6 org.kde.KWin.InputDevice.scrollOnButtonDown true

Have you tried replacing the event* number in the command with the "input-remapper" device numbers found in sudo evtest?

sezanzeb commented 1 year ago

This is how it looks for me when remapping mouse buttons:

sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Power Button
/dev/input/event1:      Power Button
/dev/input/event2:      USB Optical Mouse
/dev/input/event3:      Logitech USB Keyboard
/dev/input/event4:      Logitech USB Keyboard Consumer Control
/dev/input/event5:      Logitech USB Keyboard System Control
/dev/input/event6:      PC Speaker
/dev/input/event7:      input-remapper keyboard
/dev/input/event8:      input-remapper USB Optical Mouse forwarded
Select the device event number [0-8]: 

/dev/input/event8: input-remapper USB Optical Mouse forwarded will get the events that are not mapped, so in this case I'd try "event8" in the path in the qdbus command.

That works for me.


Ah, or use the libinput instead of evtest, that shows them on my computer as well.

niedzielski commented 11 hours ago

thanks for this tool! I ended up using this workaround for Gnome.