mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
send_key_events()
This commit is contained in:
@@ -20,7 +20,9 @@
|
||||
# ========================================================================== #
|
||||
|
||||
|
||||
from typing import Tuple
|
||||
from typing import Dict
|
||||
from typing import Iterable
|
||||
from typing import AsyncGenerator
|
||||
from typing import Type
|
||||
|
||||
@@ -48,7 +50,7 @@ class BaseHid(BasePlugin):
|
||||
|
||||
# =====
|
||||
|
||||
def send_key_event(self, key: str, state: bool) -> None:
|
||||
def send_key_events(self, keys: Iterable[Tuple[str, bool]]) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def send_mouse_button_event(self, button: str, state: bool) -> None:
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
# ========================================================================== #
|
||||
|
||||
|
||||
from typing import Tuple
|
||||
from typing import Dict
|
||||
from typing import Iterable
|
||||
from typing import AsyncGenerator
|
||||
from typing import Any
|
||||
|
||||
@@ -113,8 +115,8 @@ class Plugin(BaseHid):
|
||||
|
||||
# =====
|
||||
|
||||
def send_key_event(self, key: str, state: bool) -> None:
|
||||
self.__keyboard_proc.send_key_event(key, state)
|
||||
def send_key_events(self, keys: Iterable[Tuple[str, bool]]) -> None:
|
||||
self.__keyboard_proc.send_key_events(keys)
|
||||
|
||||
def send_mouse_button_event(self, button: str, state: bool) -> None:
|
||||
self.__mouse_proc.send_button_event(button, state)
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
|
||||
import dataclasses
|
||||
|
||||
from typing import Tuple
|
||||
from typing import List
|
||||
from typing import Set
|
||||
from typing import Iterable
|
||||
from typing import Optional
|
||||
from typing import Any
|
||||
|
||||
@@ -89,12 +91,13 @@ class KeyboardProcess(BaseDeviceProcess):
|
||||
self._clear_queue()
|
||||
self._queue_event(_ResetEvent())
|
||||
|
||||
def send_key_event(self, key: str, state: bool) -> None:
|
||||
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))
|
||||
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))
|
||||
|
||||
# =====
|
||||
|
||||
|
||||
@@ -30,8 +30,10 @@ import struct
|
||||
import errno
|
||||
import time
|
||||
|
||||
from typing import Tuple
|
||||
from typing import List
|
||||
from typing import Dict
|
||||
from typing import Iterable
|
||||
from typing import AsyncGenerator
|
||||
|
||||
import serial
|
||||
@@ -273,8 +275,9 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst
|
||||
|
||||
# =====
|
||||
|
||||
def send_key_event(self, key: str, state: bool) -> None:
|
||||
self.__queue_event(_KeyEvent(key, state))
|
||||
def send_key_events(self, keys: Iterable[Tuple[str, bool]]) -> None:
|
||||
for (key, state) in keys:
|
||||
self.__queue_event(_KeyEvent(key, state))
|
||||
|
||||
def send_mouse_button_event(self, button: str, state: bool) -> None:
|
||||
self.__queue_event(_MouseButtonEvent(button, state))
|
||||
|
||||
Reference in New Issue
Block a user