-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.h
More file actions
106 lines (90 loc) · 3.02 KB
/
mainwindow.h
File metadata and controls
106 lines (90 loc) · 3.02 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <vector>
#include <string>
#include <map>
#include "hidapi/hidapi.h"
// Прямые объявления классов Qt для уменьшения времени компиляции
class QLabel;
class QPushButton;
class QComboBox;
class QCheckBox;
class QSlider;
class QSpinBox;
class QGroupBox;
class MainWindow : public QWidget
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void writeToDevice();
void restoreDefaults();
void selectLedColor();
void updateColorPickersVisibility(int index);
void selectLedPaletteColor(int colorIndex);
private:
// UI
void setupUI();
QWidget* ActionsTab();
QWidget* PerformanceTab();
QWidget* LedTab();
QWidget* DpiEditorTab();
QLabel* statusLabel;
// advanced
QComboBox* pollRateCombo;
QComboBox* debounceCombo;
QCheckBox* angleSnapCheck;
QCheckBox* rippleControlCheck;
QSpinBox* activeDpiSpinBox;
// LED
QComboBox* ledModeCombo;
QSlider* ledSpeedSlider;
QSlider* ledBrightnessSlider;
QPushButton* ledColorButton;
QLabel* ledColorSwatch;
QGroupBox* ledColorGroup; // Группа, объединяющая все селекторы цвета
std::vector<QPushButton*> ledColorButtons; // 7 кнопок "Select..."
std::vector<QLabel*> ledColorSwatches; // 7 "образцов" цвета
// DPI editor
std::vector<QCheckBox*> dpiEnableChecks;
std::vector<QSlider*> dpiValueSliders;
std::vector<QSpinBox*> dpiValueSpinBoxes;
void initializeMaps();
void updateUiFromPayload(const std::vector<uint8_t>& payload);
void updatePayloadFromUi();
hid_device* findAndOpenDevice();
bool sendHidReport(const std::vector<uint8_t>& payload);
std::vector<uint8_t> readHidReport();
std::vector<uint8_t> factorySettingsPayload();
std::vector<uint8_t> currentPayloadState;
std::string workingDevicePath;
// conversion maps
std::map<std::string, int> ledModeIDs;
std::map<int, uint8_t> ledModeSpeedMap;
std::map<int, int> ledModeColorCount;
std::map<int, int> pollingRateMapToHz;
std::map<int, int> pollingRateHzToIndex;
std::map<int, int> debounceMsToIndex;
std::map<int, int> debounceIndexToMs;
// device data
static const unsigned short VID = 0x2EA8;
static const unsigned short PID = 0x2203;
static const uint8_t ReportID = 0x04;
static const size_t WritePayloadLength = 63;
static const size_t ReportBufferLength = WritePayloadLength + 1;
// offsets
static const size_t ActiveDPIIndex = 3;
static const size_t PollingRate = 6;
static const size_t DPIEnableMask = 7;
static const size_t DPIValuesStart = 8;
static const size_t SensorPerf = 34;
static const size_t LEDModeID = 36;
static const size_t LEDSpeed = 37;
static const size_t LEDBrightness = 38;
static const size_t LEDPaletteFlag = 40;
static const size_t DPIColorsStart = 41;
};
#endif // MAINWINDOW_H