Skip to content

Add input event reporting to the evdev-rs input platform#4769

Merged
mattkae merged 10 commits intomainfrom
feature/evdev_rs_input_report
Mar 17, 2026
Merged

Add input event reporting to the evdev-rs input platform#4769
mattkae merged 10 commits intomainfrom
feature/evdev_rs_input_report

Conversation

@mattkae
Copy link
Copy Markdown
Contributor

@mattkae mattkae commented Mar 12, 2026

What's new?

  • Created the Rust-friendly InputReport class
  • Passed the UniquePtr<InputReport> to rust when creating the evdev-rs platform
  • Calling InputReport::received_event_from_kernel in the appropriate places in the evdev-rs platform
  • Added input-event-codes as a dependency to provide constants

How to test

  1. Run miral-shell with:
miral-shell --platform-path=/path/to/your/lib/server-modules \
  --platform-input-lib=mir:evdev-input-rs \
  --input-report=log
  1. Move the mouse around and press a bunch of keys and see that the events are properly being logged to the console 🎉

Checklist

  • Tests added and pass
  • Adequate documentation added
  • (optional) Added Screenshots or videos

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 InputReport instance from the C++ platform factory into the Rust PlatformRs via 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 the input-event-codes Rust 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.

Comment thread src/platforms/evdev-rs/src/lib.rs Outdated
Comment thread src/platforms/evdev-rs/input_report.h Outdated
{
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;
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
Comment thread src/platforms/evdev-rs/input_report.cpp Outdated
Comment thread src/platforms/evdev-rs/input_report.cpp
Comment thread src/platforms/evdev-rs/src/event_processing.rs Outdated
Copy link
Copy Markdown
Contributor

@tarek-y-ismail tarek-y-ismail left a comment

Choose a reason for hiding this comment

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

Two small nits. Otherwise good 👍

Comment thread src/platforms/evdev-rs/input_report.cpp Outdated
Comment thread src/platforms/evdev-rs/CMakeLists.txt Outdated
add_library(mirplatforminputevdevrsobjects OBJECT
platform.cpp
platform_bridge.cpp platform_bridge.h
input_report.cpp input_report.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Alignment

Suggested change
input_report.cpp input_report.h
input_report.cpp input_report.h

@mattkae mattkae enabled auto-merge March 17, 2026 12:42
@github-actions
Copy link
Copy Markdown

TICS Quality Gate

✔️ Passed

mir

Coding Standards: ✔️ Passed

✔️ Condition “No new Coding Standard Violations for level 1, 2, 3 with respect to Previous analysis” passed.

See the results in the TICS Viewer

The following files have been checked for this project
  • src/platforms/evdev-rs/input_report.cpp
  • src/platforms/evdev-rs/input_report.h
  • src/platforms/evdev-rs/platform_factory.cpp
  • src/platforms/evdev-rs/platform.cpp
  • src/platforms/evdev-rs/platform.h
  • src/platforms/evdev-rs/src/event_processing.rs
  • src/platforms/evdev-rs/src/lib.rs
  • src/platforms/evdev-rs/src/platform.rs

TICS / TICS / Run TICS analysis

@mattkae mattkae disabled auto-merge March 17, 2026 18:01
@mattkae mattkae merged commit b3eccaf into main Mar 17, 2026
39 of 44 checks passed
@mattkae mattkae deleted the feature/evdev_rs_input_report branch March 17, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants