evdevremapkeys
evdevremapkeys copied to clipboard
RFC: all–key settings for multi–key remappings
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