Animeshz / keyboard-mouse-kt

A lightweight multiplatform library for interacting with global keyboard and mouse events and states from Kotlin, Java and NodeJS.
https://animeshz.github.io/keyboard-mouse-kt
MIT License
52 stars 2 forks source link

Migrate to dynamic library linking for linux, effectively supporting systems without X11. #1

Closed Animeshz closed 3 years ago

Animeshz commented 3 years ago

Currently using the XLib and XInput2 requires the overhead of installing the required lib to generate the headers which does not let non-linux host or one without these libs to build the project for those platform.

Second most important thing is that where there is non-X11 desktop environment the library won't work. Which limits it in the amount of targets.

Future plan is to migrate all the c-interop generated stubs into dlopen/dlsym/dlclose Posix API which allows to dynamically fetch the CPointer<CFunction<*>> and invoke it. Which can be done in the runtime (and has pretty less runtime overhead), we may even cache it at the first access.

This will let the library to be build without headers and in Windows/Mac for Linux as well and and can easily test it remotely on a VM. This will also enable to fallback to the Linux device API (/dev/uinput | /dev/input/xxx) if X11 is not present, which will allow the lib to support almost all the linux platforms (though this device API requires superuser).

Animeshz commented 3 years ago

Fixed with commit 92027738f2093b7cc71c4693bcbc565aec26d206 on the branch 0.1.x