netevent
netevent copied to clipboard
Feature: key remapping
Thanks for netevent, it is a fantastic project and configuring it is a very pleasant experience compared to similar tools I have used. One thing that could come in handy would be the ability to remap keys on the fly before sending them over the network. Sometimes the keycodes mapped to hardware buttons make no sense on a remote host and it would be nice to avoid having to install yet another translation layer.
No objection from me. Ideally the implementation would make this available in both daemon & create modes. Also: scaling for relative axes could be added. (Then I wouldn't have to run xinput to set a scaling matrix for my desktop mouse on my laptop anymore... ;-) ) I'll look into this when I have the time (unless someone wants to beat me to it ;-) )
So I'm wondering... should there be a simple key remapping made for now, or perhaps go the fully generic route and allow some kind of script? Like lua? Something like
device set track-relative-axes on
transform add scalex {
if event.key == EV.REL and event.code == 0 then
event.value = event.value * -0.3
endif
}
transform enable my-mouse scalex
vs something like
transform add some-name {
# leaving out a field (it's 'type:code:value') is like a wild-card match:
remap key:123 key:321
# drop key-down on key 321
remap key:321:1 drop
# For swapping to work the 'match' side would have to always match on the original value...
remap rel:0 rel:1
remap rel:1 rel:0
# For scaling see the comment below...
scale rel:0 0.5
# or some kind of matrix transformation: specify up to 3 input axes, a 3x3 matrix and up to 3 output axes... faces the same issues as commented below...
}
transform enable my-kbd some-name
transform enable my-mouse some-name
Also: scaling relative axes would probably be weird since some devices produce a lot of 1
values rather than few higher values. For this the InDevice
class would have to keep track of relative axes with floating point values and only produce events when they exceed 1.0
.
Both implementations would be fine for my purposes as long as they don't require external programs or complicate the compilation of netevent greatly (I use it on embedded).