wez / evremap

A keyboard input remapper for Linux/Wayland systems, written by @wez
MIT License
392 stars 31 forks source link

Keyboard and mouse combo remap #14

Open Ashark opened 2 years ago

Ashark commented 2 years ago

There is imwheel tool for X11, that allows you to remap mouse wheel events combined with keyboard modifiers. I am looking for this functionality on wayland.

The problem is that afaik, this tool (evremap) currently only allow you to map a single device, while thing that I want requires two devices.

This works (remaps mouse button):

device_name = "Logitech MX Master"

[[remap]]
input = ["BTN_RIGHT"]
output = ["KEY_PAGEUP"]

This also works (remaps keyboard combination):

device_name = "Logitech K850"

[[remap]]
input = ["KEY_LEFTALT", "KEY_UP"]
output = ["KEY_PAGEUP"]

But such thing does not work:

device_name = ["Logitech MX Master", "Logitech K850"]

[[remap]]
input = ["KEY_LEFTALT", "BTN_RIGHT"]
output = ["KEY_PAGEUP"]

because device_name is expected to be a string. Can we hope such functionality will be implemented?

Ashark commented 2 years ago

I was able to merge keyboard and mouse to a single virtual device, which allowed this remap:

device_name = "virtual merged device"

[[remap]]
input = ["KEY_LEFTALT", "BTN_RIGHT"]
output = ["KEY_PAGEUP"]

But the problem now seems to be in specifying a mouse wheel event instead of button in the config. Is something like this possible?

device_name = "virtual merged device"

[[remap]]
input = ["KEY_LEFTALT", "REL_WHEEL"]
output = ["KEY_LEFTCTRL", "REL_WHEEL"]

The utility needs to handle that REL_WHEEL somehow. It is not in evremap list-keys apparently.

wez commented 2 years ago

It's been a while since I looked at this...

https://github.com/wez/evremap/blob/master/src/mapping.rs#L53 uses KeyCode for its type, which is an alias for https://docs.rs/evdev-rs/latest/evdev_rs/enums/enum.EV_KEY.html

If the evremap code were to target https://docs.rs/evdev-rs/latest/evdev_rs/enums/enum.EventCode.html instead of the alias, then it would be possible to match any event.

A lot of the code assumes EV_KEY so it's not a trivial one-line change, but I think a lot of the changes would be fairly mechanical in nature.

I don't have time to look at this myself, but I'd be open to seeing a PR that extends evremap in this way!