[WPE] Add ManetteGamepadProvider with libmanette 1.0 support and haptic feedback - #1709
Open
petartijanic01 wants to merge 3 commits into
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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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