forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbulkcontroller.h
More file actions
88 lines (66 loc) · 2.09 KB
/
Copy pathbulkcontroller.h
File metadata and controls
88 lines (66 loc) · 2.09 KB
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
82
83
84
85
86
87
88
#pragma once
#include <QAtomicInt>
#include <QThread>
#include <optional>
#include "controllers/controller.h"
#include "controllers/hid/legacyhidcontrollermapping.h"
struct libusb_device_handle;
struct libusb_context;
/// USB Bulk controller backend
class BulkReader : public QThread {
Q_OBJECT
public:
BulkReader(libusb_device_handle *handle, unsigned char in_epaddr);
virtual ~BulkReader();
void stop();
signals:
void incomingData(const QByteArray& data, mixxx::Duration timestamp);
protected:
void run();
private:
libusb_device_handle* m_phandle;
QAtomicInt m_stop;
unsigned char m_in_epaddr;
};
class BulkController : public Controller {
Q_OBJECT
public:
BulkController(
libusb_context* context,
libusb_device_handle* handle,
struct libusb_device_descriptor* desc);
~BulkController() override;
QString mappingExtension() override;
virtual std::shared_ptr<LegacyControllerMapping> cloneMapping() override;
void setMapping(std::shared_ptr<LegacyControllerMapping> pMapping) override;
bool isMappable() const override {
if (!m_pMapping) {
return false;
}
return m_pMapping->isMappable();
}
bool matchMapping(const MappingInfo& mapping) override;
protected:
void send(const QList<int>& data, unsigned int length) override;
private slots:
int open() override;
int close() override;
private:
// For devices which only support a single report, reportID must be set to
// 0x0.
bool sendBytes(const QByteArray& data) override;
bool matchProductInfo(const ProductInfo& product);
libusb_context* m_context;
libusb_device_handle *m_phandle;
// Local copies of things we need from desc
std::uint16_t m_vendorId;
std::uint16_t m_productId;
std::uint8_t m_inEndpointAddr;
std::uint8_t m_outEndpointAddr;
std::optional<std::uint8_t> m_interfaceNumber;
QString m_manufacturer;
QString m_product;
QString m_sUID;
BulkReader* m_pReader;
std::shared_ptr<LegacyHidControllerMapping> m_pMapping;
};