* Get bytes from a HID Report Descriptor. * Only call with a num_bytes of 0, 1, 2, or 4. */
| 249 | * Only call with a num_bytes of 0, 1, 2, or 4. |
| 250 | */ |
| 251 | static __u32 get_hid_report_bytes(__u8 *rpt, size_t len, size_t num_bytes, size_t cur) |
| 252 | { |
| 253 | /* Return if there aren't enough bytes. */ |
| 254 | if (cur + num_bytes >= len) |
| 255 | return 0; |
| 256 | |
| 257 | if (num_bytes == 0) |
| 258 | return 0; |
| 259 | else if (num_bytes == 1) |
| 260 | return rpt[cur + 1]; |
| 261 | else if (num_bytes == 2) |
| 262 | return (rpt[cur + 2] * 256 + rpt[cur + 1]); |
| 263 | else if (num_bytes == 4) |
| 264 | return ( |
| 265 | rpt[cur + 4] * 0x01000000 + |
| 266 | rpt[cur + 3] * 0x00010000 + |
| 267 | rpt[cur + 2] * 0x00000100 + |
| 268 | rpt[cur + 1] * 0x00000001 |
| 269 | ); |
| 270 | else |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | /* |
| 275 | * Retrieves the device's Usage Page and Usage from the report descriptor. |
no outgoing calls
no test coverage detected