Architecture
padctl is a userspace daemon that maps vendor-specific USB/HID gamepad reports
to standard Linux input events via uinput or UHID. Device support is driven by
declarative TOML configs in devices/; user preferences live in separate
mapping TOMLs.
+----------------------------+
| Physical Device (USB / BT) |
+----------------------------+
|
+-------+-------+
| |
v v
+----------------+ +-------------------+
| HID / hidraw | | Vendor / libusb |
| io/hidraw.zig | | io/usbraw.zig |
+----------------+ +-------------------+
\ /
\ /
v v
+--------------------+
| DeviceIO (unified) |
+--------------------+
|
v
+--------------------+
| main loop (ppoll) |
+--------------------+
|
+---------+---------+
| |
v v
+------------------+ +------------------+
| config/device.zig| | io/netlink.zig |
| devices/*.toml | | kernel uevents |
+------------------+ +------------------+
|
v
+-----------------------------------------+
| [input rules] -> interpreter -> state |
| [output] -> OutputConfig |
+-----------------------------------------+
|
v
+----------------------+
| mapper (layer/remap) |
+----------------------+
| |
v v
+----------------+ +------------------+
| gamepad output | | auxiliary output |
| uinput or UHID | | mouse/touch/keys |
+----------------+ +------------------+
- I/O —
io/hidraw.zigreads HID devices;io/usbraw.ziguses libusb for vendor-class interfaces. Both sit behind oneDeviceIOinterface. - Main loop —
event_loop.zigruns appollloop;supervisor.ziguses netlink uevents (io/netlink.zig) to attach and detach devices on hotplug. - Device config —
config/device.zigparsesdevices/*.toml. Input rules feed an interpreter that produces gamepad state;[output]becomes anOutputConfig. - Mapper — applies the user's mapping (layers, remaps, gyro and stick modes), then emits to the virtual gamepad and the optional auxiliary mouse/touchpad/keyboard device.