KarsMulder / evsieve

A utility for mapping events from Linux event devices.
GNU General Public License v2.0
199 stars 11 forks source link

Simplify maps with modifiers #9

Open fhill2 opened 2 years ago

fhill2 commented 2 years ago

Please correct if there is a better, simplified way I haven't found out yet to reach this desired behaviour:

maps that have 1 source event are intuitive in evsieve and come as a 1 liner: --map key:f2 key:f3

An example of maps with 2 source events: Ctrl+, --> f4

afaik, --toggle --hook need to be used in order to achieve maps with 2 source events.

evsieve --input  /dev/input/by-id/keyboard grab domain=in \
  --toggle key:comma @ctrl-up @ctrl-down mode=passive id=ctrl \
  --hook   key:leftctrl:1 toggle=ctrl:2 \
  --hook   key:leftctrl:0 toggle=ctrl:1 \
  --map key:comma@ctrl-down key:f4 \
  --print \
  --output

This could be simplified by adding the option to change the amount of source events to --map so it can behave like -hook

--map key:leftctrl key:comma key:f4 source=2

What are your thoughts on this?


EDIT: Changes introduced here can now accomplish the above using only --hook (although not documented yet!)

--hook key:leftctrl key:comma send-key='key:f4'

KarsMulder commented 2 years ago

Similar issue: #7

What are your thoughts on this?

I agree evsieve needs a more ergonomic way to do this, but I have still not figured out the best way to do it. There are particularly a lot of edge cases to deal with if we want to conditionally block some input events depending on whether or not a multiple-to-one map happened or not.

--map key:leftctrl key:comma key:f4 source=2

I am not a fan of this syntax because its semantics are different from the usual --map semantics.

If I were to expand the --map to do this, I'd probably do something like --map key:comma key:f4 hold=key:leftctrl, where hold= indicates that the map only applies if the key:leftctrl key is held down, though this approach still has two inelegant points:

... now I think about it, these two inelegant points may be less severe than the mess that --hook withhold or --hook --withhold might create. I should consider this approach some more.

(although not documented yet!)

The documentation in the README is for the latest stable version of evsieve (1.3.1 right now.) The send-key clause is not part of any stable release yet. Features not part of a stable release are subject to getting changed/removed/redesigned at any time, therefore the average user is not recommended to use them.


By the way, in the above script you do not want to use mode=passive on the --toggle because your script would result in a stuck F4 key if you were to press key:leftctrl:1 key:comma:1 key:leftctrl:0 key:comma:0. The consistent mode is the default mode of toggles because it avoids pitfalls like this.

fhill2 commented 2 years ago

Great to hear your thoughts on this and the edge cases that would have to be dealt with if being implemented.

-map key:comma key:f4 hold=key:leftctrl is a better intuitive syntax.

Thank you for clarification on mode=passive vs mode=consistent that I overlooked in my original example.

If you do decide to implement, I'll be looking forward to such a feature.