Agent Guide

For an AI agent helping a user add a controller to padctl. Be exact about what was tested on real hardware.

Goal

Most devices need one file: devices/<vendor>/<model>.toml. No code changes. The test suite auto-discovers every .toml under devices/.

1. Collect

Ask the user to run these with the controller plugged in:

  • lsusb -v -d VID:PID for interfaces and endpoints.
  • The report descriptor: /sys/class/hidraw/hidrawN/device/report_descriptor (find N via the hidraw node of the device).
  • Raw reports while pressing one button or moving one axis at a time, via hidraw or usbmon. See the HID Reverse Engineering Guide.
  • If the vendor tool switches the pad into an enhanced mode, a usbmon capture of that tool's init traffic.

2. Skeleton

sudo ./zig-out/bin/padctl-capture --device /dev/hidraw0 --duration 30 --output devices/<vendor>/<model>.toml

The reverse-engineering guide also shows --vid, --pid and --interface.

3. Write the config

Read the Device Config Guide and the Device Config Reference. Copy the closest existing config in devices/ with the same report layout, then edit it.

Features that exist, all in the reference:

  • [[device.interface]] with hid, vendor and suppress classes.
  • [device.init]: commands, response_prefix, require_response, feature_report, keepalive with keepalive_interval_ms, optional keepalive_counter and keepalive_burst.
  • [device.probe] to tell apart pads behind one receiver, and several configs for one VID/PID.
  • [[report]] with [report.match], [report.fields], bit fields, the transform DSL and [report.button_group].
  • [report.checksum].
  • [output] with emulate presets (xbox-360, xbox-elite2, dualsense, dualsense-edge, switch-pro), plus [output.imu] and [output.touchpad].

4. Validate and test

padctl --validate devices/<vendor>/<model>.toml   # or ./zig-out/bin/padctl from a source build
padctl --config devices/<vendor>/<model>.toml &
evtest /dev/input/eventNN

Exit 0 is valid, 1 is validation errors, 2 is file not found or parse failure. With evtest, check every axis range and centering, every button, all 8 D-pad directions and trigger ramps. From a source checkout, run zig build test before submitting.

5. Debug

  • padctl doctor checks the daemon, config paths and permissions. Paste its output in reports.
  • padctl status checks the daemon socket.
  • padctl dump enable, reproduce the issue, then padctl dump export --period 5m -o bug.log, then padctl dump disable. See Diagnostic Logging.

6. When TOML is not enough

Stateful handshakes, rolling counters, split fields and calibration reads need a WASM plugin ([wasm] in the reference). See switch-pro.toml or dualsense.toml. If that is out of reach, open an issue with the captures.

7. Report

  • State exactly what was tested on hardware and what was not.
  • Attach captures, the descriptor and lsusb -v output.
  • Do not claim support you did not verify. Mark untested parts as untested.