Skip to main content

pspair

A command-line reimplementation of SixaxisPairTool.exe's core function: pair a PlayStation controller with a Bluetooth host by writing the host's Bluetooth address into the controller over USB.

No GUI, no driver installer, no third-party Python packages.

Install

pip install pspair

On Windows, pip install "pspair[libusb]" also installs a libusb-1.0 DLL, so you do not have to supply one yourself. If the original tool already placed libusb0.dll in System32, the plain install is enough.

Usage

pspair list
pspair get
pspair set 00:1A:7D:DA:71:13

From a source checkout the same commands work as python pspair.py ....

Protocol

Recovered from the shipped binary (PE32, x86, 612 864 bytes, sha256 97b89949f8c92d698b34e55235f0cd0c7c2075e66f37c3fd38d3912f2f877a35) by PE import/resource inspection and a Capstone linear sweep of .text; the only two usb_control_msg call sites in the image were decoded instruction by instruction. Both are USB class requests to interface 0 with a 5000 ms timeout.

Model PID read write
DualShock 3 / Sixaxis 0x0268 0xA1 0x01 0x03F5, len 50 → reply[2:8] 0x21 0x09 0x03F5, len 8 → 01 00 <addr>
DualShock 4 / v2 0x05C4, 0x09CC 0xA1 0x01 0x0312, len 50 → reply[10:16], byte-reversed 0x21 0x09 0x0313, len 23 → 13 <addr reversed> <16 bytes>

0xA1 = IN | class | interface, 0x01 = GET_REPORT; 0x21 = OUT | class | interface, 0x09 = SET_REPORT.

How the DualShock 4 read layout was established

Report 0x12 answers with 16 bytes:

idx   0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15
val  12   68   37   5c   88   27   d0   08   25   00   01   01   01   3c   2b   1a
                                                  +------- master, reversed -------+

The master address is the tail six bytes, byte-reversed: with the host set to 1A:2B:3C:01:01:01, the reply ends 01 01 01 3c 2b 1a. This was confirmed by reading the controller with both this tool and the original EXE: both report 1A:2B:3C:01:01:01.

Bytes reply[1:7] (68 37 5c 88 27 d0) are a different field - almost certainly the controller's own BD address, though that is not confirmed.

The disassembly was misleading here. The DS4 branch appears to extract reply[15:21], which cannot exist in a 16-byte reply, and an earlier version of this tool therefore read the wrong field. Offsets for this controller had to be settled with a known ground-truth value, not by reading the decompiled code.

DualShock 4 write payload

The last 16 bytes (56 e8 81 38 08 06 51 41 c0 7f 12 aa d9 66 3c ce) are copied verbatim from the binary (built at 0x24f4). Their meaning was not resolved; they are almost certainly the link key. The address is written in reverse byte order, as the original does ([esi+0x14] down to [esi] into reply[1:6]).

Not implemented: PlayStation Move (0x03D5). It is recognised and then refused before any transfer, because its write payload was only partially recovered.

Backends

Backend Platforms Library Driver required
libusb1 Windows, Linux, macOS libusb-1.0 (.dll/.so/.dylib) WinUSB or libusbK
libusb0 Windows only libusb0.dll (libusb-win32) libusb0.sys

libusb0 exists only on Windows; it is offered because the original tool installs exactly that driver, so on a machine that has run the original the pairing path already works with no extra install.

--backend auto (default) picks a backend by openability, not enumeration: libusb-1.0 lists every USB device including ones bound to a driver it cannot claim, so a backend that can merely see the controller is useless. auto opens and closes each candidate and keeps the first that succeeds; if none can open it, the first that saw a controller is used so the real error surfaces.

Library lookup: --dll PATH, then the standard names, then ctypes.util.find_library, then the DLLs shipped by the optional libusb PyPI package.

Driver notes per platform

  • Windows - libusb0 needs libusb-win32; libusb1 needs WinUSB or libusbK (Zadig). A controller can be visible to both backends and openable by only one.
  • Linux - needs access (sudo, or a udev rule such as SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666"). The kernel HID driver normally owns the interface, so the tool detaches it before claiming and re-attaches on close.
  • macOS - no driver install; IOKit may hold the interface, covered by the same detach logic.

Commands

list [--all]          enumerate controllers; --all shows every USB device
get [--index N]       read the paired host address
set ADDR [--index N]  write a new host address
self-test             framing/parsing/struct-layout checks, no hardware
--backend auto|libusb1|libusb0
--dll PATH            explicit library path
--interface N         USB interface to claim (default 0)
--dry-run             print the exact transfers without touching hardware

--dry-run needs no driver or device; it uses the connected model when one is present and otherwise labels the output as the DualShock 3 default.

set reads the address back after writing and fails if the controller does not report the requested value, for both models.

Verification performed

Against real hardware - a DualShock 4 (054C:05C4) attached to this host:

  • get -> 1A:2B:3C:01:01:01, matching the original EXE reading the same controller (the value was previously written by the original tool).
  • A report probe confirmed this device answers 0x0312 with 16 bytes, 0x0302 with 37 bytes and 0x0311 with 3 bytes, and rejects 0x0313, 0x0304, 0x0305, 0x0314, 0x03F5 with a Win32 error.
  • auto selects libusb0 (the driver the device is bound to) rather than libusb1, which enumerates it but reports access denied on open.
  • self-test covers both payloads, the observed DS4 reply against the known host address, model gating for the unsupported PID, and the ctypes struct offsets the libusb0 walk depends on (descriptor@536, devnum@576, devices@528).

Not verified:

  • set has never been run against hardware. No write has been sent to a controller, so whether the DualShock 4 report 0x13 payload actually pairs it is untested. Pairing changes controller state that this tool cannot undo.
  • DualShock 3 has not been tested on hardware; its protocol comes from the binary only.
  • Linux and macOS paths are written to the documented libusb-1.0 API but have not been executed on those platforms.
  • What reply[1:7] names.

Known failure modes seen during development

  • Sending the DS3 report 0x03F5 to a DS4 makes the transfer fail with a Win32 "device not functioning" error - the model must select the report.
  • A rejected transfer can leave the device needing a retry; read_master retries once on an empty reply, then fails with a message naming the report.
  • libusb0's error text is ANSI in the local code page (e.g. GBK), not UTF-8; it is decoded with the active code page or it appears as mojibake.
  • A partial disassembly is not enough to place a reply field. Two guesses (reply[15:21], then reply[1:7]) were both wrong before a known ground-truth address pinned it to reply[10:16].

Publishing a release

The package is one module plus pyproject.toml; there is no compiled code and no runtime dependency. The version lives only in pspair.__version__, which pyproject.toml reads, so there is nothing else to keep in sync.

python -m build                  # dist/pspair-<version>-py3-none-any.whl + .tar.gz
python -m twine check dist/*     # validates metadata and the README rendering
python -m twine upload dist/*    # TWINE_USERNAME=__token__, TWINE_PASSWORD=pypi-...

PyPI rejects a version that already exists, so bump __version__ before every upload. To rehearse, use python -m twine upload --repository testpypi dist/* and install with pip install -i https://test.pypi.org/simple/ pspair.

Metadata

Release files for pspair 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pspair 0.1.0
File Size Uploaded Provenance Actions
pspair-0.1.0.tar.gz 19.7 kB Without provenance Details for pspair-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pspair 0.1.0
File Interpreter ABI Platform Actions
pspair-0.1.0-py3-none-any.whl Python 3 none any Details for pspair-0.1.0-py3-none-any.whl

Total release size: 35.3 kB

Release files / pspair-0.1.0.tar.gz

Download URL pspair-0.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f2710655fea18029a91ccc85f1c90a89965326d94e281d48f1046e796f514944
BLAKE2b-256 checksum
How to use checksums
6b26a073b85f788908d0b2f2f9aeef4befb40ed46593d8c83b9cd932dc7ed3c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pspair-0.1.0-py3-none-any.whl

Download URL pspair-0.1.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b15ec6618c2ef1b3ccc734e9d4f20e6b104912a428d5858dab5d441457c53b57
BLAKE2b-256 checksum
How to use checksums
46365e2def81b827ee223e766bb0537e8f2422bc217828e88a30332da2900a3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for pspair 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page