From fc0fc7fff5b10423e19c2101ce4e28ff293f11bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vuchener?= Date: Fri, 11 Dec 2015 15:05:25 +0100 Subject: [PATCH] Device list tool --- CMakeLists.txt | 1 + src/tools/CMakeLists.txt | 6 ++ src/tools/hidpp-list-devices.cpp | 124 +++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 src/tools/hidpp-list-devices.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 07eceee..fac041f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ endif() find_package(PkgConfig REQUIRED) pkg_check_modules(TINYXML2 tinyxml2) +pkg_check_modules(LIBUDEV libudev) add_subdirectory(src/libhidpp) add_subdirectory(src/tools) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 565e0ac..bb9d0a4 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -14,6 +14,12 @@ add_library(common OBJECT ${COMMON_SOURCES}) add_executable(hidpp-test hidpp-test.cpp $) target_link_libraries(hidpp-test hidpp) +if(LIBUDEV_FOUND) + add_executable(hidpp-list-devices hidpp-list-devices.cpp $) + target_include_directories(hidpp-list-devices PUBLIC ${LIBUDEV_INCLUDE_DIRECTORIES}) + target_link_libraries(hidpp-list-devices hidpp ${LIBUDEV_LIBRARIES}) +endif() + add_executable(hidpp-list-features hidpp-list-features.cpp $) target_link_libraries(hidpp-list-features hidpp) diff --git a/src/tools/hidpp-list-devices.cpp b/src/tools/hidpp-list-devices.cpp new file mode 100644 index 0000000..05a76b2 --- /dev/null +++ b/src/tools/hidpp-list-devices.cpp @@ -0,0 +1,124 @@ +/* + * Copyright 2015 Clément Vuchener + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +extern "C" { +#include +} + +#include +#include +#include +#include + +#include "common/common.h" +#include "common/Option.h" +#include "common/CommonOptions.h" + +int main (int argc, char *argv[]) +{ + std::vector