Skip to main content

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 エージェント向け要約があります。

リポジトリを 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 にあります。実機ログの正本は repository 内の spec/hardware-test-log.md です。

確認済み構成

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swbt_python-0.1.1.tar.gz (246.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swbt_python-0.1.1-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file swbt_python-0.1.1.tar.gz.

File metadata

  • Download URL: swbt_python-0.1.1.tar.gz
  • Upload date:
  • Size: 246.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swbt_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b11edef7a51c9c5b928b3bbcd79c20420273618c2ca35aebe344f0ea85f6a209
MD5 d8b1c6914e741089e5ce187301398afd
BLAKE2b-256 87330d9d766bbd0c846925aba9d0adb615d49fab8cc7abcdd2ec0cadf518c793

See more details on using hashes here.

Provenance

The following attestation bundles were made for swbt_python-0.1.1.tar.gz:

Publisher: publish.yml on niart120/swbt-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swbt_python-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: swbt_python-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swbt_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7474a0fa1a42ab05b3eb120e51bbb034bd62162c5b919946af237a49e00e6aa9
MD5 9ffbc6f08e26a67e2af31a373a874b96
BLAKE2b-256 8846d4b313e3f7132f866a33a03d24e8f1af05a4007d0517d448010b5849d83b

See more details on using hashes here.

Provenance

The following attestation bundles were made for swbt_python-0.1.1-py3-none-any.whl:

Publisher: publish.yml on niart120/swbt-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page