Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create pyproject.toml (#15) #63

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ Here's a few things you could try:
```

- When you interact with your Bluetooth devices with `-d` set, you should see debug output in the logs such as:
-

```console
user@pi0w:~ $ sudo service bluetooth_2_usb stop && sudo bluetooth_2_usb -i /dev/input/event3,a1:b2:c3:d4:e5:f6,Logi -d ; sudo service bluetooth_2_usb start
# Click [show debug output] for more
>>> Click [show debug output] for more <<<
```

<details><summary>[show debug output]</summary>
Expand Down
2 changes: 1 addition & 1 deletion bluetooth_2_usb/evdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# Copyright (c) 1999-2002 Vojtech Pavlik
# Copyright (c) 2015 Hans de Goede <[email protected]>
# Copyright (c) 2023 Benjamin T. <github.com/quaxalber>
# Copyright (c) 2023 Benjamin T. <evdev@quaxalber.de>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
Expand Down
28 changes: 14 additions & 14 deletions bluetooth_2_usb/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def matches(self, device: InputDevice) -> bool:
if self.type == IdentifierType.PATH:
return self.value == device.path
if self.type == IdentifierType.NAME:
return self.normalized_value in f"{device.name}".lower()
return self.normalized_value in str(device.name).lower()
if self.type == IdentifierType.MAC:
return self.normalized_value == device.uniq

Expand All @@ -97,26 +97,26 @@ def input_device(self) -> InputDevice:
return self._input_device

def __str__(self):
return f"Relay for {self.input_device.name}"
return f"relay for {self.input_device.name}"

def __repr__(self):
return f"Relay for {str(self.input_device)}"
return f"relay for {self.input_device}"

async def async_relay_events_loop(self) -> NoReturn:
async for event in self.input_device.async_read_loop():
await self._async_relay_event(event)

async def _async_relay_event(self, input_event: InputEvent) -> None:
event = categorize(input_event)
_logger.debug(f"{self.input_device.name} sent {event}")
function = None
if isinstance(event, KeyEvent):
function = self._send_key
elif isinstance(event, RelEvent):
function = self._move_mouse
if function:
_logger.debug(f"Received {event} from {self.input_device.name}")
method = None
if isinstance(event, RelEvent):
method = self._move_mouse
elif isinstance(event, KeyEvent):
method = self._send_key
if method:
loop = asyncio.get_running_loop()
await loop.run_in_executor(None, function, event)
await loop.run_in_executor(None, method, event)

def _send_key(self, event: KeyEvent) -> None:
key_id, key_name = evdev_to_usb_hid(event)
Expand Down Expand Up @@ -209,13 +209,13 @@ def _create_task(self, device: InputDevice, task_group: TaskGroup) -> None:
async def _async_relay_events(self, device: InputDevice) -> NoReturn:
try:
relay = DeviceRelay(device)
_logger.info(f"{repr(relay)} is active")
_logger.info(f"Activated {repr(relay)}")
await relay.async_relay_events_loop()
except CancelledError:
self._cancelled = True
_logger.critical(f"{device.name} cancelled")
_logger.critical(f"{device.name} was cancelled")
except (OSError, FileNotFoundError) as ex:
_logger.critical(f"Connection lost to {device.name} [{repr(ex)}]")
_logger.critical(f"Connection to {device.name} lost [{repr(ex)}]")
except Exception:
_logger.exception(f"{device.name} failed!")
await asyncio.sleep(2)
Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "bluetooth_2_usb"
dynamic = ["version"]
description = "Convert a Raspberry Pi into a HID relay translating Bluetooth keyboard and mouse input to USB."
authors = [
{ name = "quaxalber", email = "[email protected]" },
]
license = {file = "LICENSE.md"}
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Topic :: System :: Hardware :: Universal Serial Bus (USB) :: Human Interface Device (HID)",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Development Status :: 3 - Alpha",
]

[project.urls]
Homepage = "https://github.com/quaxalber/bluetooth_2_usb"
Issues = "https://github.com/quaxalber/bluetooth_2_usb/issues"