"Regular" mouse button remapping in KWin

I’m having a hard time switching to Wayland because I need to remap mouse buttons, specifically the Back and Middle buttons. I have a Kensington Expert trackball, and button functions are somewhat arbitrary out of the box.

The ButtonRebinds feature in kcminputrc almost covers what I need, but the code in buttonbindsfilter.cpp clearly will map only ExtraButton<x> inputs, which means I can’t rebind the MiddleMouse button.

I’m also not sure if it’s possible to bind a mouse button as the action here.

I wonder why this rebinding feature is restricted to “extra” buttons?

Additionally, it seems the rebinding in global, not per-device. Whereas all the other configuration is per-device. This feels like an oversight :thinking:

Any thoughts?

I’m afraid this isn’t implemented yet; see 475879 – Re-Bind Additional Mouse Buttons menu does not accept bindings to other mouse buttons

I think this may have been intentional, but I agree it should be changed to per-device. It’s on my list of “things to make happen once I find time for it eventually, unless someone else gets there first”.

1 Like

I’d love to scratch this itch myself, and I’ll try to make some time for it, but I am in the wrong lifestage for having spare time :smile: I’ll race you!

I’ve made a little progress, with a merge request here:

This makes it possible to rebind any mouse button by editing the kcminputrc config file:

[ButtonRebinds][Mouse]                                                                                                                                                                                                                                                                                                   
MiddleButton=MouseButton,275                                                                                                                                                                                                                                                                                             
ExtraButton1=MouseButton,274

Native button codes are needed. I expected these to follow the definitions from libinput, so I’m very confused as to why “back” is not 278. I determined by trial and error that it is 275. I’d be curious to find out why.

Next on the to-do list is to make this config per-device instead of global.

2 Likes