summaryrefslogtreecommitdiffhomepage
path: root/video-ps3eye
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-07-05 13:04:58 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-07-05 13:04:58 +0200
commit8fa10fda8186b6cdd10430e4d6cb4ef8db1ee9a0 (patch)
treea5ee2b1e1d54944492776329ba71800070c72135 /video-ps3eye
parent66c2373014fc107d918b8549d554420d63405cc7 (diff)
video/ps3eye: stub
Diffstat (limited to 'video-ps3eye')
-rw-r--r--video-ps3eye/CMakeLists.txt17
-rw-r--r--video-ps3eye/module.cpp50
-rw-r--r--video-ps3eye/module.hpp3
3 files changed, 70 insertions, 0 deletions
diff --git a/video-ps3eye/CMakeLists.txt b/video-ps3eye/CMakeLists.txt
index 5e45eb4a..6510d8c7 100644
--- a/video-ps3eye/CMakeLists.txt
+++ b/video-ps3eye/CMakeLists.txt
@@ -2,6 +2,23 @@ add_compile_definitions(PS3EYE_DEBUG)
add_subdirectory("ps3eye-driver")
+if(NOT MSVC)
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(libusb "libusb-1.0" QUIET)
+ endif()
+ if(libusb_FOUND)
+ include_directories(SYSTEM ${libusb_INCLUDE_DIRS})
+ link_libraries(${libusb_LIBRARIES})
+ endif()
+else()
+ set(SDK_LIBUSB CACHE PATH "")
+ if(SDK_LIBUSB)
+ set(libusb_FOUND TRUE)
+ link_directories("${SDK_LIBUSB}")
+ include_directories(SYSTEM "${SDK_LIBUSB}")
+ endif()
+endif()
+
if(TARGET ps3eye-driver)
otr_module(video-ps3eye)
if(WIN32)
diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp
index e69de29b..b04c6acb 100644
--- a/video-ps3eye/module.cpp
+++ b/video-ps3eye/module.cpp
@@ -0,0 +1,50 @@
+#include "module.hpp"
+
+#include <libusb.h>
+
+int device_count()
+{
+ libusb_context * ctx = nullptr;
+ libusb_device **list = nullptr;
+ ssize_t sz = 0;
+ int rc = 0, cnt = 0;
+
+ constexpr int vendor_id = 0x1415;
+ constexpr int product_id = 0x2000;
+
+ rc = libusb_init(&ctx);
+
+ if (rc)
+ goto end;
+
+ sz = libusb_get_device_list(ctx, &list);
+
+ if (sz < 0)
+ goto end;
+
+ for (int i = 0; i < sz; ++i) {
+ libusb_device *device = list[i];
+ libusb_device_descriptor desc = {};
+
+ if (libusb_get_device_descriptor(device, &desc))
+ goto end;
+
+ if (desc.idVendor == vendor_id && desc.idProduct == product_id)
+ cnt++;
+ }
+
+end:
+ if (list)
+ libusb_free_device_list(list, 1);
+ if (ctx)
+ libusb_exit(ctx);
+
+ return cnt;
+}
+
+bool check_device_exists()
+{
+ static bool ret = device_count() > 0;
+ return ret;
+}
+
diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp
index e69de29b..a9283d14 100644
--- a/video-ps3eye/module.hpp
+++ b/video-ps3eye/module.hpp
@@ -0,0 +1,3 @@
+#pragma once
+
+#include "video/camera.hpp"