From edf1183114d23671bf842867b4899b3ed1ada504 Mon Sep 17 00:00:00 2001 From: Alan Ott Date: Thu, 26 Jan 2012 11:12:22 +0800 Subject: [PATCH] cleanup previous commit --- windows/hid.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/windows/hid.c b/windows/hid.c index 52a4ece..77fa93c 100644 --- a/windows/hid.c +++ b/windows/hid.c @@ -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; }