MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / get_bytes

Function get_bytes

dependencies/hidapi/hidapi.c:162–184  ·  view source on GitHub ↗

Get bytes from a HID Report Descriptor. Only call with a num_bytes of 0, 1, 2, or 4. */

Source from the content-addressed store, hash-verified

160/* Get bytes from a HID Report Descriptor.
161 Only call with a num_bytes of 0, 1, 2, or 4. */
162static uint32_t get_bytes(uint8_t *rpt, size_t len, size_t num_bytes, size_t cur)
163{
164 /* Return if there aren't enough bytes. */
165 if (cur + num_bytes >= len)
166 return 0;
167
168 if (num_bytes == 0)
169 return 0;
170 else if (num_bytes == 1) {
171 return rpt[cur+1];
172 }
173 else if (num_bytes == 2) {
174 return (rpt[cur+2] * 256 + rpt[cur+1]);
175 }
176 else if (num_bytes == 4) {
177 return (rpt[cur+4] * 0x01000000 +
178 rpt[cur+3] * 0x00010000 +
179 rpt[cur+2] * 0x00000100 +
180 rpt[cur+1] * 0x00000001);
181 }
182 else
183 return 0;
184}
185
186/* Retrieves the device's Usage Page and Usage from the report
187 descriptor. The algorithm is simple, as it just returns the first

Callers 1

get_usageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected