You are not logged in.

#1 2017-11-29 05:04:55

cozisco
Member
Registered: 2017-10-20
Posts: 7

[SOLVED] Remapping middle-mouse button with xinput

I've been using the Kensington Expert Wireless Trackball for a while now and I like it. It works great out of the box, with the 4 buttons mapped as left-click (logical button 1), right-click (logical button 3), middle-click (logical button 2) and a back button (XF86Back; logical button 8). What I'd like to do is remap them so that I have right-click (logical button 1), left-click (logical button 3), forward button (logical button 9) and back button (logical button 8), while preserving middle-click functionality (logical button 2) by simultaneously pressing the left and right buttons.

It's easy to turn on middle click emulation with libinput so that simulatneously pressing the left and right buttons simulates clicking the middle button:

xinput set-prop your-device-name "libinput Middle Emulation Enabled" 1

Remapping the mouse buttons is easy enough to do according to libinput #Manual button re-mapping by using

$ xinput set-button-map your-device-name 1 8 3 4 5 6 7 9 2 

Combining these two techniques doesn't work as expected. Simultaneously pressing physical buttons 1 and 3 (left and right click) simulates physical button 2 (which has been remapped to logical button 8), rather than logical button 2. Any suggestions of how I can simulate logical button 2 instead? I was thinking of using xbindkeys, but it can't detect simultaneous button presses.

Last edited by cozisco (2017-11-30 19:34:11)

Offline

#2 2017-11-29 08:50:56

seth
Member
Registered: 2012-09-03
Posts: 51,299

Re: [SOLVED] Remapping middle-mouse button with xinput

xmodmap?

Offline

#3 2017-11-29 19:26:01

cozisco
Member
Registered: 2017-10-20
Posts: 7

Re: [SOLVED] Remapping middle-mouse button with xinput

How do you mean? I can turn on middle button emulation using xinput and then remap buttons using

xmodmap -e "pointer = 1 8 3 4 5 6 7 9 2"

But the functionality is the same as in my original post. Is there a way to remap simultaneous button presses using xmodmap?

Last edited by cozisco (2017-11-29 23:41:01)

Offline

#4 2017-11-29 19:39:56

seth
Member
Registered: 2012-09-03
Posts: 51,299

Re: [SOLVED] Remapping middle-mouse button with xinput

No. The idea was that xmodmap operates on a different layer than xinput (I guess it should be "1 8 3 4 5 6 7 9 2", though?) - but it doesn't (neither with evdev, just tried)

"man evdev" however has

Option "Emulate3Button" "integer"
              Specifies the physical button number to be emitted if middle  button  emulation  is  triggered.   Default:  2.
              Property: "Evdev Middle Button Button".

what sounds pretty promising.

Offline

#5 2017-11-30 00:58:05

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [SOLVED] Remapping middle-mouse button with xinput

Have you tried combining LeftHanded with the emulation? I believe this is preferred now over explicitly mapping the buttons by number. (I think, from your description, that you are switching the buttons for left-handed use. If I've misunderstood, ignore this suggestion.)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2017-11-30 19:32:11

cozisco
Member
Registered: 2017-10-20
Posts: 7

Re: [SOLVED] Remapping middle-mouse button with xinput

@cfr - Sorry, sometimes it's hard to follow my writing. I'm not trying to do LeftHanded, but trying to remap and rearrange to a completely different layout.

@seth - good catch. It should indeed be "1 8 3 4 5 6 7 9 2" and I edited my previous post accordingly. Your evdev suggestion worked! I just had to include all the options

Option "ButtonMapping" "1 8 3 4 5 6 7 9 2"
Option "Emulate3Buttons" "True"
Option "Emulate3Button" "9"

Thanks so much!

Offline

Board footer

Powered by FluxBB