summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-10-26 19:48:43 +0300
committerDevaev Maxim <[email protected]>2020-10-26 19:48:43 +0300
commit3c690816e1e00198e3693fcfa883424cde6daa54 (patch)
treed735c81bfeb7e8a08ca38a78db00cd0c8e979639 /kvmd
parentad943811f9b0fb89c08196c08f307f7a5a374feb (diff)
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/plugins/hid/otg/keyboard.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/kvmd/plugins/hid/otg/keyboard.py b/kvmd/plugins/hid/otg/keyboard.py
index c497f7c8..21b950f9 100644
--- a/kvmd/plugins/hid/otg/keyboard.py
+++ b/kvmd/plugins/hid/otg/keyboard.py
@@ -52,18 +52,12 @@ class _ModifierEvent(BaseEvent):
modifier: OtgKey
state: bool
- def __post_init__(self) -> None:
- assert self.modifier.is_modifier
-
@dataclasses.dataclass(frozen=True)
class _KeyEvent(BaseEvent):
key: OtgKey
state: bool
- def __post_init__(self) -> None:
- assert not self.key.is_modifier
-
# =====
class KeyboardProcess(BaseDeviceProcess):
@@ -94,10 +88,8 @@ class KeyboardProcess(BaseDeviceProcess):
def send_key_events(self, keys: Iterable[Tuple[str, bool]]) -> None:
for (key, state) in keys:
otg_key = KEYMAP[key].otg
- if otg_key.is_modifier:
- self._queue_event(_ModifierEvent(otg_key, state))
- else:
- self._queue_event(_KeyEvent(otg_key, state))
+ cls = (_ModifierEvent if otg_key.is_modifier else _KeyEvent)
+ self._queue_event(cls(otg_key, state))
# =====