Python library for presenting an NX-compatible virtual Bluetooth HID input device.
Project description
swbt-python
NX 向けの仮想 Bluetooth HID 入力デバイスを Python から扱うためのライブラリです。
本ライブラリは pre-alpha 版です。実機での動作は Bluetooth adapter、driver、対象機器の firmware に依存します。
必要なもの
- Python 3.12 以降
- uv
- Bumble が利用可能な専用 USB Bluetooth dongle
インストール
pip install swbt-python
ソースから動かす場合は次を使います。
uv sync --dev
ドキュメント
公開ドキュメント には API、利用例、実機準備、AI エージェント向け要約があります。
- API 仕様: API Reference
- 利用例: Usage Guide
- 実機構成と troubleshooting: Hardware Guide
- AI エージェント向け要約: Agent Brief
リポジトリを checkout している場合、同じ内容は docs/ 配下でも確認できます。
利用例
import asyncio
from swbt import Button, SwitchGamepad
async def main() -> None:
async with SwitchGamepad(
adapter="usb:0",
key_store_path="switch-bond.json",
) as pad:
await pad.connect(
timeout=30.0,
allow_pairing=True,
)
await pad.tap(Button.A)
await pad.neutral()
asyncio.run(main())
この例は専用 Bluetooth adapter を使い、HID advertising、pairing または reconnect、periodic report loop、入力送信を行います。専用 USB Bluetooth dongle と接続情報のファイルパスを指定し、終了時は neutral を送ってから接続を閉じます。
接続方法、key_store_path、入力 API の使い分けは Usage Guide にあります。
実機検証
実機接続には、PC の通常 Bluetooth 機能と共有しない専用 USB Bluetooth dongle と、OS ごとの driver 準備が必要です。Windows では、Zadig などで専用 dongle に WinUSB / libwdi driver を入れてから adapter 名を確認します。
driver 準備、adapter 名の確認、troubleshooting は Hardware Guide にあります。実機ログの正本は hardware-test-log です。
確認済み構成
2026-07-04 時点では、Windows 11 / CSR8510 A10 / WinUSB / Switch 2 firmware 22.1.0 で、pairing、reconnect、Button A、D-pad、left / right stick、neutral 後の入力残りなしを確認済みです。adapter 名の例は usb:0 です。
試験的構成
Linux / macOS は experimental です。手順は Hardware Guide に整備されていますが、動作検証されていないことに留意してください。adapter が開けるか、pairing できるか、入力が反映されるかは未確認です。
CSR8510 A10 以外の Bluetooth dongle、Switch 2 firmware 22.1.0 以外の対象機器は確認済み構成に含めていません。
開発
uv sync --dev
uv run ruff format --check .
uv run ruff check .
uv run ty check --no-progress
uv run pytest tests/unit
uv run pytest tests/integration
ライセンス
MIT ライセンスです。全文は LICENSE にあります。
注記
このプロジェクトは、対象機器や関連商標の権利者から承認、後援、提携を受けたものではありません。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swbt_python-0.1.0.tar.gz.
File metadata
- Download URL: swbt_python-0.1.0.tar.gz
- Upload date:
- Size: 219.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c08646e5146cd8b50989a6a2255937ea7e457dec937a3eb1dffd266dcd410f1
|
|
| MD5 |
9b2620e877e486161f6f1715fba35180
|
|
| BLAKE2b-256 |
3eb3418283612ad7cec8d8e18f2bf31f9d1295f037069769f8a9861a5f8a034a
|
Provenance
The following attestation bundles were made for swbt_python-0.1.0.tar.gz:
Publisher:
publish.yml on niart120/swbt-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swbt_python-0.1.0.tar.gz -
Subject digest:
3c08646e5146cd8b50989a6a2255937ea7e457dec937a3eb1dffd266dcd410f1 - Sigstore transparency entry: 2071703734
- Sigstore integration time:
-
Permalink:
niart120/swbt-python@406d2e6454f4f8f456fdb06b1629e393c1939428 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/niart120
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@406d2e6454f4f8f456fdb06b1629e393c1939428 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file swbt_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swbt_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75e8f2048d386c7b68c33e1298e0d2ef7d11780aa7b95ed7d42b3d7ceb9e0d2e
|
|
| MD5 |
b27680e14a6cdfb3e30f3be0ce169f9b
|
|
| BLAKE2b-256 |
92ceab35875aabb3f108b2a17f6b3f59e0dbaa06f10a207afd80d814511ca2be
|
Provenance
The following attestation bundles were made for swbt_python-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on niart120/swbt-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swbt_python-0.1.0-py3-none-any.whl -
Subject digest:
75e8f2048d386c7b68c33e1298e0d2ef7d11780aa7b95ed7d42b3d7ceb9e0d2e - Sigstore transparency entry: 2071703743
- Sigstore integration time:
-
Permalink:
niart120/swbt-python@406d2e6454f4f8f456fdb06b1629e393c1939428 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/niart120
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@406d2e6454f4f8f456fdb06b1629e393c1939428 -
Trigger Event:
workflow_dispatch
-
Statement type: