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

RFC: all–key settings for multi–key remappings #30

Open
mmazur opened this issue Oct 16, 2020 · 0 comments
Open

RFC: all–key settings for multi–key remappings #30

mmazur opened this issue Oct 16, 2020 · 0 comments

Comments

@mmazur
Copy link

mmazur commented Oct 16, 2020

When remapping a key 1:1, any additional modifications can be applied to the target key, like so:

    KEY_LEFTMETA:
    - code: KEY_LEFTALT
      arg1: true
      arg2: false

This syntax works great with 1:1. The issue I'm having is with 1:N, where the goal is to generate a key combination involving at least one modifier. I'd like to be able to specify arg1 and arg2 that would apply to all remappings.

The way I've hacked it for testing purposes is that I've added code that checks the first remapping and if it finds an argument, it treats it as applying to everything. [code snippet at the end]
But I'd really like there to be a set syntax for "this applies to all N keys in the remapping".

I was thinking something along the lines of the parses detecting whether a key remapping is a list or a dict. If it's a dict, it'd work something like:

KEY_LEFTMETA:
  arg1: true
  arg2: false
  remappings:
  - KEY_LEFTCTRL
  - KEY_C

@philipl would a patch adding such "global" settings be a thing you'd be open to?

And for context, this is the approach I'm currently testing for making remappings involving modifiers keys less prone to getting wedged (I'm using a bunch KEY_LEFTMETA+KEY and end up with xorg thinking that LEFTMETA is permanently down like a lot of the times).

def remap_event(output, event, event_remapping):
    (…)
    modifier = event_remapping[0].get('modifier', False)
    if modifier:
        if event.value != 1:
            return
        for remapping in event_remapping:
            event.code = remapping['code']
            event.type = remapping.get('type', None) or original_type
            event.value = 1
            output.write_event(event)
            output.syn()
        for remapping in reversed(event_remapping):
            event.code = remapping['code']
            event.type = remapping.get('type', None) or original_type
            event.value = 0
            output.write_event(event)
            output.syn()
        return
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

1 participant