Giter Site home page Giter Site logo

Comments (4)

wez avatar wez commented on August 26, 2024

I wouldn't expect it to work like that, but it wouldn't surprise me if it has been doing that all along, as my use cases always involve the main key and a modifier key, and it is typically harmless if the modifier continues to be reported.

I don't have a ton of bandwidth to investigate this, so I would value your effort to figure out what's going on and perhaps resolve it!

from evremap.

and3rson avatar and3rson commented on August 26, 2024

I'm experiencing a similar issue While doing further research, it turned out that my issue is unrelated. Keeping this for historic purposes.

[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_RIGHTMETA"]
tap = ["KEY_ESC"]

[[remap]]
input = ["KEY_LEFTMETA", "KEY_I"]
output = ["KEY_UP"]
[[remap]]
input = ["KEY_LEFTMETA", "KEY_J"]
output = ["KEY_LEFT"]
[[remap]]
input = ["KEY_LEFTMETA", "KEY_K"]
output = ["KEY_DOWN"]
[[remap]]
input = ["KEY_LEFTMETA", "KEY_L"]
output = ["KEY_RIGHT"]

When performing the following sequence:

  • press META
  • press J
  • press L
  • release J
  • release L
  • release META

...the following inputs are generated by evremap:

  • LEFT
  • L (exactly when J is released)
  • RIGHT

from evremap.

and3rson avatar and3rson commented on August 26, 2024

Seems like the issue might be due to evremap releasing the modifier (META) once J is pressed. I've added some logs to debug this, here's the output of my previous key sequence:

 2023-07-02T01:13:12.439 ERROR evremap::remapper > Press [KEY_RIGHTMETA]
 2023-07-02T01:13:12.520 ERROR evremap::remapper > Press [KEY_LEFT]
 2023-07-02T01:13:12.520 ERROR evremap::remapper > Release [KEY_RIGHTMETA]
 2023-07-02T01:13:12.571 ERROR evremap::remapper > Press [KEY_L]
 2023-07-02T01:13:12.614 ERROR evremap::remapper > Press [KEY_RIGHT]
 2023-07-02T01:13:12.614 ERROR evremap::remapper > Release [KEY_LEFT, KEY_L]
 2023-07-02T01:13:12.657 ERROR evremap::remapper > Press [KEY_RIGHTMETA]
 2023-07-02T01:13:12.657 ERROR evremap::remapper > Release [KEY_RIGHT]
 2023-07-02T01:13:12.723 ERROR evremap::remapper > Release [KEY_RIGHTMETA]

Here's the logs of me pressing META+J alone:

 2023-07-02T01:14:21.745 ERROR evremap > Short delay: release any keys now!
 2023-07-02T01:14:24.121 ERROR evremap::remapper > Going into read loop
 2023-07-02T01:14:24.863 ERROR evremap::remapper > Press [KEY_RIGHTMETA]
 2023-07-02T01:14:25.092 ERROR evremap::remapper > Press [KEY_LEFT]
 2023-07-02T01:14:25.092 ERROR evremap::remapper > Release [KEY_RIGHTMETA] <---- fake release
 2023-07-02T01:14:25.252 ERROR evremap::remapper > Press [KEY_RIGHTMETA]   <---- followed by a press again 
 2023-07-02T01:14:25.252 ERROR evremap::remapper > Release [KEY_LEFT]
 2023-07-02T01:14:25.580 ERROR evremap::remapper > Release [KEY_RIGHTMETA]

This also happens when I use a single-role modifier, e. g. CTRL or LEFTMETA.

EDIT: When I press META+J, desired_keys becomes empty. I think this is what causes evremap to release the modifier. Inside compute_keys, keys still contain META & J during first phase, however they are removed during second phase. This seems like a tricky situation, since:

  • It makes sense for evremap to release META during substitution (to properly generate LEFT instead of META+LEFT), however evremap needs to remember that META was pressed in order to generate proper remap for a second press while first press has not been released yet.
  • It seems like evremap sees META, J, & L pressed all together, and it substitutes META+J from the list, thus treating L as pressed without a modifier. This means evremap will probably need to differentiate between modifiers and non-modifier keys.

EDIT 2: I was able to resolve my issue with the following patch:

diff --git a/src/remapper.rs b/src/remapper.rs
index 0e90697..2965184 100644
--- a/src/remapper.rs
+++ b/src/remapper.rs
@@ -164,13 +164,17 @@ impl InputMapper {
                 if input.is_subset(&keys_minus_remapped) {
                     for i in input {
                         keys.remove(i);
-                        keys_minus_remapped.remove(i);
+                        if !is_modifier(i) {
+                            keys_minus_remapped.remove(i);
+                        }
                     }
                     for o in output {
                         keys.insert(o.clone());
                         // Outputs that apply are not visible as
                         // inputs for later remap rules
-                        keys_minus_remapped.remove(o);
+                        if !is_modifier(o) {
+                            keys_minus_remapped.remove(o);
+                        }
                     }
                 }
             }

Not sure if there are any side effects to this, but this made my life much easier! The idea here is to allow modifier keys to be reused for multiple remaps, e. g. when keys that are pressed trigger multiple remaps with shared key, e. g. META+J+K -> META+J and META+K. Let me know what you think.

from evremap.

mikezila avatar mikezila commented on August 26, 2024

I'm still getting this behavior when trying to turn a trio of keys into arrow keys on a 60% keyboard.

[[remap]]
input = ["KEY_RIGHTALT"]
output = ["KEY_LEFT"]

[[remap]]
input = ["KEY_RIGHTCTRL"]
output = ["KEY_RIGHT"]

[[remap]]
input = ["KEY_COMPOSE", "KEY_RIGHTALT"]
output = ["KEY_UP"]

[[remap]]
input = ["KEY_COMPOSE", "KEY_RIGHTCTRL"]
output = ["KEY_DOWN"]

[[remap]]
input = ["KEY_COMPOSE"]
output = []

My goal is to use right alt and control as left and right, and also as up and down if I'm holding the compose key. It does work, but when doing the combinations I still get left and right inputs instead of just the up and down. I've tried it with the rules in various orders and the behavior is always the same.

from evremap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.