Last active
August 26, 2023 13:37
-
-
Save TinoDidriksen/732de7fc35be6e4a2e5f97da3a9bdb4f to your computer and use it in GitHub Desktop.
CMake find and use libevdev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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