diff options
author | Devaev Maxim <[email protected]> | 2020-11-22 05:48:55 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-11-22 05:48:55 +0300 |
commit | 48550d2e78acb7e2669f8bd9595330c4001302f1 (patch) | |
tree | 4071e2d94488af9d6042ef0d5f231423e359f8eb /kvmd/plugins/hid/_mcu/__init__.py | |
parent | 6a8ee1a11470fe6572c0ca224ec370f2b4752be0 (diff) |
refactoring
Diffstat (limited to 'kvmd/plugins/hid/_mcu/__init__.py')
-rw-r--r-- | kvmd/plugins/hid/_mcu/__init__.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py index cbecd286..6e0f902e 100644 --- a/kvmd/plugins/hid/_mcu/__init__.py +++ b/kvmd/plugins/hid/_mcu/__init__.py @@ -55,8 +55,6 @@ from .gpio import Gpio from .proto import REQUEST_PING from .proto import REQUEST_REPEAT from .proto import RESPONSE_LEGACY_OK -from .proto import KEYBOARD_CODES_TO_NAMES -from .proto import MOUSE_CODES_TO_NAMES from .proto import BaseEvent from .proto import SetKeyboardOutputEvent from .proto import SetMouseOutputEvent @@ -66,6 +64,8 @@ from .proto import MouseButtonEvent from .proto import MouseMoveEvent from .proto import MouseRelativeEvent from .proto import MouseWheelEvent +from .proto import get_active_keyboard +from .proto import get_active_mouse from .proto import check_response @@ -163,7 +163,8 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many- features = state["status"] & 0xFF absolute = True - if online and (outputs & 0b00111000) in [0b00010000, 0b00011000]: + active_mouse = get_active_mouse(outputs) + if online and active_mouse in ["usb_rel", "ps2"]: absolute = False keyboard_outputs: Dict = {"available": {}, "active": ""} @@ -179,13 +180,12 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many- keyboard_outputs["available"]["ps2"] = {"name": "PS/2"} mouse_outputs["available"]["ps2"] = {"name": "PS/2"} - active = KEYBOARD_CODES_TO_NAMES.get(outputs & 0b00000111, "") - if active in keyboard_outputs["available"]: - keyboard_outputs["active"] = active + active_keyboard = get_active_keyboard(outputs) + if active_keyboard in keyboard_outputs["available"]: + keyboard_outputs["active"] = active_keyboard - active = MOUSE_CODES_TO_NAMES.get(outputs & 0b00111000, "") - if active in mouse_outputs["available"]: - mouse_outputs["active"] = active + if active_mouse in mouse_outputs["available"]: + mouse_outputs["active"] = active_mouse return { "online": online, |