From a33efcaef3e69fb097a71198d6b8cecb02491800 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Sat, 24 Jul 2021 02:09:18 +0300 Subject: disabled instead of empty string --- kvmd/plugins/hid/_mcu/__init__.py | 8 ++++---- kvmd/plugins/hid/_mcu/proto.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'kvmd/plugins/hid/_mcu') diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py index bcca89b9..07aeface 100644 --- a/kvmd/plugins/hid/_mcu/__init__.py +++ b/kvmd/plugins/hid/_mcu/__init__.py @@ -179,12 +179,12 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many- if outputs1 & 0b10000000: # Dynamic if outputs2 & 0b00000001: # USB - keyboard_outputs["available"].extend(["usb"]) - mouse_outputs["available"].extend(["usb", "usb_rel"]) + keyboard_outputs["available"].extend(["usb", "disabled"]) + mouse_outputs["available"].extend(["usb", "usb_rel", "disabled"]) if outputs2 & 0b00000010: # PS/2 - keyboard_outputs["available"].extend(["ps2"]) - mouse_outputs["available"].extend(["ps2"]) + keyboard_outputs["available"].extend(["ps2", "disabled"]) + mouse_outputs["available"].extend(["ps2", "disabled"]) active_keyboard = get_active_keyboard(outputs1) if active_keyboard in keyboard_outputs["available"]: diff --git a/kvmd/plugins/hid/_mcu/proto.py b/kvmd/plugins/hid/_mcu/proto.py index bc3feafa..16757d7d 100644 --- a/kvmd/plugins/hid/_mcu/proto.py +++ b/kvmd/plugins/hid/_mcu/proto.py @@ -38,14 +38,15 @@ class BaseEvent: # ===== _KEYBOARD_NAMES_TO_CODES = { - "usb": 0b00000001, - "ps2": 0b00000011, + "disabled": 0b00000000, + "usb": 0b00000001, + "ps2": 0b00000011, } _KEYBOARD_CODES_TO_NAMES = tools.swapped_kvs(_KEYBOARD_NAMES_TO_CODES) def get_active_keyboard(outputs: int) -> str: - return _KEYBOARD_CODES_TO_NAMES.get(outputs & 0b00000111, "") + return _KEYBOARD_CODES_TO_NAMES.get(outputs & 0b00000111, "disabled") @dataclasses.dataclass(frozen=True) @@ -62,15 +63,16 @@ class SetKeyboardOutputEvent(BaseEvent): # ===== _MOUSE_NAMES_TO_CODES = { - "usb": 0b00001000, - "usb_rel": 0b00010000, - "ps2": 0b00011000, + "disabled": 0b00000000, + "usb": 0b00001000, + "usb_rel": 0b00010000, + "ps2": 0b00011000, } _MOUSE_CODES_TO_NAMES = tools.swapped_kvs(_MOUSE_NAMES_TO_CODES) def get_active_mouse(outputs: int) -> str: - return _MOUSE_CODES_TO_NAMES.get(outputs & 0b00111000, "") + return _MOUSE_CODES_TO_NAMES.get(outputs & 0b00111000, "disabled") @dataclasses.dataclass(frozen=True) -- cgit v1.2.3