Metadata-Version: 2.4
Name: pyusbdisplay
Version: 0.1.0
Summary: Python bindings for MSDisplaySDK USB secondary display
Author: pyusbdisplay contributors
License: MIT AND LicenseRef-MSDisplaySDK-Redistributable
Project-URL: Homepage, https://github.com/example/pyusbdisplay
Keywords: usb,display,msdisplay,ctypes
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: System :: Hardware
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: image
Requires-Dist: Pillow>=10.0.0; extra == "image"
Provides-Extra: monitor
Requires-Dist: Pillow>=10.0.0; extra == "monitor"
Requires-Dist: psutil>=5.9.0; extra == "monitor"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Dynamic: license-file

# pyusbdisplay

Python bindings for **MSDisplaySDK** (via `MSDISPLAYSDKWRRAPER.dll`).

This project wraps the official Windows SDK; it does not reimplement the USB protocol.

## Requirements

- Windows x64
- Python 3.12+ (64-bit)
- Official `MSDISPLAYSDKWRRAPER.dll` (shipped under `refdoc/.../sdk_lib64/Release/`)
- USB display driver installed when using secondary-screen devices (`refdoc/.../lib/libusb`)

## Setup

```powershell
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
# or from a built wheel:
pip install dist\pyusbdisplay-*-py3-none-win_amd64.whl
```

Native libraries ship under `msdisplay/_vendor/{win32,win_amd64,linux_*}/`.
Override with:

```powershell
$env:MSDISPLAY_SDK_DLL = "C:\path\to\MSDISPLAYSDKWRRAPER.dll"
```

Search order: `MSDISPLAY_SDK_DLL` → package `_vendor/<platform>/` → `refdoc/.../Release/` (dev) → cwd.

## Build wheels (one-click)

```powershell
.\pack.bat
# or
.\pack.ps1
# or
python scripts/build_package.py --clean
```

Options:

```powershell
.\pack.bat --platforms win_amd64,win32
.\pack.bat --clean
python scripts/build_package.py --platforms linux_x86_64
```

Artifacts land in `dist/`. Linux wheels are built only when `.so` files exist under `msdisplay/_vendor/linux_*`.

Upload:

```powershell
python -m twine upload --repository testpypi dist/*
python -m twine upload dist/*
```

## Quick demo

```powershell
python examples/demo_console.py
python examples/demo_adia64.py
python examples/demo_console.py --image test.bmp --jpeg
python examples/demo_console.py --once
python examples/demo_console.py --interval 0.03
```

- `demo_console.py`: solid color cycle / custom image, continuous until **Ctrl+C**
- `demo_adia64.py`: AIDA64 布局 + 赛博二次元 HUD（霓虹、扫描线、日文徽章、小角色）

Flow matches the official C++ example:

1. Register attach/detach callbacks
2. `start` → `enable_sdk_screen_processor(True)`
3. Query device info / secondary-screen capability
4. Set resolution only when the device does **not** support secondary screen
5. `send_picture` (BGRA pixels)

If app stops sending for more than ~3 seconds on secondary-screen devices, the panel falls back to the system secondary display.

## Library usage

```python
import msdisplay as msd

msd.load_sdk()  # optional
msd.register_callbacks(
    lambda handle, resos: print("attach", hex(handle), resos),
    lambda handle: print("detach", hex(handle)),
)
msd.start()
msd.enable_sdk_screen_processor(True)
print(msd.get_sdk_version())

# ... wait for attach, then:
info = msd.get_device_info(handle)
if not msd.check_device_screen_capability(handle):
    msd.set_video_param(handle, info.resolutions[0])

frame = msd.load_bgra("photo.bmp")
msd.send_picture(handle, frame.width, frame.height, frame.data, encode_jpeg=False)
msd.stop()
```

## Package layout

- `msdisplay/` — ctypes bindings and helpers
- `examples/demo_console.py` — console demo
- `refdoc/` — vendor SDK package (reference only)
