[WPE] Add ManetteGamepadProvider with libmanette 1.0 support and haptic feedback - #1709
Conversation
Add USE_MANETTE_GAMEPAD_PROVIDER cmake option (default OFF) that allows WPE to use ManetteGamepadProvider (direct libmanette) instead of the existing GamepadLibWPE (libwpe gamepad) backend. When enabled (-DUSE_MANETTE_GAMEPAD_PROVIDER=ON): - FindManette.cmake searches for manette-1 first, falls back to manette-0.2 - WebCore builds ManetteGamepad.cpp/ManetteGamepadProvider.cpp - WebKit builds UIGamepadProviderManette.cpp When disabled (default): - WebCore builds GamepadLibWPE.cpp/GamepadProviderLibWPE.cpp - WebKit builds UIGamepadProviderLibWPE.cpp - Original libwpe-based gamepad input routing is preserved This brings the WPE port in line with how the GTK port uses libmanette directly, while keeping GamepadLibWPE as the default. * Source/cmake/FindManette.cmake: * Source/cmake/OptionsWPE.cmake: * Source/WebCore/PlatformWPE.cmake: * Source/WebCore/SourcesWPE.txt: * Source/WebKit/PlatformWPE.cmake: * Source/WebKit/SourcesWPE.txt: * Source/WebKit/UIProcess/API/wpe/WPEWebViewLegacy.cpp: * Source/WebKit/UIProcess/Gamepad/manette/UIGamepadProviderManette.cpp:
Port gamepad haptic feedback (dual-rumble) support to the WPE ManetteGamepadProvider, matching the GTK port implementation. Uses MANETTE_CHECK_VERSION(0, 2, 13) to select the correct rumble API: - >= 0.2.13 (and all of 1.0): magnitudes passed as double directly - < 0.2.13: magnitudes scaled by G_MAXUINT16 Includes a fallback #define for MANETTE_CHECK_VERSION for libmanette versions < 0.2.10 that lack the macro. Also enables defaultGamepadVibrationActuatorEnabled when USE(MANETTE). * Source/WebCore/platform/gamepad/manette/ManetteGamepad.cpp: (WebCore::ManetteGamepad::ManetteGamepad): (WebCore::ManetteGamepad::playEffect): (WebCore::ManetteGamepad::stopEffects): (WebCore::ManetteGamepad::effectDelayTimerFired): (WebCore::ManetteGamepad::startRumble): (WebCore::ManetteGamepad::effectDurationTimerFired): * Source/WebCore/platform/gamepad/manette/ManetteGamepad.h: * Source/WebCore/platform/gamepad/manette/ManetteGamepadProvider.cpp: (WebCore::ManetteGamepadProvider::playEffect): (WebCore::ManetteGamepadProvider::stopEffects): * Source/WebKit/Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultGamepadVibrationActuatorEnabled):
Add MANETTE_CHECK_VERSION(1, 0, 0) guards to support libmanette 1.0 while retaining compilation with 0.2: - Signal callbacks: 1.0 uses direct parameter signals (button-pressed, button-released, absolute-axis-changed with ManetteButton/ManetteAxis), 0.2 uses ManetteEvent-based signals (button-press-event, etc.) - Button mapping: 1.0 uses ManetteButton enum (MANETTE_BUTTON_SOUTH, etc.), 0.2 uses linux input-event-codes (BTN_A, etc.) - Axis mapping: 1.0 uses ManetteAxis enum with trigger axes, 0.2 uses ABS_* constants - Device iteration: 1.0 uses manette_monitor_list_devices(), 0.2 uses ManetteMonitorIter - Analog trigger support in 1.0 via analogButtonChanged() for MANETTE_AXIS_LEFT_TRIGGER / MANETTE_AXIS_RIGHT_TRIGGER - GUniquePtrManette.h include guarded (ManetteMonitorIter absent in 1.0) * Source/WebCore/platform/gamepad/manette/ManetteGamepad.cpp: * Source/WebCore/platform/gamepad/manette/ManetteGamepad.h: * Source/WebCore/platform/gamepad/manette/ManetteGamepadProvider.cpp:
|
@petartijanic01 : how did you test this PR? with WPEFramework? To test it on my side with WPEFramework I had to do some libmanette modification which I am trying to upstream: https://gitlab.gnome.org/GNOME/libmanette/-/merge_requests/160. |
| #if MANETTE_CHECK_VERSION(0, 2, 13) | ||
| manette_device_rumble(m_device.get(), parameters.strongMagnitude, parameters.weakMagnitude, static_cast<guint>(parameters.duration)); | ||
| #else | ||
| manette_device_rumble(m_device.get(), parameters.strongMagnitude * G_MAXUINT16, parameters.weakMagnitude * G_MAXUINT16, static_cast<guint>(parameters.duration)); | ||
| #endif |
There was a problem hiding this comment.
In libmanette < 1.0 manette_device_rumble uses guint16 in case of magnitudes:
https://github.com/GNOME/libmanette/blob/0.2.13/src/manette-device.h#L48
even in case of development 0.2 branch, they are still guint16:
https://github.com/GNOME/libmanette/blob/libmanette-0-2/src/manette-device.h#L48
only in development main branch they changed that to double:
https://github.com/GNOME/libmanette/blob/main/src/manette-device.h#L84
GNOME/libmanette@4a3ee6c
I know that this is because you backport this change from upstream and in upstream there is the same bug. I am going to fix that in upstream: https://bugs.webkit.org/show_bug.cgi?id=323663
There was a problem hiding this comment.
and one more thing, MANETTE_CHECK_VERSION was introduced in 0.2.10, before that version this macro does not exist
This PR adds
USE_MANETTE_GAMEPAD_PROVIDER(default OFF) to allow the WPE portto use ManetteGamepadProvider directly, matching the GTK port's approach.
Motivation
The existing ManetteGamepadProvider (used by the GTK port) lacks:
digital button events (0/1). libmanette 1.0 exposes triggers as axis events
(
MANETTE_AXIS_LEFT_TRIGGER/MANETTE_AXIS_RIGHT_TRIGGER) with continuous0.0–1.0 values, enabling proper analog input per the W3C Gamepad spec.
ManetteGamepadProvider on WPE. This PR ports the GTK implementation using
manette_device_rumble().API (ManetteEvent-based signals, BTN_* constants, ManetteMonitorIter).
Changes
Commit 1: Build toggle
USE_MANETTE_GAMEPAD_PROVIDERcmake option (default OFF). FindManette.cmaketries
manette-1first, falls back tomanette-0.2. When enabled, buildsManetteGamepadProvider instead of GamepadLibWPE.
Commit 2: playEffect (haptic feedback)
Rumble support via
manette_device_rumble(), ported from the GTK implementation(upstream commit 2e1369350dab). Uses
MANETTE_CHECK_VERSION(0, 2, 13)for APIselection between double and guint16 magnitudes.
Commit 3: libmanette 1.0 API with 0.2 fallback
Version-guarded signal names, button/axis enums, device iteration, and
analogButtonChanged()for analog triggers. Includes#ifndef MANETTE_CHECK_VERSIONfallback for libmanette < 0.2.10.
Tested with both libmanette 0.2.6 and 1.0.
f212889