Return std::expected from the ps5 controller feature reads#28
Merged
Conversation
Convert InputReader::GetControllerMacAll/Version/CalibrationData from an int 0/1 status (whose result the caller discarded) to std::expected<void, std::error_code>, marked [[nodiscard]]. Their two failure modes map to two error domains: an ioctl failure carries the errno via sys::ioctl, while a well-formed response that fails a protocol check (wrong ReportID / signature bytes) carries a new hid:: error category (src/bluez/hid_error.h) — the textbook way to represent a domain error in a std::error_code. Both compose through the same expected channel. open_and_init() now consumes the results: the feature reads are best-effort (a controller still streams input without calibration), so a failure is logged as a warning with the specific message and initialisation continues. Verified: full build green; a standalone check confirms the hid category (name "hid", message "invalid device response", enum comparison); a ps5 client start/SIGTERM cycle exits cleanly. Decoding a real controller needs hardware. Signed-off-by: Joel Winarske <joel.winarske@linux.com>
Addresses the CodeQL "no trivial switch statements" review comment on #28: a single-case switch reads more naturally as an if. Signed-off-by: Joel Winarske <joel.winarske@linux.com>
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.
Return std::expected from the ps5 controller feature reads
Convert InputReader::GetControllerMacAll/Version/CalibrationData from an int 0/1 status (whose result the caller discarded) to std::expected<void, std::error_code>, marked [[nodiscard]].
Their two failure modes map to two error domains: an ioctl failure carries the errno via sys::ioctl, while a well-formed response that fails a protocol check (wrong ReportID / signature bytes) carries a new hid:: error category
(src/bluez/hid_error.h) — the textbook way to represent a domain error in a std::error_code. Both compose through the same expected channel.
open_and_init() now consumes the results: the feature reads are best-effort (a controller still streams input without calibration), so a failure is logged as a warning with the specific message and initialisation continues.
Verified: full build green; a standalone check confirms the hid category (name "hid", message "invalid device response", enum comparison); a ps5 client start/SIGTERM cycle exits cleanly. Decoding a real controller needs hardware.