cleanup previous commit

This commit is contained in:
Alan Ott 2012-01-26 11:12:22 +08:00
parent fd64a9f36b
commit edf1183114

View File

@ -211,46 +211,18 @@ static HANDLE open_device(const char *path, BOOL enumerate)
{
HANDLE handle;
DWORD desired_access = (enumerate)? 0: (GENERIC_WRITE | GENERIC_READ);
DWORD share_mode = (enumerate)?
FILE_SHARE_READ|FILE_SHARE_WRITE:
FILE_SHARE_READ;
if (enumerate) {
handle = CreateFileA(path,
0, /* desired access */
FILE_SHARE_READ|FILE_SHARE_WRITE, /*share mode*/
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,//FILE_ATTRIBUTE_NORMAL,
0);
return handle;
}
/* First, try to open with sharing mode turned off. This will make it so
that a HID device can only be opened once. This is to be consistent
with the behavior on the other platforms. */
handle = CreateFileA(path,
desired_access,
FILE_SHARE_READ, /*share mode*/
share_mode,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,//FILE_ATTRIBUTE_NORMAL,
0);
#if 0
if (handle == INVALID_HANDLE_VALUE) {
/* Couldn't open the device. Some devices must be opened
with sharing enabled (even though they are only opened once),
so try it here. */
handle = CreateFileA(path,
desired_access,
FILE_SHARE_READ|FILE_SHARE_WRITE, /*share mode*/
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,//FILE_ATTRIBUTE_NORMAL,
0);
}
#endif
return handle;
}