hid_listener 2.0.0 copy "hid_listener: ^2.0.0" to clipboard
hid_listener: ^2.0.0 copied to clipboard

A hid listening library for cross platform listening to keyboard/mouse events.

hid_listener #

HidListener is a library that allows you to listen to hid events cross-platform.

Windows #

Add this into your main.cpp file

#include <hid_listener/hid_listener_plugin_windows.h>

and add this inside wWinMain funciton

HidListener listener;

MacOS #

Add this into your MainFlutterWindow.swift file

import hid_listener

and add this inside MainFlutterWindow class

let listener = HidListener()

The file should now look something like this:

...
import hid_listener

class MainFlutterWindow: NSWindow {
  let listener = HidListener()
...

Linux #

Add this into your main.cc file

#include <hid_listener/hid_listener_plugin.h>

and add this inside main funciton

HidListener listener;

Dart #

To use the library, you first have to initialize the listener backend:

if (getListenerBackend() != null) {
  if (!getListenerBackend().initialize()) {
    print("Failed to initialize listener backend");
  }
} else {
  print("No listener backend for this platform")
}

After successfully initializing the listener backend, register listeners like this:

final keyboardListenerId = getListenerBackend()!.addKeyboardListener((event) {
  print("${event.logicalKey.debugName}")
});

getListenerBackend()!.addMouseListener((event) { ... })

Removing listeners can be done using remove(keyboard/Mouse)Listener method call:

getListenerBackend()!.removeKeyboardListener(keyboardListenerId);
12
likes
140
points
227
downloads

Publisher

unverified uploader

Weekly Downloads

A hid listening library for cross platform listening to keyboard/mouse events.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, plugin_platform_interface

More

Packages that depend on hid_listener