-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcuedevice.h
144 lines (131 loc) · 3.77 KB
/
cuedevice.h
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef CUEDEVICE_H
#define CUEDEVICE_H
#include <cereal/types/polymorphic.hpp>
#include <cereal/archives/xml.hpp>
#include <QString>
class CUEDeviceVidPid
{
public:
CUEDeviceVidPid()
{
#ifdef DEBUG_DEFAULT_INIT
std::cout << "Created CUEDeviceVidPid" << std::endl;
#endif
}
// Negative Vids/Pids are used
int32_t usbVid;
int32_t usbPid;
template <class Archive>
void serialize(Archive& ar, const std::uint32_t version)
{
ar(CEREAL_NVP(usbVid), CEREAL_NVP(usbPid));
}
};
CEREAL_CLASS_VERSION(CUEDeviceVidPid, 200)
class CUEDevice
{
public:
CUEDevice()
{
#ifdef DEBUG_DEFAULT_INIT
std::cout << "Created CUEDevice" << std::endl;
#endif
}
QString deviceId;
CUEDeviceVidPid modelId;
QString hidCaps;
QString deviceLightingType;
template <class Archive>
void serialize(Archive& ar, const std::uint32_t version)
{
ar(CEREAL_NVP(deviceId), CEREAL_NVP(modelId), CEREAL_NVP(hidCaps), CEREAL_NVP(deviceLightingType));
}
};
CEREAL_CLASS_VERSION(CUEDevice, 303)
class CUEDeviceComparator
{
public:
bool operator()(const CUEDevice& d1, const CUEDevice& d2)
{
return (d1.deviceId == d2.deviceId) | (d1.modelId.usbPid + d1.modelId.usbVid > d2.modelId.usbPid + d2.modelId.usbVid)
| (d1.hidCaps == d2.hidCaps) | (d1.deviceLightingType == d2.deviceLightingType);
}
};
class CUEDeviceNoCaps
{
public:
CUEDeviceNoCaps()
{
#ifdef DEBUG_DEFAULT_INIT
std::cout << "Created CUEDeviceNoCaps" << std::endl;
#endif
}
QString capability;
QString deviceId;
CUEDeviceVidPid modelId;
template <class Archive>
void serialize(Archive& ar, const std::uint32_t version)
{
ar(CEREAL_NVP(capability), CEREAL_NVP(deviceId), CEREAL_NVP(modelId));
}
};
CEREAL_CLASS_VERSION(CUEDeviceNoCaps, 301)
static std::map<QString, int> devCmpMapDefault = {
{"StandardRgb", 0},
{"StandardSingleColor", 1},
{"ZoneRgb", 2},
{"RestrictedWireless", 3},
{"DramSingleColor", 4},
{"Undefined", 5},
{"DramRgb", 6},
};
class CUEDeviceNoCapsComparator
{
public:
bool operator()(const CUEDeviceNoCaps& d1, const CUEDeviceNoCaps& d2)
{
std::map<QString, int>& cmpmap = *(devCmpMap ? devCmpMap : &devCmpMapDefault);
// In case we don't have the value in the list
if((cmpmap.count(d1.capability) && cmpmap.count(d2.capability)))
return cmpmap[d1.capability] < cmpmap[d2.capability];
return (d1.deviceId == d2.deviceId) | (d1.capability < d2.capability)
| (d1.modelId.usbPid + d1.modelId.usbVid > d2.modelId.usbPid + d2.modelId.usbVid);
}
};
// FIXME: Not a great name
class CUEDeviceNoCapsNoCap
{
public:
CUEDeviceNoCapsNoCap()
{
#ifdef DEBUG_DEFAULT_INIT
std::cout << "Created CUEDeviceNoCapsNoCap" << std::endl;
#endif
}
QString deviceId;
CUEDeviceVidPid vidPid;
template <class Archive>
void serialize(Archive& ar, const std::uint32_t version)
{
ar(CEREAL_NVP(deviceId), CEREAL_NVP(vidPid));
}
};
CEREAL_CLASS_VERSION(CUEDeviceNoCapsNoCap, 300)
static std::map<QString, int> coolingCmpMapDefault = {
{"DEMO_COMMANDER_PRO_DEVICE", 0},
{"DEMO_PSU_DEVICE", 1},
{"DEMO_LIQUID_COOLER_DEVICE", 2},
};
class CUEDeviceNoCapsNoCapComparator
{
public:
bool operator()(const CUEDeviceNoCapsNoCap& d1, const CUEDeviceNoCapsNoCap& d2)
{
std::map<QString, int>& cmpmap = *(coolingCmpMap ? coolingCmpMap : &coolingCmpMapDefault);
// In case we don't have the value in the list
if((cmpmap.count(d1.deviceId) && cmpmap.count(d2.deviceId)))
return cmpmap[d1.deviceId] < cmpmap[d2.deviceId];
return (d1.vidPid.usbPid + d1.vidPid.usbVid > d2.vidPid.usbPid + d2.vidPid.usbVid);
}
};
#endif // CUEDEVICE_H