Skip to content

Fix C/Capture swap, read factory stick calibration, hardening (v1.3.0) - #18

Merged
mlstr0m merged 1 commit into
mainfrom
agent/funny-dirac-vjofbi
Sep 27, 2026
Merged

mlstr0m merged 1 commit into
mainfrom
agent/funny-dirac-vjofbi

Conversation

@mlstr0m

@mlstr0m mlstr0m commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Protocol

Hardening

  • mappings.json is written atomically (temp file + os.replace).
  • "dsu.enabled" must be a boolean; bool("false") used to evaluate to True.
  • A warning is shown when the DSU server binds a non-loopback address.
  • DSU socket: dropped SO_REUSEADDR. It is useless for UDP, and on Linux it let a second server silently share the port.
  • Worker → UI messages are now taken atomically, and the stick hysteresis read happens under the lock.
  • Uses get_running_loop(); logging is set up at startup instead of at import.

Build

  • Python 3.10+ (bleak 3 requires it), with upper bounds on major versions.
  • py2app moved to requirements-build.txt.
  • CI matrix: 3.10, 3.12, 3.13.
  • The DMG README explains the macOS 15+ Gatekeeper "Open Anyway" flow.

Tests

  • New tests cover the byte-4 bits, calibration decoding (using the real blocks published in the fork's PROTOCOL.md), command frames, an end-to-end session with and without a responding controller, and the config hardening.
  • Reverting the C/Capture fix makes 3 tests fail.
  • The tests were run on Linux with stubbed rumps/pynput. Not yet verified on real hardware: C/Capture, the "sticks calibrated" status and the player LED.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SGsFjHBorX2mfsanZhFyzs


Generated by Claude Code

Protocol (sources cited in code and README):
- Byte 4 of the input report: Capture is 0x02 and C is 0x10, not the
  reverse. Agreed by ndeadly/switch2_controller_research (hid_reports.md),
  esp-cpp/espp PR #765 (switch2_pro_report.hpp) and the hardware capture
  in issue #14. Also fixes Capture -> DSU Touch.
- Read the factory stick calibration over the command channel
  (649d4ac9-...f005 / replies c765a961-...) and light player LED 1.
  Frame format, SPI addresses 0x130A8/0x130E8 and block layout adapted
  from kennethreitz/switch2bridge-macos@975f329 (issue #14, MIT), based on
  darthcloud/BlueRetro#1249; addresses match SDL's Switch 2 driver.
  Best effort: a silent controller keeps the nominal 2048 range.
- README: 7492866c-...c0f8 is notify-only, document the command channel.

Hardening:
- mappings.json written atomically (temp file + os.replace)
- "dsu.enabled" must be a boolean (bool("false") was True)
- warn when the DSU server is bound to a non-loopback address
- DSU socket: drop SO_REUSEADDR (useless for UDP; on Linux it let a
  second server silently share the port)
- worker -> UI messages taken atomically; stick hysteresis read under lock
- asyncio.get_running_loop(); logging set up at startup, not import

Build: Python 3.10+ (bleak 3 requires it), major-version upper bounds,
py2app moved to requirements-build.txt, CI matrix 3.10/3.12/3.13,
DMG README explains the macOS 15+ Gatekeeper "Open Anyway" flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SGsFjHBorX2mfsanZhFyzs
@mlstr0m
mlstr0m merged commit bce6fed into main Sep 27, 2026
4 checks passed
mlstr0m pushed a commit that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants