Skip to content

Instantly share code, notes, and snippets.

@TinoDidriksen
Last active August 26, 2023 13:37
Show Gist options
  • Save TinoDidriksen/732de7fc35be6e4a2e5f97da3a9bdb4f to your computer and use it in GitHub Desktop.
Save TinoDidriksen/732de7fc35be6e4a2e5f97da3a9bdb4f to your computer and use it in GitHub Desktop.
CMake find and use libevdev
project(example CXX)
find_package(PkgConfig REQUIRED)
pkg_search_module(LIBEVDEV REQUIRED libevdev)
add_executable(example example.cpp)
target_include_directories(example PRIVATE ${LIBEVDEV_INCLUDE_DIRS})
target_link_libraries(example PRIVATE ${LIBEVDEV_LIBRARIES})
#include <fcntl.h>
#include <libevdev/libevdev.h>
int main() {
struct libevdev *dev = nullptr;
int fd;
int rc = 1;
fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
rc = libevdev_new_from_fd(fd, &dev);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment