Fix protocol parsing races, config data loss and build - #10
Open
PericlesSavio wants to merge 10 commits into
Open
Fix protocol parsing races, config data loss and build#10PericlesSavio wants to merge 10 commits into
PericlesSavio wants to merge 10 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of the contribution series described in #9 — fixes only, each in its own commit:
cmd/flydigid04 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 intermittently254"externally handled" key marker: any config write (LEDs, deadzone) silently reverted keyboard mappings made by Space Station on Windowsoffactually apply to the bean — plus a smallleds offcommand to expose itinstallinstead ofmvinmake install:mvpreserves the SELinux label of the build directory, making systemd refuse to execute the daemon on FedoraTesting
Tested on a Vader 3 Pro ONE PIECE (device 81), wired and wireless (dongle), in DInput and XInput modes.
go build ./...andgo 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.