-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusb_routine.cpp
43 lines (40 loc) · 922 Bytes
/
usb_routine.cpp
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
#include "usbhid.h"
DWORD WINAPI ReadReport(void*) {
while (TRUE)
{
if (!WRITE_ROPRT)
{
if (HidDeviceObject != INVALID_HANDLE_VALUE)
{
CancelIo(HidDeviceObject);
int Result = ReadFile(HidDeviceObject,&InputReport,Capabilities.InputReportByteLength,
&NumberOfBytesRead,(LPOVERLAPPED)&HIDOverlapped);
}
}
Sleep(25);
}
}
DWORD WINAPI WriteReport(void*) {
BOOL Result = TRUE;
int n;
while (TRUE)
{
if (WRITE_ROPRT)
{
if (HidDeviceObject != INVALID_HANDLE_VALUE)
{
CancelIo(HidDeviceObject);
if (Use_Setxxx == 1){
Result = HidD_SetFeature(HidDeviceObject,OutputReport,Capabilities.FeatureReportByteLength);
}
else{
Result = WriteFile(HidDeviceObject,&OutputReport,Capabilities.OutputReportByteLength,
&NumberOfBytesWriten,(LPOVERLAPPED)&HIDOverlapped);
}
WRITE_ROPRT = FALSE;
memset(&OutputReport, 0, 256);
}
}
Sleep(25);
}
}