Skip to content

Cutscenes: don't let the key that started a movie skip it - #8063

Open
AdmiralTolwyn wants to merge 2 commits into
scp-fs2open:masterfrom
AdmiralTolwyn:movie-held-key-skip
Open

AdmiralTolwyn wants to merge 2 commits into
scp-fs2open:masterfrom
AdmiralTolwyn:movie-held-key-skip

Conversation

@AdmiralTolwyn

@AdmiralTolwyn AdmiralTolwyn commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Movies are skipped on the release of Escape, Enter or Space. If one of those keys starts the movie, its release arrives once playback has begun and skips the movie at once. The easiest way to see it is the tech room cutscene list: select a cutscene, press Enter, and the movie is gone as soon as you let go of Enter. #4461 (for #4419) fixed the same thing for releases queued during the loading screen, but a live release still gets through.

This PR skips only on the release of a key whose press arrived during playback (auto-repeat doesn't count):

  • The press listener only records the key and passes the event on, so key.cpp, SCPUI and the On Key Pressed hook see presses as before. It's registered at DEFAULT_LISTENER_WEIGHT - 20 so that no other listener can consume a press before it's recorded.
  • Only the release that stops the movie is consumed. Other releases pass on, so a key held from before the movie isn't left marked as down while it plays.
  • os_remove_deferred_cutscene_key_events() now drops deferred key-downs along with their releases. Otherwise a down queued during the loading screen would be replayed into the movie, count as a press, and its live release would skip it.

Pressing and releasing Escape, Enter or Space during a movie still skips it. Three small changes mods could notice: On Key Released now fires during a movie for a skip key that was held from before it started (master swallowed that release); a skip key pressed during the loading screen and released during playback now fires On Key Released without a preceding On Key Pressed, because the deferred press is dropped (master fired the press and swallowed the release); and a key pressed during the first movie of a back-to-back pair no longer skips the second one if the first ends before the key is released.

Testing

  • I built 9f9d1e9 on macOS arm64 (Release) and ran the unit tests: 348 passed, 1 skipped. The skipped test is OptionsManagerOverride.ShadowRenderMethodDefaultFollowsTheGlobal, which is unrelated.
  • Retail FS2 data, tech room cutscene list, intro selected. Key events were pushed into SDL's event queue by a throwaway test shim. Enter was pressed to start the movie and released about a second later:
    • master 51041cf: 3 s after the release the cutscene list is back, so the release skipped the movie.
    • this PR: the movie is still playing. A fresh Enter press during playback fires On Key Pressed, and its release stops the movie.

movie skip, master vs this PR

Movies are skipped on the release of Escape, Enter or Space. When a
movie is started by one of those keys, for example Enter in the tech
room cutscene list, its release arrives once playback has begun and
skips the movie at once. scp-fs2open#4461 already dropped deferred releases from
the loading screen, but a live release still gets through.

Skip only on the release of a key whose press arrived during playback,
ignoring auto-repeat. The press listener only observes, so the other
key listeners and the On Key Pressed hook still see presses, and it
runs ahead of them so none can hide a press from it. Only the release
that stops playback is consumed; other releases pass on, so a key held
from before the movie is not left marked as down. Deferred key-downs
are now dropped together with their releases, since a replayed down
would count as a press.

@dustinspace217 dustinspace217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 9f9d1e9, and I could reproduce the fix.

Tested (Debug builds of master 5af50bd and this head, retail FS2 data, no mods, Linux, OpenGL): tech room cutscene list with every cutscene shown, Enter held for one second on the intro and then released. The keys were real X key events, not injected SDL events.

  • master: three seconds after the release, the cutscene list is back.
  • this PR: the intro is still playing. An Escape tap then returns to the list.

From reading: every movie the engine plays full screen, and so every movie a key can skip, goes through movie::play: the tech room, campaign and mission paths, and the Lua testing library's playCutscene. A script that drives its own player through gr.openMovie doesn't use these listeners. Nothing else listens for key-downs ahead of weight -20. key_flush() after the movie clears held keys. The record of presses is local to one play() call, which gives the back-to-back behavior the description lists.

Three small things, none blocking:

  • The release listener's weight (inline).
  • A third change mods could notice, beside the two listed: Enter or Space pressed on the loading screen and released during the movie now fires On Key Released with no On Key Pressed before it, since the deferred press is dropped. Master did the reverse.
  • Escape isn't in the deferred filter in os_remove_deferred_cutscene_key_events(), so an Escape tapped on a loading screen still skips the movie that follows, the same as master. The new comment there reads as if it covers every skip key.

Not tested: campaign and mission cutscenes, a key held through a loading screen, a scripted-UI mod, the script hooks, real key repeat, Windows and macOS.

Comment thread code/cutscene/movie.cpp Outdated
auto key_down_handle =
os::events::addEventListener(SDL_EVENT_KEY_DOWN, os::events::DEFAULT_LISTENER_WEIGHT - 20, key_down_listener);
auto key_up_handle =
os::events::addEventListener(SDL_EVENT_KEY_UP, os::events::DEFAULT_LISTENER_WEIGHT - 10, key_up_listener);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The press listener moved to -20, but this one stays at -10, the same weight as the scripted UI's key-up listener (rocket_ui.cpp:626). Listeners are ordered by std::sort on the weight, so which of the two runs first isn't defined. The scripted UI's handler consumes the event while its context is active, so if it sorts first, the release never gets here and the key can't skip. Master has the same tie, so this isn't new, but -20 here too would settle it. I read this from the code and did not run a scripted-UI mod.

Run the key-up listener at -20, before the scripted UI listener at -10
can consume the release. Equal weights have no defined order, so the
old tie could hide a skip release from movie playback.

Document the ordering beside the registration so the weight is not
mistaken for an interchangeable priority.
@AdmiralTolwyn

Copy link
Copy Markdown
Contributor Author

Thanks for testing it. The release listener now runs at -20 too (1a0aa74), with a comment on why, so it always runs before the scripted UI's key-up listener. Build and unit tests pass, and the tech-room repro behaves as before: holding, repeating and releasing the Enter that started the movie leaves it playing, and a fresh Enter skips it. I don't have a scripted-UI mod to test the consuming case directly.

I've also added the loading-screen press/release difference you found to the description.

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.

2 participants