Skip to content

SebastienDuruz/Uinput-Reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UinputReader

C# service for reading Linux evdev input events from /dev/input/event*.

Projects

  • src/InputEvents.Core: discovery, evdev reading, decoding, and routing library.
  • src/InputEvents.Daemon: optional CLI daemon (--list-devices, --listen, --json).

Build

dotnet build UinputReader.sln

Daemon Usage

List available input devices:

dotnet run --project src/InputEvents.Daemon -- --list-devices

Listen to keyboard events (default behavior):

dotnet run --project src/InputEvents.Daemon -- --listen

Stream JSON lines:

dotnet run --project src/InputEvents.Daemon -- --listen --json

C# Example usage

using 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");
    }
}

Permissions

Reading /dev/input/event* usually requires root privileges or membership in the input group.

  • The service handles EACCES / EPERM and marks devices as inaccessible.
  • See docs/udev-rules.md for a recommended udev setup.

Notes

  • Works on both X11 and Wayland because it reads kernel-level input events.
  • /dev/uinput is used to create virtual devices and inject events; it is not the source of physical keyboard events.
  • No persistent event storage is implemented.

About

c# Demo project showing Uinput read on Linux

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages