Refactor: reduce repetition and clarify non-obvious code#72
Merged
thePunderWoman merged 1 commit intomainfrom Apr 29, 2026
Merged
Refactor: reduce repetition and clarify non-obvious code#72thePunderWoman merged 1 commit intomainfrom
thePunderWoman merged 1 commit intomainfrom
Conversation
- drive_controllers: replace 4 repeated button-number switch blocks with DRIVE_BTNFIELD/DOME_BTNFIELD macros, consistent with existing macro style - buttons: extract processButtonLayer() helper; processButton/Long/Alt become one-line wrappers instead of three identical copies - audio: extract sendAllHCRVolumes(v,a,b); used in applyHCRVolume, restoreVolumes, and toggleMute - config: collapse 7 identical dome-seek else-if blocks (each calling applyDomePositionParams) into one chained || expression - audio.h: comment the unsigned-wraparound trick on fLastVolumeUpdate init Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
drive_controllers.cpp— Four 7-lineswitchblocks that mapped a button number to a PS3 button field have been replaced withDRIVE_BTNFIELD/DOME_BTNFIELDmacros, consistent with the existingDISPATCH_BUTTONmacro style in the same filebuttons.cpp/console.h—processButton,processLongButton, andprocessAltButtonwere structurally identical; extractedprocessButtonLayer(num, label, actions)and kept the three public methods as one-line wrappersaudio.cpp/audio.h— The three-lineSetVolume(CH_V…) SetVolume(CH_A…) SetVolume(CH_B…)pattern appeared inapplyHCRVolume,restoreVolumes, andtoggleMute; extractedsendAllHCRVolumes(v, a, b)config.cpp— Seven consecutive else-if blocks each callingapplyDomePositionParams()collapsed into one chained||expression, matching the pattern already used elsewhere inprocessConfigaudio.h— One-line comment explaining the unsigned-wraparound trick onfLastVolumeUpdateinitialisationNo behaviour changes. Net: −105 lines / +56 lines.
Test plan
pio test -e native— 448/448 passpio run— firmware builds clean🤖 Generated with Claude Code