Skip to content

[WPE] Add ManetteGamepadProvider with libmanette 1.0 support and haptic feedback - #1709

Open
petartijanic01 wants to merge 3 commits into
WebPlatformForEmbedded:wpe-2.46from
petartijanic01:feature/manette-gamepad-provider-toggle
Open

[WPE] Add ManetteGamepadProvider with libmanette 1.0 support and haptic feedback#1709
petartijanic01 wants to merge 3 commits into
WebPlatformForEmbedded:wpe-2.46from
petartijanic01:feature/manette-gamepad-provider-toggle

Conversation

@petartijanic01

@petartijanic01 petartijanic01 commented Aug 6, 2026

Copy link
Copy Markdown

This PR adds USE_MANETTE_GAMEPAD_PROVIDER (default OFF) to allow the WPE port
to use ManetteGamepadProvider directly, matching the GTK port's approach.

Motivation

The existing ManetteGamepadProvider (used by the GTK port) lacks:

  • Analog trigger support — with libmanette 0.2, triggers are reported as
    digital button events (0/1). libmanette 1.0 exposes triggers as axis events
    (MANETTE_AXIS_LEFT_TRIGGER / MANETTE_AXIS_RIGHT_TRIGGER) with continuous
    0.0–1.0 values, enabling proper analog input per the W3C Gamepad spec.
  • Haptic feedback — playEffect (dual-rumble) was not implemented for the
    ManetteGamepadProvider on WPE. This PR ports the GTK implementation using
    manette_device_rumble().
  • libmanette 1.0 support — the existing code only supports libmanette 0.2
    API (ManetteEvent-based signals, BTN_* constants, ManetteMonitorIter).

Changes

Commit 1: Build toggle
USE_MANETTE_GAMEPAD_PROVIDER cmake option (default OFF). FindManette.cmake
tries manette-1 first, falls back to manette-0.2. When enabled, builds
ManetteGamepadProvider 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 API
selection 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_VERSION
fallback for libmanette < 0.2.10.

Tested with both libmanette 0.2.6 and 1.0.
f212889

Build-Tests Layout-Tests
✅ 🛠 wpe-246-amd64-build ✅ 🧪 wpe-246-amd64-layout
✅ 🛠 wpe-246-arm32-build ❌ 🧪 wpe-246-arm32-layout

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:
@emutavchi
emutavchi requested a review from magomez August 6, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants