libinput-dotnet 1.30.4

dotnet add package libinput-dotnet --version 1.30.4
                    
NuGet\Install-Package libinput-dotnet -Version 1.30.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="libinput-dotnet" Version="1.30.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="libinput-dotnet" Version="1.30.4" />
                    
Directory.Packages.props
<PackageReference Include="libinput-dotnet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add libinput-dotnet --version 1.30.4
                    
#r "nuget: libinput-dotnet, 1.30.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package libinput-dotnet@1.30.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=libinput-dotnet&version=1.30.4
                    
Install as a Cake Addin
#tool nuget:?package=libinput-dotnet&version=1.30.4
                    
Install as a Cake Tool

libinput-dotnet

.NET bindings for libinput

Usage

using Libinput;
using Udev;

using var udev = new UdevContext();
using var context = LibinputContext.CreateUdevContext(udev);
context.AssignSeat("seat0");

while (true)
{
    context.Dispatch();
    foreach (var ev in context.Events())
    {
        using (ev)
        {
            switch (ev)
            {
                case LibinputKeyboardEvent key:
                    Console.WriteLine($"key {key.Key} {key.KeyState}");
                    break;
                case LibinputPointerMotionEvent motion:
                    Console.WriteLine($"motion {motion.Dx}/{motion.Dy}");
                    break;
            }
        }
    }

    context.Wait(); // poll(2) on context.Fd
}

Or manage devices explicitly with the path backend:

using var context = LibinputContext.CreatePathContext();
using var device = context.AddDevice("/dev/input/event3");
device.Config.Tap.Enabled = true;

The context is poll-style and never starts threads; integrate context.Fd into any event loop and call Dispatch when it is readable.

Permissions

libinput opens evdev nodes through an open/close callback pair so that access can be routed through a seat manager. By default the binding uses LibinputDirectInterface, which calls open(2) directly and requires permission on /dev/input/event* (root, the input group, or a udev rule). To integrate with systemd-logind or seatd instead, implement ILibinputInterface and pass it to the context factory.

Requirements

  • libinput.so.10 (libinput ≥ 1.21; the wrapper targets 1.30) installed via your distribution.
  • libudev.so.1 for the udev backend.

Building

dotnet build                       # solution: Libinput.NET.slnx
dotnet test                        # needs libinput.so.10; uinput for the integration tests
dotnet run --project samples/Libinput.NET.Sample            # watch seat0
dotnet run --project samples/Libinput.NET.Sample -- /dev/input/event3

The integration tests create virtual devices through /dev/uinput and inject real events; they skip when /dev/uinput or the created nodes are not accessible.

Regenerating the native bindings

src/Libinput.NET/Native/Generated/** is checked in, so consumers never need clang. To regenerate after bumping the external/libinput submodule:

git submodule update --init
dotnet tool restore
sh eng/generate.sh
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.30.4 511 7/28/2026