Prevent restarting haptic playback from gamepad/keyboard while a clip plays#77
Closed
tomaabe wants to merge 1 commit into
Closed
Prevent restarting haptic playback from gamepad/keyboard while a clip plays#77tomaabe wants to merge 1 commit into
tomaabe wants to merge 1 commit into
Conversation
… plays
The Play WASAPI (L1) and Play XAudio2 (R1) buttons were wrapped in
ImGui::BeginDisabled while a clip was playing, but that only suppresses mouse
interaction. The gamepad shortcut ("|| IsButtonPressed(...)") bypassed the
disabled state entirely, and ImGui still activates a keyboard Space/Enter on a
button that already had focus. As a result a clip could be restarted from the
start, or the other engine started, mid-playback via the controller or the
keyboard.
Gate both play actions on !IsPlaying() for every input path (mouse, keyboard
and gamepad) so playback cannot be retriggered while active, and clear the
window focus on play so the now-disabled button stops showing a pressed
animation when Space is held.
|
Fixed internally, will be in the next github publish. |
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
While a clip is playing, the Play WASAPI (L1) and Play XAudio2 (R1) buttons could still be retriggered via the controller or the keyboard, restarting playback from the beginning or starting the other engine. Only mouse clicks were correctly blocked. This change gates both play actions on
!IsPlaying()for every input path.Repro steps
Root cause
The play buttons were wrapped in
ImGui::BeginDisabled(IsPlaying()), butBeginDisabledonly suppresses mouse interaction. The gamepad shortcut (|| IsButtonPressed(...)) bypassed the disabled state entirely, and ImGui still activates keyboard Space/Enter on a button that already had focus, so playback could be retriggered through those paths.Fix
!isPlayingso mouse, keyboard (Space/Enter) and gamepad (L1/R1) paths are all blocked while a clip is playing, and the two engines are mutually exclusive.ImGui::SetWindowFocus(nullptr)when playback starts so the now-disabled button does not keep showing a pressed animation when Space is held.Testing
Notes
haptics.cpp; no public API changes.