New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gamepad.vibrationActuator: Add support for "trigger-rumble" effect type #9075
Gamepad.vibrationActuator: Add support for "trigger-rumble" effect type #9075
Conversation
b35dd5c
to
24bea12
Compare
EWS run on current version of this PR (hash 24bea12)
|
Ping review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but please see my question about the effect promise lifecycle.
m_playingEffectPromise = WTFMove(promise); | ||
GamepadProvider::singleton().playEffect(m_gamepad->index(), m_gamepad->id(), effectType, effectParameters, [this, protectedThis = makePendingActivity(*this), playingEffectPromise = m_playingEffectPromise](bool success) mutable { | ||
if (m_playingEffectPromise != playingEffectPromise) | ||
currentEffectPromise = WTFMove(promise); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we move the promise
argument to the local currentEffectPromise
variable, but don't move that into the playEffect closure, could this go out of scope and cause problems? Previously it was moved to the m_playingEffectPromise
, which seems like it would keep it alive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentEffectPromise
is declared like so:
auto& currentEffectPromise = promiseForEffectType(effectType);
and it returns a reference to the right promise data member. I didn't change any lifetime here. The promise still gets stored as RefPtr in a data member. It is merely abstracted away by the currentEffectPromise
C++ reference since we have more than one such data member now.
currentEffectPromise = WTFMove(promise); | ||
GamepadProvider::singleton().playEffect(m_gamepad->index(), m_gamepad->id(), effectType, effectParameters, [this, protectedThis = makePendingActivity(*this), playingEffectPromise = currentEffectPromise, effectType](bool success) mutable { | ||
auto& currentEffectPromise = promiseForEffectType(effectType); | ||
if (playingEffectPromise != currentEffectPromise) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is keeping currentEffectPromise
alive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promiseForEffectType() returns a reference to a data member that is a RefPtr.
https://bugs.webkit.org/show_bug.cgi?id=250352 rdar://104315486 Reviewed by Brent Fulgham and Geoffrey Garen. Gamepad.vibrationActuator: Add support for "trigger-rumble" effect type: - https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/GamepadHapticsActuatorTriggerRumble/explainer.md It allows vibrating the triggers (which the XBox controller supports), while the existing "dual-rumble" only makes the handles vibrate. This isn't yet part of the specification at: - https://w3c.github.io/gamepad/extensions.html#dom-gamepadhapticeffecttype However, it is supported by Blink and used by XBox cloud games. I am adding support behind an experimental feature flag, off by default. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Modules/gamepad/GamepadEffectParameters.h: * Source/WebCore/Modules/gamepad/GamepadEffectParameters.idl: * Source/WebCore/Modules/gamepad/GamepadHapticActuator.cpp: (WebCore::GamepadHapticActuator::canPlayEffectType const): (WebCore::GamepadHapticActuator::playEffect): (WebCore::GamepadHapticActuator::stopEffects): (WebCore::GamepadHapticActuator::document const): (WebCore::GamepadHapticActuator::promiseForEffectType): * Source/WebCore/Modules/gamepad/GamepadHapticActuator.h: * Source/WebCore/Modules/gamepad/GamepadHapticEffectType.idl: * Source/WebCore/platform/gamepad/cocoa/GameControllerGamepad.mm: (WebCore::GameControllerGamepad::setupElements): * Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.h: * Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.mm: (WebCore::GameControllerHapticEffect::create): (WebCore::GameControllerHapticEffect::GameControllerHapticEffect): (WebCore::GameControllerHapticEffect::start): (WebCore::GameControllerHapticEffect::stop): (WebCore::GameControllerHapticEffect::leftEffectFinishedPlaying): (WebCore::GameControllerHapticEffect::rightEffectFinishedPlaying): (WebCore::GameControllerHapticEffect::strongEffectFinishedPlaying): Deleted. (WebCore::GameControllerHapticEffect::weakEffectFinishedPlaying): Deleted. * Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEngines.h: (WebCore::GameControllerHapticEngines::leftHandleEngine): (WebCore::GameControllerHapticEngines::rightHandleEngine): (WebCore::GameControllerHapticEngines::leftTriggerEngine): (WebCore::GameControllerHapticEngines::rightTriggerEngine): (WebCore::GameControllerHapticEngines::strongEngine): Deleted. (WebCore::GameControllerHapticEngines::weakEngine): Deleted. * Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEngines.mm: (WebCore::GameControllerHapticEngines::GameControllerHapticEngines): (WebCore::GameControllerHapticEngines::currentEffectForType): (WebCore::GameControllerHapticEngines::playEffect): (WebCore::GameControllerHapticEngines::stopEffects): (WebCore::GameControllerHapticEngines::ensureStarted): (WebCore::GameControllerHapticEngines::stop): * Source/WebCore/platform/gamepad/cocoa/GameControllerSoftLink.h: * Source/WebCore/platform/gamepad/cocoa/GameControllerSoftLink.mm: * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Canonical link: https://commits.webkit.org/259507@main
24bea12
to
2dca512
Compare
Committed 259507@main (2dca512): https://commits.webkit.org/259507@main Reviewed commits have been landed. Closing PR #9075 and removing active labels. |
2dca512
24bea12