rules: only one warning per inaccessible key for KeyPress action

This commit is contained in:
Peter F. Patel-Schneider 2022-05-11 11:28:42 -04:00
parent b717872557
commit 1c596a8124
2 changed files with 5 additions and 3 deletions

View File

@ -162,6 +162,8 @@ i.e., don't use a single `KeyPress` like 'a+b'.
If a key symbol can only be produced by a shfited or level 3 keypress, e.g., "A", If a key symbol can only be produced by a shfited or level 3 keypress, e.g., "A",
then Solaar will add keypresses to produce that keysymbol, then Solaar will add keypresses to produce that keysymbol,
e.g., simulating a left shift keypress to get "A" instead of "a". e.g., simulating a left shift keypress to get "A" instead of "a".
If a key symbol is not available in the current keymap or needs other shift-like keys,
then Solaar cannot simulate it.
If Solaar can determine the current key modifiers (shift, control, etc.) If Solaar can determine the current key modifiers (shift, control, etc.)
any key symbols that correspond to these modifier keys are not pressed, any key symbols that correspond to these modifier keys are not pressed,
so if the shift key is currently down on a keyboard Solaar will not bother to simulate a shift key. so if the shift key is currently down on a keyboard Solaar will not bother to simulate a shift key.

View File

@ -841,8 +841,6 @@ class KeyPress(Action):
if (group == k.group or len(keycodes.keys) == 1) and k.keycode < 256 and (level is None or k.level < level): if (group == k.group or len(keycodes.keys) == 1) and k.keycode < 256 and (level is None or k.level < level):
keycode = k.keycode keycode = k.keycode
level = k.level level = k.level
if keycode is None:
_log.warn('rule KeyPress key symbol not currently available %s', self)
return (keycode, level) return (keycode, level)
def __str__(self): def __str__(self):
@ -865,7 +863,9 @@ class KeyPress(Action):
def keyDown(self, keysyms, modifiers): def keyDown(self, keysyms, modifiers):
for k in keysyms: for k in keysyms:
(keycode, level) = self.keysym_to_keycode(k, modifiers) (keycode, level) = self.keysym_to_keycode(k, modifiers)
if keycode and self.needed(keycode, modifiers): if keycode is None:
_log.warn('rule KeyPress key symbol not currently available %s', self)
elif self.needed(keycode, modifiers):
self.mods(level, modifiers, _KEY_PRESS) self.mods(level, modifiers, _KEY_PRESS)
simulate_key(keycode, _KEY_PRESS) simulate_key(keycode, _KEY_PRESS)