libx52/vkm
nirenjan 3c02fe5ec2 refactor: Rearrange files to avoid duplicate code issue
Prior to this change, SonarQube complains about duplicated code in the
symlinked header files. This change reworks the layout so that the
installed headers all reside under the 'includes' directory, and the
meson.build files are updated to reflect the new paths.
2026-04-20 10:28:24 -07:00
..
README.md feat: Add virtual keyboard/mouse library support 2026-03-30 10:01:50 -07:00
common.c refactor: Remove vkm_ prefix from VKM source files 2026-04-03 23:54:58 -07:00
linux_evdev.c refactor: Remove vkm_ prefix from VKM source files 2026-04-03 23:54:58 -07:00
linux_evdev_test.c refactor: Remove vkm_ prefix from VKM source files 2026-04-03 23:54:58 -07:00
meson.build refactor: Rearrange files to avoid duplicate code issue 2026-04-20 10:28:24 -07:00
stub.c refactor: Remove vkm_ prefix from VKM source files 2026-04-03 23:54:58 -07:00
test_strerror.c build: Migrate includes to use libx52/ prefix 2026-04-03 22:54:48 -07:00
vkm-internal.h build: Migrate includes to use libx52/ prefix 2026-04-03 22:54:48 -07:00

README.md

Virtual keyboard/mouse infrastructure

The virtual keyboard/mouse infrastructure (or VKM), is an API used by an application to inject keyboard and mouse events into the OS stack. The advantage of using a separate API for this is so that this can be handled in a cross-platform manner without having to sprinkle #ifdef's throughout the program.

Base API

The API is based around a context, which is an opaque pointer returned by vkm_init. All subsequent VKM calls will take in this pointer as the first argument, and return a signed 32-bit status code. Once done, vkm_exit will clean up any data structures and close any file descriptors that were opened as part of the VKM calls.

VKM can also be configured through the vkm_config API call.

Device handling

vkm_new_device is the API to use when creating a new VKM device. While VKM will support both keyboard and mouse events from a single device, there may be cases where the application needs to separate out keyboard and mouse events into different devices. The flags will enable keyboard and/or mouse support.

Note that the supported event codes (on Linux) are fixed, and cannot be updated. The keyboard will emulate a standard US keyboard, while the mouse will emulate a standard 3 button mouse with a scroll wheel.

Mouse handling

The mouse is handled as a single API call that passes in dx and dy to move the mouse in the relative X and Y axes. VKM will take care of internally translating the calls to the appropriate framework. This is handled in vkm_mouse_move

The scroll wheel is handled through vkm_mouse_scroll. By default, the mouse motion uses standard scrolling, but high resolution scrolling may be enabled.

The buttons are handled by vkm_mouse_click. The API will send the state, depending on the input (pressed or not)

Keyboard handling

The keyboard is handled through a single call vkm_keyboard_send. This sends a single key event, with modifiers enabled (Ctrl, Shift, Alt, GUI).