Skip to content

Commit d796615

Browse files
authored
Merge pull request #1442 from ganeshprasads/wpe-2.38-gp-analog-button
Send analog button values based on W3C GamePad
2 parents 08bfd3f + 6aa8bee commit d796615

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Source/WebCore/platform/gamepad/wpe/WPEGamepad.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ WPEGamepad::WPEGamepad(struct wpe_gamepad_provider* provider, uintptr_t gamepadI
5858
auto& self = *static_cast<WPEGamepad*>(data);
5959
self.absoluteAxisChanged(static_cast<unsigned>(axis), value);
6060
},
61-
nullptr, nullptr, nullptr,
61+
// analog_button_value
62+
[](void* data, enum wpe_gamepad_button button, double value) {
63+
auto& self = *static_cast<WPEGamepad*>(data);
64+
self.analogButtonChanged(static_cast<unsigned>(button), value);
65+
},
66+
nullptr, nullptr,
6267
};
6368
wpe_gamepad_set_client(m_gamepad.get(), &s_client, this);
6469
}
@@ -84,6 +89,15 @@ void WPEGamepad::absoluteAxisChanged(unsigned axis, double value)
8489
WPEGamepadProvider::singleton().scheduleInputNotification(*this, WPEGamepadProvider::ShouldMakeGamepadsVisible::Yes);
8590
}
8691

92+
void WPEGamepad::analogButtonChanged(unsigned button, double value)
93+
{
94+
m_lastUpdateTime = MonotonicTime::now();
95+
m_buttonValues[button].setValue(clampTo(value, 0.0, 1.0));
96+
97+
WPEGamepadProvider::singleton().scheduleInputNotification(*this, WPEGamepadProvider::ShouldMakeGamepadsVisible::Yes);
98+
99+
}
100+
87101
} // namespace WebCore
88102

89103
#endif // ENABLE(GAMEPAD)

Source/WebCore/platform/gamepad/wpe/WPEGamepad.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class WPEGamepad final : public PlatformGamepad {
4848
private:
4949
void buttonPressedOrReleased(unsigned, bool);
5050
void absoluteAxisChanged(unsigned, double);
51+
void analogButtonChanged(unsigned, double);
5152

5253
Vector<SharedGamepadValue> m_buttonValues;
5354
Vector<SharedGamepadValue> m_axisValues;

0 commit comments

Comments
 (0)