A libinput-compatible library designed for Android/Termux environments. This library provides the same API as the official libinput library and integrates with termux-display-client to provide real Android input events to applications like KWin.
- API Compatible: Provides the same public API as libinput 1.28.0
- Android/Termux Ready: Works without Linux kernel dependencies
- Real Input Integration: Integrates with termux-display-client for actual input events
- Event Handling: Supports keyboard, pointer, touch, and gesture events
- Device Management: Virtual device creation and capability management
- Configuration Stubs: Provides all configuration APIs (returns sensible defaults)
- Meson Build System: Uses Meson like the official libinput
libinput/
├── src/
│ ├── libinput.c # Core context and event handling
│ ├── libinput.h # Public API header
│ ├── evdev.c # Event processing and creation
│ ├── evdev-mt-touchpad.c # Device management and mock udev
│ └── [stub files] # Placeholder implementations
├── meson.build # Root Meson configuration (official style)
├── libinput.pc.in # pkg-config template
└── README.md # This file
Note: termux-display-client library must be installed first.
# Build libinput
meson setup builddir
meson compile -C builddir
meson install -C builddirIf termux-display-client is not found, the build will fail with a clear error message.
- Meson 0.64+
- C compiler with C99 support
- pthread library
- math library (libm)
- termux-display-client library (required - provides Android input integration)
The library will be installed as:
- Library:
/usr/local/lib/libinput.so(orlibinput.so.10) - Headers:
/usr/local/include/libinput/libinput.h - pkg-config:
/usr/local/lib/pkgconfig/libinput.pc
This library can be used as a drop-in replacement for libinput in applications like KWin:
# Check if properly installed
pkg-config --cflags --libs libinput
# Use in your meson.build
dependency('libinput')#include <libinput.h>
#include <render.h> // from termux-display-client
#include <sys/epoll.h>
// KWin gets the termux-display-client event fd
int termux_fd = get_conn_fd();
// Initialize libinput with the termux fd
struct libinput *li = libinput_termux_create_context(&interface, userdata, termux_fd);
// Get the same fd for monitoring (libinput_get_fd returns the termux_fd)
int libinput_fd = libinput_get_fd(li);
assert(libinput_fd == termux_fd);
// Add to epoll
struct epoll_event ev = {
.events = EPOLLIN,
.data.fd = libinput_fd
};
epoll_ctl(epoll_fd, EPOLL_CTL_ADD, libinput_fd, &ev);
// In event loop
if (events[i].data.fd == libinput_fd) {
libinput_dispatch(li); // Read from termux fd and convert events
while ((event = libinput_get_event(li)) != NULL) {
// Process converted libinput event
libinput_event_destroy(event);
}
}- Context Management:
libinput_udev_create_context(),libinput_path_create_context() - Event Handling:
libinput_dispatch(),libinput_get_event(),libinput_next_event_type() - Event Types: All event creation and getter functions for keyboard, pointer, touch, gesture events
- Device Management: Device creation, capability queries, reference counting
- Configuration: All configuration APIs (return sensible defaults)
- termux-display-client Bridge: Connects to termux-display-client for real input events
- Android Keycode Mapping: Uses termux-display-client's Android-to-Linux keycode mapping
- Synchronous Event Processing: Reads events on-demand when KWin calls libinput_dispatch()
- Event Translation: Converts Android touch/mouse/keyboard events to libinput format
- External FD Management: KWin manages termux-display-client connection and passes fd to libinput
- Standard libinput API: Follows official libinput patterns for KWin integration
- Zero-copy FD sharing: libinput_get_fd() returns the same fd KWin got from termux-display-client
- Device Discovery: Creates virtual devices with standard capabilities
This implementation mimics the official libinput structure:
- Uses the same soversion (10) and library name (
libinput.so) - Provides identical API surface
- Compatible with existing build systems expecting libinput
- Uses Meson build system like the official libinput
This library allows KWin to compile and run on Android/Termux by providing the required libinput dependency. It integrates directly with termux-display-client to provide real Android input events to KWin.
- First build and install
termux-display-client - Then build and install this
libinputimplementation - Finally build KWin with this libinput implementation
MIT License - Compatible with the original libinput license.