diff options
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/api/hid.py | 5 | ||||
-rw-r--r-- | kvmd/apps/vnc/server.py | 20 |
2 files changed, 17 insertions, 8 deletions
diff --git a/kvmd/apps/kvmd/api/hid.py b/kvmd/apps/kvmd/api/hid.py index 90bf53ff..573ed48c 100644 --- a/kvmd/apps/kvmd/api/hid.py +++ b/kvmd/apps/kvmd/api/hid.py @@ -42,7 +42,6 @@ from ....validators.kvm import valid_hid_mouse_move from ....validators.kvm import valid_hid_mouse_button from ....validators.kvm import valid_hid_mouse_wheel -from ....keyboard.keysym import SymmapWebKey from ....keyboard.keysym import build_symmap from ....keyboard.printer import text_to_web_keys @@ -98,7 +97,7 @@ class HidApi: self.__hid.send_key_events(text_to_web_keys(text, symmap)) return make_json_response() - def __ensure_symmap(self, keymap_name: str) -> Dict[int, SymmapWebKey]: + def __ensure_symmap(self, keymap_name: str) -> Dict[int, Dict[int, str]]: keymap_name = valid_printable_filename(keymap_name, "keymap") path = os.path.join(self.__keymaps_dir_path, keymap_name) try: @@ -110,7 +109,7 @@ class HidApi: return self.__inner_ensure_symmap(path, st.st_mtime) @functools.lru_cache(maxsize=10) - def __inner_ensure_symmap(self, path: str, mtime: int) -> Dict[int, SymmapWebKey]: + def __inner_ensure_symmap(self, path: str, mtime: int) -> Dict[int, Dict[int, str]]: _ = mtime # For LRU return build_symmap(path) diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index f552e026..41fd0487 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -33,7 +33,7 @@ import aiohttp from ...logging import get_logger -from ...keyboard.keysym import SymmapWebKey +from ...keyboard.keysym import switch_symmap_modifiers from ...keyboard.keysym import build_symmap from ...clients.kvmd import KvmdClientWs @@ -72,7 +72,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes desired_fps: int, keymap_name: str, - symmap: Dict[int, SymmapWebKey], + symmap: Dict[int, Dict[int, str]], kvmd: KvmdClient, streamer: StreamerClient, @@ -119,6 +119,8 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes self.__lock = asyncio.Lock() + self.__modifiers = 0 + # ===== async def run(self) -> None: @@ -238,10 +240,18 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes # ===== async def _on_key_event(self, code: int, state: bool) -> None: + (is_modifier, self.__modifiers) = switch_symmap_modifiers(self.__modifiers, code, state) if self.__kvmd_ws: - web_key = self.__symmap.get(code) - if web_key is not None: - await self.__kvmd_ws.send_key_event(web_key.name, state) + web_keys = self.__symmap.get(code) + if web_keys: + if is_modifier: + web_key = web_keys.get(0) + else: + web_key = web_keys.get(self.__modifiers) + if web_key is None: + web_key = web_keys.get(0) + if web_key is not None: + await self.__kvmd_ws.send_key_event(web_key, state) async def _on_pointer_event(self, buttons: Dict[str, bool], wheel: Dict[str, int], move: Dict[str, int]) -> None: if self.__kvmd_ws: |