From 8fa10fda8186b6cdd10430e4d6cb4ef8db1ee9a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 5 Jul 2019 13:04:58 +0200 Subject: video/ps3eye: stub --- video-ps3eye/module.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'video-ps3eye/module.cpp') 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 + +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; +} + -- cgit v1.2.3