C# service for reading Linux evdev input events from /dev/input/event*.
src/InputEvents.Core: discovery, evdev reading, decoding, and routing library.src/InputEvents.Daemon: optional CLI daemon (--list-devices,--listen,--json).
dotnet build UinputReader.slnList available input devices:
dotnet run --project src/InputEvents.Daemon -- --list-devicesListen to keyboard events (default behavior):
dotnet run --project src/InputEvents.Daemon -- --listenStream JSON lines:
dotnet run --project src/InputEvents.Daemon -- --listen --jsonusing InputEvents.Core;
using InputEvents.Core.Models;
using InputEvents.Core.Options;
var svc = new InputEventService(new InputEventServiceOptions
{
IncludeKinds = new[] { DeviceKind.Keyboard },
AutoDiscover = true
});
await svc.StartAsync(ct);
await foreach (var ev in svc.GetEventsAsync(ct))
{
if (ev is KeyEvent k && k.State == KeyState.Down)
{
Console.WriteLine($"{k.DevicePath} {k.Key} DOWN");
}
}Reading /dev/input/event* usually requires root privileges or membership in the input group.
- The service handles
EACCES/EPERMand marks devices as inaccessible. - See
docs/udev-rules.mdfor a recommended udev setup.
- Works on both X11 and Wayland because it reads kernel-level input events.
/dev/uinputis used to create virtual devices and inject events; it is not the source of physical keyboard events.- No persistent event storage is implemented.