Nfw.Linux.Hid
1.0.1
See the version list below for details.
dotnet add package Nfw.Linux.Hid --version 1.0.1
NuGet\Install-Package Nfw.Linux.Hid -Version 1.0.1
<PackageReference Include="Nfw.Linux.Hid" Version="1.0.1" />
paket add Nfw.Linux.Hid --version 1.0.1
#r "nuget: Nfw.Linux.Hid, 1.0.1"
// Install Nfw.Linux.Hid as a Cake Addin #addin nuget:?package=Nfw.Linux.Hid&version=1.0.1 // Install Nfw.Linux.Hid as a Cake Tool #tool nuget:?package=Nfw.Linux.Hid&version=1.0.1
Nfw.Linux.Hid
A convenient library for outputting Keyboard and Mouse events via a Linux USB Gadget + OTG + /dev/hidX device.
Keyboard
using Nfw.Linux.Hid.Keyboard;
SimpleKeyboard keyboard = new SimpleKeyboard();
keyboard.EmitString("test");
You can also use methdos to toggle keys (i.e. 'hold down SHIFT'), send specific keys etc. SendKey
or the Events which can be sent via EmitEvent.
Mouse
using Nfw.Linux.Hid.Mouse;
SimpleMouse mouse = new SimpleMouse();
// Start at center
mouse.Center();
// Move diagonally from top left, to bottom right
for(int x = 0; x < SimpleMouse.MAX_X; x++) {
mouse.MoveTo(x,x);
Thread.Sleep(1);
}
Note additional methods for clicking, toggling (press-and-hold), etc are also available.
References
- https://www.rmedgar.com/blog/using-rpi-zero-as-keyboard-setup-and-device-definition/
- https://www.elinux.org/images/e/ef/USB_Gadget_Configfs_API_0.pdf
- https://www.usb.org/sites/default/files/documents/hid1_11.pdf
- http://www.linux-usb.org/usb.ids
- https://github.com/tiny-pilot/tinypilot/blob/master/app/main.py
Attribution
- Keyboard icons created by Freepik - Flaticon
- Much inspiration, and OTG/HID setup code, from the TinyPilot project
Creating the HID devices
Creating the HID devices via USB Gadget is a bit out of scope for this library, but for reference, the method used by the author is included in the repo here. Only tested on rasbian-lite 32bit on a R-Pi4. Requires the dwc2 OTG driver/overlay:
echo "dtoverlay=dwc2" >> /boot/config.txt
echo "dwc2" >> /etc/modules
Then reboot, and run:
sudo ./init-usb-gadget.sh
sudo ./install-usb-gadget.sh
You should end up with /dev/hidg0 and /dev/hidg1 accordingly.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- Microsoft.Extensions.Logging (>= 6.0.0)
- morelinq (>= 3.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.