Skip to content

Commit 4eaf82b

Browse files
committed
Gamepad.vibrationActuator.type should be "dual-rumble"
https://bugs.webkit.org/show_bug.cgi?id=250410 Reviewed by Alex Christensen. Gamepad.vibrationActuator.type should be "dual-rumble", not "vibration": - https://w3c.github.io/gamepad/extensions.html#dom-gamepadhapticactuatortype * LayoutTests/gamepad/gamepad-vibrationActuator-type-expected.txt: Added. * LayoutTests/gamepad/gamepad-vibrationActuator-type.html: Added. * Source/WebCore/Modules/gamepad/Gamepad.cpp: (WebCore::Gamepad::vibrationActuator): * Source/WebCore/Modules/gamepad/GamepadHapticActuator.cpp: (WebCore::GamepadHapticActuator::create): (WebCore::GamepadHapticActuator::GamepadHapticActuator): * Source/WebCore/Modules/gamepad/GamepadHapticActuator.h: Canonical link: https://commits.webkit.org/258758@main
1 parent 63b6c42 commit 4eaf82b

File tree

5 files changed

+46
-9
lines changed

5 files changed

+46
-9
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Tests for vibrationActuator.type
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
PASS gamepad.vibrationActuator.type is "dual-rumble"
7+
PASS successfullyParsed is true
8+
9+
TEST COMPLETE
10+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<head>
2+
<script src="../resources/js-test.js"></script>
3+
<body>
4+
<script>
5+
description("Tests for vibrationActuator.type");
6+
jsTestIsAsync = true;
7+
8+
function runTest() {
9+
addEventListener("gamepadconnected", e => {
10+
gamepad = e.gamepad;
11+
12+
shouldBeEqualToString("gamepad.vibrationActuator.type", "dual-rumble");
13+
14+
finishJSTest();
15+
});
16+
17+
testRunner.setMockGamepadDetails(0, "Test Gamepad", "", 2, 2);
18+
testRunner.setMockGamepadAxisValue(0, 0, 0.7);
19+
testRunner.setMockGamepadAxisValue(0, 1, -1.0);
20+
testRunner.setMockGamepadButtonValue(0, 0, 1.0);
21+
testRunner.setMockGamepadButtonValue(0, 1, 1.0);
22+
testRunner.connectMockGamepad(0);
23+
}
24+
25+
onload = runTest;
26+
</script>
27+
</body>

Source/WebCore/Modules/gamepad/Gamepad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void Gamepad::updateFromPlatformGamepad(const PlatformGamepad& platformGamepad)
7575
GamepadHapticActuator& Gamepad::vibrationActuator()
7676
{
7777
if (!m_vibrationActuator)
78-
m_vibrationActuator = GamepadHapticActuator::create(*this);
78+
m_vibrationActuator = GamepadHapticActuator::create(GamepadHapticActuator::Type::DualRumble, *this);
7979
return *m_vibrationActuator;
8080
}
8181

Source/WebCore/Modules/gamepad/GamepadHapticActuator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838

3939
namespace WebCore {
4040

41-
Ref<GamepadHapticActuator> GamepadHapticActuator::create(Gamepad& gamepad)
41+
Ref<GamepadHapticActuator> GamepadHapticActuator::create(Type type, Gamepad& gamepad)
4242
{
43-
return adoptRef(*new GamepadHapticActuator(gamepad));
43+
return adoptRef(*new GamepadHapticActuator(type, gamepad));
4444
}
4545

46-
GamepadHapticActuator::GamepadHapticActuator(Gamepad& gamepad)
47-
: m_type { Type::Vibration }
46+
GamepadHapticActuator::GamepadHapticActuator(Type type, Gamepad& gamepad)
47+
: m_type { type }
4848
, m_gamepad { gamepad }
4949
{
5050
}

Source/WebCore/Modules/gamepad/GamepadHapticActuator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ struct GamepadEffectParameters;
4141

4242
class GamepadHapticActuator : public RefCounted<GamepadHapticActuator> {
4343
public:
44-
static Ref<GamepadHapticActuator> create(Gamepad&);
45-
~GamepadHapticActuator();
46-
4744
using EffectType = GamepadHapticEffectType;
4845
enum class Type : uint8_t { Vibration, DualRumble };
4946
enum class Result : uint8_t { Complete, Preempted };
5047

48+
static Ref<GamepadHapticActuator> create(Type, Gamepad&);
49+
~GamepadHapticActuator();
50+
5151
Type type() const { return m_type; }
5252
bool canPlayEffectType(EffectType) const;
5353
void playEffect(Document&, EffectType, GamepadEffectParameters&&, Ref<DeferredPromise>&&);
5454
void reset(Document&, Ref<DeferredPromise>&&);
5555

5656
private:
57-
explicit GamepadHapticActuator(Gamepad&);
57+
GamepadHapticActuator(Type, Gamepad&);
5858

5959
Type m_type;
6060
WeakPtr<Gamepad> m_gamepad;

0 commit comments

Comments
 (0)