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

Send analog button values based on W3C GamePad #1410

Open
wants to merge 1 commit into
base: wpe-2.38
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Source/WebCore/platform/gamepad/wpe/WPEGamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ WPEGamepad::WPEGamepad(struct wpe_gamepad_provider* provider, uintptr_t gamepadI
auto& self = *static_cast<WPEGamepad*>(data);
self.absoluteAxisChanged(static_cast<unsigned>(axis), value);
},
nullptr, nullptr, nullptr,
// analog_button_value
[](void* data, enum wpe_gamepad_button button, double value) {
auto& self = *static_cast<WPEGamepad*>(data);
self.analogButtonChanged(static_cast<unsigned>(button), value);
},
nullptr, nullptr,
};
wpe_gamepad_set_client(m_gamepad.get(), &s_client, this);
}
Expand All @@ -84,6 +89,15 @@ void WPEGamepad::absoluteAxisChanged(unsigned axis, double value)
WPEGamepadProvider::singleton().scheduleInputNotification(*this, WPEGamepadProvider::ShouldMakeGamepadsVisible::Yes);
}

void WPEGamepad::analogButtonChanged(unsigned button, double value)
{
m_lastUpdateTime = MonotonicTime::now();
m_buttonValues[button].setValue(value);
Copy link

Choose a reason for hiding this comment

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

can we assure that the lower layers will send values between 0 and 1?

would it make sense to clamp or even assert those received values?


WPEGamepadProvider::singleton().scheduleInputNotification(*this, WPEGamepadProvider::ShouldMakeGamepadsVisible::Yes);

}

} // namespace WebCore

#endif // ENABLE(GAMEPAD)
1 change: 1 addition & 0 deletions Source/WebCore/platform/gamepad/wpe/WPEGamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class WPEGamepad final : public PlatformGamepad {
private:
void buttonPressedOrReleased(unsigned, bool);
void absoluteAxisChanged(unsigned, double);
void analogButtonChanged(unsigned, double);

Vector<SharedGamepadValue> m_buttonValues;
Vector<SharedGamepadValue> m_axisValues;
Expand Down