Crafter.Graphics/lib/libevdev/README.md
Jorijn van der Graaf dfb70bc088
fix(gamepad): build libevdev from a vendored copy
The Linux gamepad backend included <libevdev/libevdev.h> from
/usr/include/libevdev-1.0 and linked the system libevdev, but the
Flatpak SDK crafter-build runs in (org.freedesktop.Sdk 26.08) ships no
libevdev headers, so Crafter.Graphics stopped building there.
lib/libevdev now carries libevdev 1.14.0 (MIT), built once as its own
static library that Crafter.Graphics depends on. As part of cfg it would
be compiled again in every test configuration, since they copy
cfg.cFiles.

libevdev's generated event-names.h names every input code by its macro,
so the library compiles against the kernel input headers that table was
generated from (lib/libevdev/kernel-headers), not the target's. That
directory is deliberately not called include: Crafter.Build puts every
include directory of a dependency on its consumers' include path, where
those headers would shadow each consumer's own <linux/input.h>. The
paths are absolute because Crafter.Build only resolves the returned
configuration's paths against the project root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 03:03:16 +02:00

1.8 KiB

libevdev (vendored)

The Linux gamepad backend (implementations/Crafter.Graphics-Gamepad.cpp) parses evdev events with libevdev. It is compiled into Crafter.Graphics from this directory instead of being linked from the system. The Flatpak SDK that crafter-build runs in has no libevdev headers, and a vendored copy builds the same way for every target, including cross sysroots.

  • Upstream: https://gitlab.freedesktop.org/libevdev/libevdev.git, tag libevdev-1.14.0 (commit d9af2e4580297e9c14715fef06621dd39d9d8a3a). MIT, see COPYING.
  • libevdev/: the core library sources, unchanged. The uinput half isn't used and isn't included.
  • libevdev/event-names.h: generated, the way libevdev's meson build does it, from the kernel headers below.
  • libevdev/config.h: what libevdev's meson build writes on Linux (_GNU_SOURCE).
  • kernel-headers/linux/: the kernel uapi input.h and input-event-codes.h that ship with that libevdev release. libevdev compiles against its own copy (its meson build puts them first on the path), because event-names.h names every code by its macro and has to see the same set of codes. Only the libevdev library sees them, and the directory isn't called include, because Crafter.Build puts every include directory of a dependency on its consumers' include path.

project.cpp builds these sources once, as their own static library, which Crafter.Graphics depends on.

Updating

Copy COPYING, the files under libevdev/ and upstream's include/linux/linux/{input.h,input-event-codes.h} (into kernel-headers/linux/) from the new release, keep config.h, then regenerate the name table:

python3 libevdev/make-event-names.py kernel-headers/linux/input.h kernel-headers/linux/input-event-codes.h \
    > libevdev/event-names.h