Skip to content

Fix protocol parsing races, config data loss and build - #10

Open
PericlesSavio wants to merge 10 commits into
pipe01:masterfrom
PericlesSavio:fix/protocol-and-build
Open

Fix protocol parsing races, config data loss and build#10
PericlesSavio wants to merge 10 commits into
pipe01:masterfrom
PericlesSavio:fix/protocol-and-build

Conversation

@PericlesSavio

Copy link
Copy Markdown

Part 1 of the contribution series described in #9 — fixes only, each in its own commit:

  • Fix build break from an unused import in cmd/flydigid
  • Filter gamepad state packets (04 FE) out of config parsing: they stream continuously on the config interface and carry sensor data in the bytes the config checks look at, so they were randomly mistaken for config chunks or write acks, corrupting reads and writes intermittently
  • Preserve the 254 "externally handled" key marker: any config write (LEDs, deadzone) silently reverted keyboard mappings made by Space Station on Windows
  • Fix LED conversion panic on unmodeled modes (breathing, gradient, feedback) and make off actually apply to the bean — plus a small leds off command to expose it
  • Fix stale gamepad connection after disconnect: on a dead USB handle the daemon could return a zombie connection forever
  • Fix XInput device teardown (USB context cleanup on early returns and close)
  • Use install instead of mv in make install: mv preserves the SELinux label of the build directory, making systemd refuse to execute the daemon on Fedora
  • Adds the project's first unit tests (state packet filtering, LED conversion)

Testing

Tested on a Vader 3 Pro ONE PIECE (device 81), wired and wireless (dongle), in DInput and XInput modes. go build ./... and go test ./... pass.

Next in the series (branches ready on my fork, one PR at a time): button mapping command, keyboard mapping through uinput, Qt GUI, packaging.

State packets (04 FE) stream continuously on the config interface and
carry sensor data in the bytes the config checks look at, so they were
randomly mistaken for config chunks or write acks, corrupting reads and
writes intermittently.
Space Station stores keyboard-mapped buttons as the special 254 marker.
Reading the config converted it to an identity mapping, so any write
(LEDs, deadzone) silently reverted those buttons to plain gamepad
output.
Reading a controller set to an unmodeled LED mode (breathing, gradient,
feedback) crashed the daemon. Also, applying LedsConfiguration_Off did
not modify the bean at all, so turning LEDs off was never actually
written to the controller.
Disconnect relied on the read loop noticing the close to clear the
connection. On a dead USB handle the loop may never exit, leaving the
daemon stuck returning a zombie connection forever. Clear it right
away, and guard the async clear so it cannot wipe a newer connection.
Close the gousb context on early-return paths and rework the close
sequence so the device handle and context are released reliably before
reloading xpad.
mv preserves the SELinux label of the build directory (user_home_t on
Fedora), which makes systemd refuse to execute the daemon. install
creates the files with the destination's default context.
Companion to the LED 'off' fix: exposes turning the LEDs off through
the CLI, which previously had no way to do it.
Tested: config read/write, button remapping, keyboard mapping and LEDs
all work on the ONE PIECE edition (device 81), wired and wireless.
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.

1 participant