ReactOS 0.4.15-dev-8413-gc1c91f2
device.c File Reference
#include <stdio.h>
#include "ntstatus.h"
#include "windows.h"
#include "setupapi.h"
#include "hidusage.h"
#include "ddk/hidsdi.h"
#include "wine/test.h"
Include dependency graph for device.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define READ_MAX_TIME   5000
 

Typedefs

typedef void() device_test(HANDLE device)
 

Functions

static void test_device_info (HANDLE device)
 
static void run_for_each_device (device_test *test)
 
static HANDLE get_device (USHORT page, USHORT usages[], UINT usage_count, DWORD access)
 
static void process_data (HIDP_CAPS Caps, PHIDP_PREPARSED_DATA ppd, CHAR *data, DWORD data_length)
 
static void test_read_device (void)
 
static void test_get_input_report (void)
 
 START_TEST (device)
 

Macro Definition Documentation

◆ READ_MAX_TIME

#define READ_MAX_TIME   5000

Definition at line 29 of file device.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 21 of file device.c.

Typedef Documentation

◆ device_test

typedef void() device_test(HANDLE device)

Definition at line 31 of file device.c.

Function Documentation

◆ get_device()

static HANDLE get_device ( USHORT  page,
USHORT  usages[],
UINT  usage_count,
DWORD  access 
)
static

Definition at line 106 of file device.c.

107{
108 GUID hid_guid;
109 HDEVINFO info_set;
110 DWORD index = 0;
111 SP_DEVICE_INTERFACE_DATA interface_data;
112 DWORD detail_size = MAX_PATH * sizeof(WCHAR);
115 BOOL rc;
116
117 HidD_GetHidGuid(&hid_guid);
118
119 ZeroMemory(&interface_data, sizeof(interface_data));
120 interface_data.cbSize = sizeof(interface_data);
121
122 data = HeapAlloc(GetProcessHeap(), 0 , sizeof(*data) + detail_size);
123 data->cbSize = sizeof(*data);
124
126 while (SetupDiEnumDeviceInterfaces(info_set, NULL, &hid_guid, index, &interface_data))
127 {
128 index ++;
129
130 if (SetupDiGetDeviceInterfaceDetailW(info_set, &interface_data, data, sizeof(*data) + detail_size, NULL, NULL))
131 {
133 HIDP_CAPS Caps;
136 {
137 trace("Not enough permissions to read device %s.\n", wine_dbgstr_w(data->DevicePath));
138 continue;
139 }
140 ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
141
142 rc = HidD_GetPreparsedData(file, &ppd);
143 ok(rc, "Failed to get preparsed data(0x%x)\n", GetLastError());
144 status = HidP_GetCaps(ppd, &Caps);
145 ok(status == HIDP_STATUS_SUCCESS, "Failed to get Caps(0x%x)\n", status);
146 rc = HidD_FreePreparsedData(ppd);
147 ok(rc, "Failed to free preparsed data(0x%x)\n", GetLastError());
148 if (!page || page == Caps.UsagePage)
149 {
150 int j;
151 if (!usage_count)
152 {
155 return file;
156 }
157 for (j = 0; j < usage_count; j++)
158 if (!usages[j] || usages[j] == Caps.Usage)
159 {
162 return file;
163 }
164 }
166 }
167 }
170 return NULL;
171}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2780
HDEVINFO WINAPI SetupDiGetClassDevsW(CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
Definition: devinst.c:2292
BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:3011
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint index
Definition: glext.h:6031
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
HIDAPI BOOLEAN WINAPI HidD_GetPreparsedData(IN HANDLE HidDeviceObject, OUT PHIDP_PREPARSED_DATA *PreparsedData)
Definition: hid.c:290
HIDAPI VOID WINAPI HidD_GetHidGuid(OUT LPGUID HidGuid)
Definition: hid.c:202
HIDAPI BOOLEAN WINAPI HidD_FreePreparsedData(IN PHIDP_PREPARSED_DATA PreparsedData)
Definition: hid.c:139
HIDAPI NTSTATUS NTAPI HidP_GetCaps(IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities)
Definition: hidp.c:26
#define HIDP_STATUS_SUCCESS
Definition: hidpi.h:248
struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA
Definition: hidpi.h:39
#define wine_dbgstr_w
Definition: kernel32.h:34
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
static PCCRYPT_OID_INFO ** usages
Definition: softpub.c:81
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
#define DIGCF_PRESENT
Definition: setupapi.h:171
USAGE UsagePage
Definition: hidpi.h:151
USAGE Usage
Definition: hidpi.h:150
Definition: fci.c:127
Definition: module.h:576
Definition: ps.c:97
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_get_input_report(), and test_read_device().

◆ process_data()

static void process_data ( HIDP_CAPS  Caps,
PHIDP_PREPARSED_DATA  ppd,
CHAR data,
DWORD  data_length 
)
static

Definition at line 173 of file device.c.

174{
175 INT i;
177
178 if (Caps.NumberInputButtonCaps)
179 {
180 USAGE button_pages[100];
181
182 for (i = 1; i < 0xff; i++)
183 {
184 ULONG usage_length = 100;
185 status = HidP_GetUsages(HidP_Input, i, 0, button_pages, &usage_length, ppd, data, data_length);
186 ok (status == HIDP_STATUS_SUCCESS || usage_length == 0,
187 "HidP_GetUsages failed (%x) but usage length still %i\n", status, usage_length);
188 if (usage_length)
189 {
190 CHAR report[50];
191 int count;
192 int j;
193
194 count = usage_length;
195 j = 0;
196 report[0] = 0;
197 trace("\tButtons [0x%x: %i buttons]:\n", i, usage_length);
198 for (count = 0; count < usage_length; count += 15)
199 {
200 for (j=count; j < count+15 && j < usage_length; j++)
201 {
202 CHAR btn[7];
203 sprintf(btn, "%i ", button_pages[j]);
204 strcat(report, btn);
205 }
206 trace("\t\t%s\n", report);
207 }
208 }
209 }
210 }
211
212 if (Caps.NumberInputValueCaps)
213 {
214 ULONG value;
217
221 ok(status == HIDP_STATUS_SUCCESS, "Failed to get value caps (%x)\n",status);
222
223 trace("\tValues:\n");
224 for (i = 0; i < length; i++)
225 {
227 values[i].Range.UsageMin, &value, ppd, data, data_length);
228 ok(status == HIDP_STATUS_SUCCESS, "Failed to get value [%i,%i] (%x)\n",
229 values[i].UsagePage, values[i].Range.UsageMin, status);
230 trace("[%02x, %02x]: %u\n",values[i].UsagePage, values[i].Range.UsageMin, value);
231 }
232
234 }
235}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Must_inspect_result_ _In_ USAGE UsagePage
Definition: hidpi.h:382
@ HidP_Input
Definition: hidpi.h:238
#define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_)
Definition: hidpi.h:470
_Must_inspect_result_ HIDAPI NTSTATUS NTAPI HidP_GetUsages(_In_ HIDP_REPORT_TYPE ReportType, _In_ USAGE UsagePage, _In_ USHORT LinkCollection, _Out_writes_to_(*UsageLength, *UsageLength) USAGE *UsageList, _Inout_ ULONG *UsageLength, _In_ PHIDP_PREPARSED_DATA PreparsedData, _Out_writes_bytes_(ReportLength) PCHAR Report, _In_ ULONG ReportLength)
_Must_inspect_result_ HIDAPI NTSTATUS NTAPI HidP_GetUsageValue(_In_ HIDP_REPORT_TYPE ReportType, _In_ USAGE UsagePage, _In_ USHORT LinkCollection, _In_ USAGE Usage, _Out_ PULONG UsageValue, _In_ PHIDP_PREPARSED_DATA PreparsedData, _In_reads_bytes_(ReportLength) PCHAR Report, _In_ ULONG ReportLength)
USHORT USAGE
Definition: hidusage.h:30
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned short USHORT
Definition: pedump.c:61
USHORT NumberInputButtonCaps
Definition: hidpi.h:157
USHORT NumberInputValueCaps
Definition: hidpi.h:158
Definition: range.c:39
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
char CHAR
Definition: xmlstorage.h:175

Referenced by test_get_input_report(), and test_read_device().

◆ run_for_each_device()

static void run_for_each_device ( device_test test)
static

Definition at line 57 of file device.c.

58{
59 GUID hid_guid;
60 HDEVINFO info_set;
61 DWORD index = 0;
62 SP_DEVICE_INTERFACE_DATA interface_data;
63 DWORD detail_size = MAX_PATH * sizeof(WCHAR);
65
66 HidD_GetHidGuid(&hid_guid);
67
68 ZeroMemory(&interface_data, sizeof(interface_data));
69 interface_data.cbSize = sizeof(interface_data);
70
71 data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data) + detail_size);
72 data->cbSize = sizeof(*data);
73
75 while (SetupDiEnumDeviceInterfaces(info_set, NULL, &hid_guid, index, &interface_data))
76 {
77 index ++;
78
79 if (SetupDiGetDeviceInterfaceDetailW(info_set, &interface_data, data, sizeof(*data) + detail_size, NULL, NULL))
80 {
83 {
84 trace("Not enough permissions to read device %s.\n", wine_dbgstr_w(data->DevicePath));
85 continue;
86 }
88 {
89 trace("Device is busy: %s.\n", wine_dbgstr_w(data->DevicePath));
90 continue;
91 }
92
93 ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u.\n",
94 wine_dbgstr_w(data->DevicePath), GetLastError());
95
97 test(file);
98
100 }
101 }
104}
#define GENERIC_READ
Definition: compat.h:135
#define test
Definition: rosglue.h:37
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( device  )

Definition at line 400 of file device.c.

401{
405}
static void test_get_input_report(void)
Definition: device.c:324
static void test_read_device(void)
Definition: device.c:237
static void run_for_each_device(device_test *test)
Definition: device.c:57
static void test_device_info(void)
Definition: devinst.c:274

◆ test_device_info()

static void test_device_info ( HANDLE  device)
static

Definition at line 33 of file device.c.

34{
36 HIDP_CAPS Caps;
37 HIDD_ATTRIBUTES attributes;
39 BOOL rc;
40 WCHAR device_name[128];
41
42 rc = HidD_GetPreparsedData(device, &ppd);
43 ok(rc, "Failed to get preparsed data(0x%x)\n", GetLastError());
44 status = HidP_GetCaps(ppd, &Caps);
45 ok(status == HIDP_STATUS_SUCCESS, "Failed to get Caps(0x%x)\n", status);
47 ok(rc, "Failed to get product string(0x%x)\n", GetLastError());
48 trace("Found device %s (%02x, %02x)\n", wine_dbgstr_w(device_name), Caps.UsagePage, Caps.Usage);
49 rc = HidD_FreePreparsedData(ppd);
50 ok(rc, "Failed to free preparsed data(0x%x)\n", GetLastError());
51 rc = HidD_GetAttributes(device, &attributes);
52 ok(rc, "Failed to get device attributes (0x%x)\n", GetLastError());
53 ok(attributes.Size == sizeof(attributes), "Unexpected HIDD_ATTRIBUTES size: %d\n", attributes.Size);
54 trace("Device attributes: vid:%04x pid:%04x ver:%04x\n", attributes.VendorID, attributes.ProductID, attributes.VersionNumber);
55}
static const WCHAR device_name[]
Definition: btrfs.c:60
HIDAPI BOOLEAN WINAPI HidD_GetAttributes(IN HANDLE HidDeviceObject, OUT PHIDD_ATTRIBUTES Attributes)
Definition: hid.c:152
HIDAPI BOOLEAN WINAPI HidD_GetProductString(IN HANDLE HidDeviceObject, OUT PVOID Buffer, IN ULONG BufferLength)
Definition: hid.c:345
ULONG Size
Definition: hidpi.h:84
USHORT VendorID
Definition: hidpi.h:85
USHORT ProductID
Definition: hidpi.h:86
USHORT VersionNumber
Definition: hidpi.h:87
Definition: devices.h:37

◆ test_get_input_report()

static void test_get_input_report ( void  )
static

Definition at line 324 of file device.c.

325{
327 HIDP_CAPS Caps;
328 WCHAR device_name[128];
329 CHAR *data = NULL;
330 DWORD tick, spent, max_time;
331 char *report;
332 BOOL rc;
334
337
338 if (!device)
339 device = get_device(0x0, NULL, 0x0, GENERIC_READ);
340
341 if (!device)
342 {
343 trace("No device found for testing\n");
344 return;
345 }
347 ok(rc, "Failed to get product string(0x%x)\n", GetLastError());
348 trace("HidD_GetInputRpeort tests on device :%s\n",wine_dbgstr_w(device_name));
349
350 rc = HidD_GetPreparsedData(device, &ppd);
351 ok(rc, "Failed to get preparsed data(0x%x)\n", GetLastError());
352 status = HidP_GetCaps(ppd, &Caps);
353 ok(status == HIDP_STATUS_SUCCESS, "Failed to get Caps(0x%x)\n", status);
355
357 max_time = READ_MAX_TIME;
358 else
359 max_time = 100;
361 trace("Test your device for the next %i seconds\n", max_time/1000);
363 tick = GetTickCount();
364 spent = 0;
365 do
366 {
367 int i;
368
369 data[0] = 0; /* Just testing report ID 0 for now, That will catch most devices */
371 spent = GetTickCount() - tick;
372
373 if (rc)
374 {
375 ok(data[0] == 0, "Report ID (0) is not the first byte of the data\n");
376 report[0] = 0;
377 for (i = 0; i < Caps.InputReportByteLength; i++)
378 {
379 char bytestr[5];
380 sprintf(bytestr, "%x ", (BYTE)data[i]);
381 strcat(report, bytestr);
382 }
383 trace("Input report (%i): %s\n", Caps.InputReportByteLength, report);
384
385 process_data(Caps, ppd, data, Caps.InputReportByteLength);
386 }
387 else
388 trace("Failed to get Input Report, (%x)\n", rc);
389 trace("REMAINING: %d ms\n", max_time - spent);
390 Sleep(500);
391 } while(spent < max_time);
392
393 rc = HidD_FreePreparsedData(ppd);
394 ok(rc, "Failed to free preparsed data(0x%x)\n", GetLastError());
398}
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
HIDAPI BOOLEAN WINAPI HidD_GetInputReport(IN HANDLE HidDeviceObject, IN OUT PVOID ReportBuffer, IN ULONG ReportBufferLength)
Definition: hid.c:215
#define HID_USAGE_GENERIC_GAMEPAD
Definition: hidusage.h:35
#define HID_USAGE_PAGE_GENERIC
Definition: hidusage.h:176
#define HID_USAGE_GENERIC_JOYSTICK
Definition: hidusage.h:34
static HANDLE get_device(USHORT page, USHORT usages[], UINT usage_count, DWORD access)
Definition: device.c:106
#define READ_MAX_TIME
Definition: device.c:29
static void process_data(HIDP_CAPS Caps, PHIDP_PREPARSED_DATA ppd, CHAR *data, DWORD data_length)
Definition: device.c:173
int winetest_interactive
USHORT InputReportByteLength
Definition: hidpi.h:152
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_read_device()

static void test_read_device ( void  )
static

Definition at line 237 of file device.c.

238{
240 HIDP_CAPS Caps;
242 WCHAR device_name[128];
243 CHAR *data = NULL;
244 DWORD read;
245 BOOL rc;
247 DWORD timeout, tick, spent, max_time;
248 char *report;
249
252
253 if (!device)
254 device = get_device(0x0, NULL, 0x0, GENERIC_READ);
255
256 if (!device)
257 {
258 trace("No device found for reading\n");
259 return;
260 }
262 ok(rc, "Failed to get product string(0x%x)\n", GetLastError());
263 trace("Read tests on device :%s\n",wine_dbgstr_w(device_name));
264
265 rc = HidD_GetPreparsedData(device, &ppd);
266 ok(rc, "Failed to get preparsed data(0x%x)\n", GetLastError());
267 status = HidP_GetCaps(ppd, &Caps);
268 ok(status == HIDP_STATUS_SUCCESS, "Failed to get Caps(0x%x)\n", status);
270
271 memset(&overlapped, 0, sizeof(overlapped));
274 {
275 max_time = READ_MAX_TIME;
276 timeout = 1000;
277 }
278 else
279 max_time = timeout = 100;
281 trace("Test your device for the next %i seconds\n", max_time/1000);
283 tick = GetTickCount();
284 spent = 0;
285 do
286 {
289 {
290 ResetEvent(overlapped.hEvent);
291 spent = GetTickCount() - tick;
292 trace("REMAINING: %d ms\n", max_time - spent);
293 continue;
294 }
295 ResetEvent(overlapped.hEvent);
296 spent = GetTickCount() - tick;
298 if (read)
299 {
300 int i;
301
302 report[0] = 0;
303 for (i = 0; i < read && i < Caps.InputReportByteLength; i++)
304 {
305 char bytestr[5];
306 sprintf(bytestr, "%x ", (BYTE)data[i]);
307 strcat(report, bytestr);
308 }
309 trace("Input report (%i): %s\n", read, report);
310
311 process_data(Caps, ppd, data, read);
312 }
313 trace("REMAINING: %d ms\n", max_time - spent);
314 } while(spent < max_time);
315
316 CloseHandle(overlapped.hEvent);
317 rc = HidD_FreePreparsedData(ppd);
318 ok(rc, "Failed to free preparsed data(0x%x)\n", GetLastError());
322}
#define read
Definition: acwin.h:96
#define FALSE
Definition: types.h:117
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
#define memset(x, y, z)
Definition: compat.h:39
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:81
Definition: dhcpd.h:245
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by START_TEST().