blob: ac6d8807acbb09b72654392526aba9473b07540c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#include "module.hpp"
#if 0
#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;
}
static const QString camera_name = QStringLiteral("PS3 Eye open driver");
namespace video::impl {
std::vector<QString> ps3eye_camera_::camera_names() const
{
if (check_device_exists())
return { camera_name };
else
return {};
}
std::unique_ptr<camera> ps3eye_camera_::make_camera(const QString& name)
{
if (name == camera_name && check_device_exists())
return std::make_unique<ps3eye_camera>();
else
return {};
}
bool ps3eye_camera_::show_dialog(const QString& camera_name)
{
// TODO
return false;
}
bool ps3eye_camera_::can_show_dialog(const QString& camera_name)
{
return false;
}
} // ns video::impl
#endif
|