Skip to content
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

[GameController] Correctly handle magnitude values passed to GamepadHapticActuator.playEffect() #8653

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Jan 14, 2023

7ad0df2

[GameController] Correctly handle magnitude values passed to GamepadHapticActuator.playEffect()
https://bugs.webkit.org/show_bug.cgi?id=250616

Reviewed by Youenn Fablet.

Correctly handle magnitude values passed to GamepadHapticActuator.playEffect()
when passing them to the GameController framework.

We noticed different Gamepad vibration results between Safari and Chrome for
the same magnitude values. One obvious difference was that values below 0.1
didn't result in any vibration in Safari but did in Chrome.

In 258874@main, I made an attempt to address this by scaling the input
magnitude (in the range [0; 1]) to be in the range [0.1; 1] in order to
always get a vibration if the magnitude value is not zero.

However, I have since heard back from GameController developers who have
indicating that we should be using the square root of the magnitude,
instead of the raw magnitude value. This is due to the fact that the
GameController framework doesn't use the input value as-is internally.

I am therefore updating our code to use the suggested approach. I have
validated on XBox Cloud that the level of vibration feels similar between
Safari and Chrome.

* Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.mm:
(WebCore::magnitudeToIntensity):

Canonical link: https://commits.webkit.org/258988@main

83d3fa9

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  watch-sim
βœ… πŸ›  πŸ§ͺ unsafe-merge

@cdumez cdumez self-assigned this Jan 14, 2023
@cdumez cdumez added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Jan 14, 2023
Copy link
Contributor

@youennf youennf left a comment

Choose a reason for hiding this comment

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

LGTM.
By any chance, do you know what Chrome is doing on macOS?

@cdumez
Copy link
Contributor Author

cdumez commented Jan 16, 2023

LGTM.
By any chance, do you know what Chrome is doing on macOS?

They are using low level HID directly, not the GameController framework as far as I could tell.

@cdumez cdumez added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jan 17, 2023
…apticActuator.playEffect()

https://bugs.webkit.org/show_bug.cgi?id=250616

Reviewed by Youenn Fablet.

Correctly handle magnitude values passed to GamepadHapticActuator.playEffect()
when passing them to the GameController framework.

We noticed different Gamepad vibration results between Safari and Chrome for
the same magnitude values. One obvious difference was that values below 0.1
didn't result in any vibration in Safari but did in Chrome.

In 258874@main, I made an attempt to address this by scaling the input
magnitude (in the range [0; 1]) to be in the range [0.1; 1] in order to
always get a vibration if the magnitude value is not zero.

However, I have since heard back from GameController developers who have
indicating that we should be using the square root of the magnitude,
instead of the raw magnitude value. This is due to the fact that the
GameController framework doesn't use the input value as-is internally.

I am therefore updating our code to use the suggested approach. I have
validated on XBox Cloud that the level of vibration feels similar between
Safari and Chrome.

* Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.mm:
(WebCore::magnitudeToIntensity):

Canonical link: https://commits.webkit.org/258988@main
@webkit-commit-queue
Copy link
Collaborator

Committed 258988@main (7ad0df2): https://commits.webkit.org/258988@main

Reviewed commits have been landed. Closing PR #8653 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 7ad0df2 into WebKit:main Jan 17, 2023
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
4 participants