Coverage for integrations / remote_desktop / peripheral_backends / base.py: 76.2%
21 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-12 04:49 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-12 04:49 +0000
1"""
2Base class for peripheral forwarding backends.
4Each backend handles a specific peripheral type (USB, Bluetooth, Gamepad).
5Backends detect available peripherals, forward them over HARTOS transport,
6and handle cleanup on disconnect.
7"""
9from abc import ABC, abstractmethod
10from typing import List
12from integrations.remote_desktop.peripheral_bridge import PeripheralInfo
15class PeripheralBackend(ABC):
16 """Abstract base for peripheral forwarding backends."""
18 @abstractmethod
19 def discover(self) -> List[PeripheralInfo]:
20 """Discover connected peripherals of this type."""
21 ...
23 @abstractmethod
24 def forward(self, peripheral: PeripheralInfo, transport) -> bool:
25 """Start forwarding a peripheral over the transport.
27 Args:
28 peripheral: The peripheral to forward.
29 transport: TransportChannel to send events on.
31 Returns:
32 True if forwarding started successfully.
33 """
34 ...
36 @abstractmethod
37 def stop(self, peripheral_id: str) -> bool:
38 """Stop forwarding a specific peripheral."""
39 ...
41 @property
42 @abstractmethod
43 def available(self) -> bool:
44 """Whether this backend's system dependencies are available."""
45 ...
47 @property
48 @abstractmethod
49 def peripheral_type_name(self) -> str:
50 """The peripheral type this backend handles (e.g., 'usb', 'bluetooth')."""
51 ...