Repository navigation
Conversation
Gamepad.copy() carries only the Xbox button names and sets the PlayStation ones from them, so a script that set triangle, cross, share and so on was silently ignored. Each PlayStation name is now ORed into its Xbox twin on a staging copy before delivery, so the OpMode sees the button under both names, as on the robot; the script's own gamepad is not changed, so releasing the button releases it.
This branch has not been deployed
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.
What
A
GamepadScriptthat presses a button by its PlayStation name (triangle,cross,circle,square,share,options,ps) now reaches the OpMode, which sees it under both names, as on the robot. Releasing it releases it.Why
Gamepad.copy()isfromByteArray(other.toByteArray());toByteArraycarries only the Xbox names (a, b, x, y,back, start, guide), and
fromByteArraythen sets the PlayStation names from them (updateButtonAliases; checkedwith
javap -cagainst RobotCore 12.0.0). Sogamepad1.triangle = truein a script was silently dropped: theOpMode saw neither
trianglenory. Teams with PS controllers write their code with PS names, so they write theirscripts that way too, and the test just doesn't press anything. We lost time on exactly this.
OpModeContext.beforeUserCodenow stages the copy: the script's gamepad is copied to a stagingGamepad, eachPlayStation name is ORed into its Xbox twin there, and the staging copy is delivered with
copy()as before. Thescript's own gamepad is never written, so a button stays down exactly as long as the script holds it. Edge
detection (
triangleWasPressed(),yWasPressed()) works under both names.GamepadScript's javadoc says eithername works.
How I tested it
New test in
IterativeOpModeRunnerTest: a script holdstrianglefor two ticks and tapsshareonce; the OpModesees
triangleandyboth down for exactly those ticks,backandsharefor the tap, andtriangleWasPressed(),yWasPressed()andshareWasPressed()once each. Without the change it fails../gradlew :SimLoop:testDebugUnitTest --rerun: all pass.:examples:testDebugUnitTestand:SimLoop:desktop:testpass. The leak gate passes../gradlew testpasses on my machineNew or changed behaviour has a test
If I touched docs or public javadoc:
./gradlew :SimLoop:docsSitepassesChecklist