Skip to content

Deliver buttons a script presses by their PlayStation names - #33

Open
saltyeg wants to merge 1 commit into
Horizon-36596:mainfrom
saltyeg:fix/playstation-button-names
Open

saltyeg wants to merge 1 commit into
Horizon-36596:mainfrom
saltyeg:fix/playstation-button-names

Conversation

@saltyeg

@saltyeg saltyeg commented Oct 29, 2026

Copy link
Copy Markdown

What

A GamepadScript that 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() is fromByteArray(other.toByteArray()); toByteArray carries only the Xbox names (a, b, x, y,
back, start, guide), and fromByteArray then sets the PlayStation names from them (updateButtonAliases; checked
with javap -c against RobotCore 12.0.0). So gamepad1.triangle = true in a script was silently dropped: the
OpMode saw neither triangle nor y. Teams with PS controllers write their code with PS names, so they write their
scripts that way too, and the test just doesn't press anything. We lost time on exactly this.

OpModeContext.beforeUserCode now stages the copy: the script's gamepad is copied to a staging Gamepad, each
PlayStation name is ORed into its Xbox twin there, and the staging copy is delivered with copy() as before. The
script'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 either
name works.

How I tested it

  • New test in IterativeOpModeRunnerTest: a script holds triangle for two ticks and taps share once; the OpMode
    sees triangle and y both down for exactly those ticks, back and share for the tap, and
    triangleWasPressed(), yWasPressed() and shareWasPressed() once each. Without the change it fails.

  • ./gradlew :SimLoop:testDebugUnitTest --rerun: all pass. :examples:testDebugUnitTest and
    :SimLoop:desktop:test pass. The leak gate passes.

  • ./gradlew test passes on my machine

  • New or changed behaviour has a test

  • If I touched docs or public javadoc: ./gradlew :SimLoop:docsSite passes

Checklist

  • No robot-specific or season-specific code (SimLoop stays season-agnostic)
  • Every new number says its unit, and its frame if it is a pose
  • Any public API change is called out above (none)
  • If an AI agent wrote some of this, a human has read the change and run the tests

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

No deployments
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