mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-04 12:00:16 +00:00
optimized get_keycode
This commit is contained in:
parent
f5e734316d
commit
7b89e8a46f
@ -31,13 +31,18 @@ from keymapper.paths import get_config_path
|
||||
|
||||
|
||||
def update_reverse_mapping(func):
|
||||
"""Generate a reverse mapping to optimize reverse lookups."""
|
||||
"""Generate a reverse mapping to optimize reverse lookups.
|
||||
|
||||
If _mapping contains `20: "a, A"`,
|
||||
reverse mapping will contain `"a": 20, "A": 20`
|
||||
"""
|
||||
def wrapper(self, *args, **kwargs):
|
||||
func(self, *args, **kwargs)
|
||||
self._reverse_mapping = {
|
||||
value: key for key, value
|
||||
in self._mapping.items()
|
||||
}
|
||||
|
||||
self._reverse_mapping = {}
|
||||
for key, value in self._mapping.items():
|
||||
for character in value.split(','):
|
||||
self._reverse_mapping[character.strip()] = key
|
||||
return wrapper
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user