-
Notifications
You must be signed in to change notification settings - Fork 2
/
BladeStructs.h
149 lines (131 loc) · 3.11 KB
/
BladeStructs.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
145
146
147
148
149
//
// Created by alex on 08/01/2022.
//
#ifndef LIBRAZERBLADE_BLADESTRUCTS_H
#define LIBRAZERBLADE_BLADESTRUCTS_H
#include "Core.h"
#include "BladeDeviceId.h"
#define RAZER_USB_REPORT_LEN 90
#define DEFAULT_TIMEOUT 5000
enum BladeQuery
{
QueryNone = 0,
QueryFanSpeed = 0b00000001,
QueryPowerMode = 0b00000010,
QueryBrightness = 0b00000100,
QueryBoost = 0b00001000,
QueryAll = 0x7FFFFFFF,
QueryCount = 4,
};
enum BladeQueryRows
{
QueryRow0 = 0b00000001,
QueryRow1 = 0b00000010,
QueryRow2 = 0b00000100,
QueryRow3 = 0b00001000,
QueryRow4 = 0b00010000,
QueryRow5 = 0b00100000,
QueryRowCount = 6,
};
enum BladeResponse
{
RazerResponseNone = 0x00,
RazerResponseBusy = 0x01,
RazerResponseSuccess = 0x02,
RazerResponseFailure = 0x03,
RazerResponseTimeout = 0x04,
RazerResponseNotSupported = 0x05,
RazerResponseDoesntMatch = 0xFF
};
enum BladePacketDirection
{
Set = 0x00,
Get = 0x01,
HostToDevice = Set,
DeviceToHost = Get
};
enum BladeBoostId
{
BoostCpu = 0x01,
BoostGpu = 0x02
};
enum BladePacketType
{
PktFan = 0x01,
PktPower = 0x02,
PktBoostMode = 0x07,
PktGetBrightness = 0x03,
PktSetBrightness = 0x04,
PktChromaApply = 0x0a,
PktChromaSetRow = 0x0b,
};
typedef struct UsbHandle_s
{
int32_t autoRelease;
void* handle;
} UsbHandle;
typedef struct UserData_s
{
void* ptr;
int32_t length;
int32_t autoFree;
} UserData;
typedef struct KeyboardRow_s
{
uint8_t rowid; // Row ID (0-5) used by the EC to update each row
RGB24 keys[15]; // 15 keys per row (regardless if the LEDs are present or not)
} KeyboardRow;
// Keyboard structs
typedef struct KeyboardInfo_s
{
uint8_t brightness; // 0-255 brightness
KeyboardRow rows[6]; // 6 rows
} KeyboardInfo;
typedef union TransactionId_s
{
uint8_t id;
struct transaction_parts
{
uint8_t device: 3;
uint8_t id: 5;
} parts;
} TransactionId;
typedef union CommandId_s
{
uint8_t id;
struct command_id_parts
{
uint8_t id: 7;
uint8_t direction: 1;
} parts;
} CommandId;
/* Status:
* 0x00 New Command
* 0x01 Command Busy
* 0x02 Command Successful
* 0x03 Command Failure
* 0x04 Command No Response / Command Timeout
* 0x05 Command Not Support
*
* Transaction ID used to group request-response, device useful when multiple devices are on one usb
* Remaining Packets is the number of remaining packets in the sequence
* Protocol Type is always 0x00
* Data Size is the size of payload, cannot be greater than 80. 90 = header (8B) + data + CRC (1B) + Reserved (1B)
* Command Class is the type of command being issued
* Command ID is the type of command being send. Direction 0 is Host->Device, Direction 1 is Device->Host. AKA Get LED 0x80, Set LED 0x00
*
* */
typedef struct RazerPacket_s
{
uint8_t status;
TransactionId transaction_id;
uint16_t remaining_packets;
uint8_t protocol_type; // 0x00
uint8_t data_size;
uint8_t command_class;
CommandId command_id;
uint8_t args[80];
uint8_t crc;
uint8_t reserved; // 0x00
} RazerPacket;
#endif //LIBRAZERBLADE_BLADESTRUCTS_H