Add input event reporting to the evdev-rs input platform#4769
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for Mir’s input event reporting (mir::input::InputReport) to the Rust-based evdev-rs input platform so that input events processed via libinput can be reported through the existing Mir reporting pipeline (e.g. --input-report=log).
Changes:
- Threads an
InputReportinstance from the C++ platform factory into the RustPlatformRsvia CXX (UniquePtr). - Calls
received_event_from_kernel()from Rust while processing libinput pointer/keyboard/touch events. - Introduces a small C++ wrapper (
mir::input::evdev_rs::InputReport) and adds theinput-event-codesRust dependency for evdev constants.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platforms/evdev-rs/src/platform.rs | Stores the report object in PlatformRs and passes it into event processing. |
| src/platforms/evdev-rs/src/lib.rs | Extends the CXX bridge to include InputReport and pass it into evdev_rs_create(). |
| src/platforms/evdev-rs/src/event_processing.rs | Emits input-report callbacks while handling libinput events. |
| src/platforms/evdev-rs/platform_factory.cpp | Passes Mir’s InputReport into the evdev-rs platform instance. |
| src/platforms/evdev-rs/platform.h | Updates platform constructor signature to accept the report. |
| src/platforms/evdev-rs/platform.cpp | Wraps and forwards the report object into Rust via UniquePtr. |
| src/platforms/evdev-rs/input_report.h | Declares the C++ “Rust-friendly” InputReport wrapper type. |
| src/platforms/evdev-rs/input_report.cpp | Implements forwarding to mir::input::InputReport. |
| src/platforms/evdev-rs/Cargo.toml | Adds input-event-codes dependency (workspace). |
| src/platforms/evdev-rs/CMakeLists.txt | Builds the new input_report.{h,cpp} wrapper. |
| Cargo.toml | Adds input-event-codes to workspace dependencies. |
| Cargo.lock | Records new dependency and lockfile updates. |
| { | ||
| public: | ||
| explicit InputReport(std::shared_ptr<input::InputReport> const& report); | ||
| void received_event_from_kernel(uint64_t when_microseconds, int32_t type, uint32_t code, uint32_t value) const; |
There was a problem hiding this comment.
The wrapper method takes code/value as uint32_t, but the underlying mir::input::InputReport::received_event_from_kernel(...) expects int code, int value (signed). This makes it impossible to forward negative value and can lead to surprising wraparound when casting. Align the wrapper signature with the underlying API (use signed types for code/value) so the Rust/C++ boundary preserves the original event data.
| void received_event_from_kernel(uint64_t when_microseconds, int32_t type, uint32_t code, uint32_t value) const; | |
| void received_event_from_kernel(uint64_t when_microseconds, int32_t type, int32_t code, int32_t value) const; |
tarek-y-ismail
left a comment
There was a problem hiding this comment.
Two small nits. Otherwise good 👍
| add_library(mirplatforminputevdevrsobjects OBJECT | ||
| platform.cpp | ||
| platform_bridge.cpp platform_bridge.h | ||
| input_report.cpp input_report.h |
There was a problem hiding this comment.
Nit: Alignment
| input_report.cpp input_report.h | |
| input_report.cpp input_report.h |
…mir into feature/evdev_rs_input_report
TICS Quality Gate✔️ Passedmir
|
What's new?
InputReportclassUniquePtr<InputReport>to rust when creating the evdev-rs platformInputReport::received_event_from_kernelin the appropriate places in the evdev-rs platforminput-event-codesas a dependency to provide constantsHow to test
miral-shellwith:Checklist