-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdumpHID.cpp
More file actions
58 lines (46 loc) · 1 KB
/
Copy pathdumpHID.cpp
File metadata and controls
58 lines (46 loc) · 1 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
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <iostream>
#include <hidapi/hidapi.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <hidapi/hidapi.h>
int main (int argc, char* argv[])
{
hid_device *handle;
unsigned char buf[50];
int res;
if(argc != 2)
{
std::cout << "Invalid parameters passed in. Please pass in the path to the HID device." << std::endl;
return -1;
}
handle = hid_open_path(argv[1]);
while(1)
{
res = hid_read_timeout(handle, buf, sizeof(buf),3000);
if(res > 0)
{
std::cout << "REPORT\n\tID: " << std::hex << (int)buf[0] << "\n\tData: ";
for(int i = 1; i < res; i++)
{
std::cout << std::hex << (int)buf[i] << " ";
}
std::cout << std::endl;
}
else
{
std::cout << "Read Timeout...\n";
}
}
}