Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify maps with modifiers #9

Open
fhill2 opened this issue Jan 8, 2022 · 2 comments
Open

Simplify maps with modifiers #9

fhill2 opened this issue Jan 8, 2022 · 2 comments

Comments

@fhill2
Copy link

fhill2 commented Jan 8, 2022

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
Copy link
Owner

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:

  • The key after hold= would have to be interpreted with the same semantics as used by --hook which are different from the semantics used by --map (i.e. an unspecified event value is interpreted as 1~ by --hook, whereas --map interprets it as "any value");
  • There would have to be some "consistent" mode for maps similar to how --toggle treats EV_KEY type events differently from other events.

... 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
Copy link
Author

fhill2 commented Jan 9, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants