diff options
author | Devaev Maxim <[email protected]> | 2020-10-08 12:18:38 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-10-08 12:18:38 +0300 |
commit | f1910f7c8ec085eece1adc56ff999527881e71d9 (patch) | |
tree | 4f3cb6c481a7d0f29b91fa8ccc9e320f3a29b73b /kvmd/apps/vnc/server.py | |
parent | 920f648d6526217009f8ee4dc6e943a28a4886db (diff) |
more correct keymap handling
Diffstat (limited to 'kvmd/apps/vnc/server.py')
-rw-r--r-- | kvmd/apps/vnc/server.py | 20 |
1 files changed, 15 insertions, 5 deletions
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: |