RawInput.Sharp 0.2.0

dotnet add package RawInput.Sharp --version 0.2.0
                    
NuGet\Install-Package RawInput.Sharp -Version 0.2.0
                    
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="RawInput.Sharp" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RawInput.Sharp" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="RawInput.Sharp" />
                    
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 RawInput.Sharp --version 0.2.0
                    
#r "nuget: RawInput.Sharp, 0.2.0"
                    
#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 RawInput.Sharp@0.2.0
                    
#: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=RawInput.Sharp&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=RawInput.Sharp&version=0.2.0
                    
Install as a Cake Tool

RawInput.Sharp

A simple wrapper library for Windows Raw Input.

Target frameworks

Starting with version 0.2.0, the library targets .NET 8 (net8.0). The sample applications target .NET 8 for Windows (net8.0-windows).

If you need .NET Standard 1.1 or .NET Framework support, use the 0.1.3 compatibility release.

NuGet

https://www.nuget.org/packages/RawInput.Sharp/

Version 0.2.0 targets .NET 8.0 and later. If you need a build for .NET Standard 2.0, netstandard1.1, or an older .NET Framework target, use version 0.1.3.

Usage

Acquiring connected devices

// using Linearstar.Windows.RawInput;

// Get the devices that can be handled with Raw Input.
var devices = RawInputDevice.GetDevices();

// Keyboards will be returned as RawInputKeyboard.
var keyboards = devices.OfType<RawInputKeyboard>();

// Mice will be RawInputMouse.
var mice = devices.OfType<RawInputMouse>();

Reading raw inputs

protected override void WndProc(ref Message m)
{
    const int WM_INPUT = 0x00FF;

    // You can read inputs by processing the WM_INPUT message.
    if (m.Msg == WM_INPUT)
    {
        // Create an RawInputData from the handle stored in lParam.
        var data = RawInputData.FromHandle(m.LParam);

        // You can identify the source device using Header.DeviceHandle or just Device.
        var sourceDeviceHandle = data.Header.DeviceHandle;
        var sourceDevice = data.Device;

        // The data will be an instance of either RawInputMouseData, RawInputKeyboardData, or RawInputHidData.
        // They contain the raw input data in their properties.
        switch (data)
        {
            case RawInputMouseData mouse:
                Console.WriteLine(mouse.Mouse);
                break;
            case RawInputKeyboardData keyboard:
                Console.WriteLine(keyboard.Keyboard);
                break;
            case RawInputHidData hid:
                Console.WriteLine(hid.Hid);
                break;
        }
    }

    base.WndProc(ref m);
}

Further examples

License

zlib License

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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RawInput.Sharp:

Package Downloads
Qian.BarcodeScanner.WPF

Package Description

GitHub repositories (12)

Showing the top 12 popular GitHub repositories that depend on RawInput.Sharp:

Repository Stars
lively-community/lively
Free and open-source software that allows users to set animated desktop wallpapers and screensavers powered by WinUI 3.
ClassIsland/ClassIsland
一款功能强、可定制、跨平台,适用于班级多媒体屏幕的课表信息显示工具,可以一目了然地显示各种信息。
Maassoft/ColorControl
Easily change NVIDIA display settings and/or control LG TV's
Taiizor/Sucrose
Sucrose is a versatile wallpaper engine that brings life to your desktop with a wide range of interactive wallpapers.
Artemis-RGB/Artemis
Provides advanced unified lighting across many different brands RGB peripherals
Meowmaritus/DSAnimStudio
Direct3D-Accelerated Dark Souls TAE Editor
LanZhan-Harmony/WindowsMusicPlayer-TheUntamedMusicPlayer
WinUI开发的现代化Windows在线和本地音乐播放器
Yoooi0/MultiFunPlayer
flexible application to synchronize various devices with media playback
project-sbc/Handheld-Control-Panel
Gainedge/BetterExplorer
A Better Explorer is a filemanager replacement that adds several handy features for productive file management.
lindexi/lindexi_gd
博客用到的代码
BetterWorld-Liuser/XiaoChao
Windows端的快捷键提示工具
Version Downloads Last Updated
0.2.0 738 7/31/2026
0.1.3 45,993 11/3/2023
0.1.2 403 11/3/2023
0.1.1 7,626 3/21/2023
0.1.0 464 3/21/2023
0.0.4 149,520 5/1/2021
0.0.3 9,520 12/7/2019
0.0.2 1,250 5/7/2019
0.0.1 822 5/7/2019
0.0.0 927 5/5/2019

See the GitHub release notes for this version.