From 335c2118d213f12dc0ea62c627f631ee427fc1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincas=20Mili=C5=ABnas?= Date: Sun, 26 Jun 2011 23:26:58 +0300 Subject: [PATCH 15/20] user32: Added GetRawInputDeviceInfoA implementation (try 16) --- dlls/user32/input.c | 39 ++++++++++++++++++++++++++++++++++++--- dlls/user32/tests/input.c | 28 ++++++++++++++-------------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 59ec0ac..fcbe84a 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -551,11 +551,44 @@ UINT WINAPI DECLSPEC_HOTPATCH GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, */ UINT WINAPI GetRawInputDeviceInfoA(HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize) { - FIXME("(hDevice=%p, uiCommand=%d, pData=%p, pcbSize=%p) stub!\n", hDevice, uiCommand, pData, pcbSize); + TRACE("(hDevice=%p, uiCommand=%d, pData=%p, pcbSize=%p)\n", hDevice, uiCommand, pData, pcbSize); - return 0; -} + if (pcbSize == NULL) + { + SetLastError( ERROR_NOACCESS ); + return (UINT)-1; + } + if (uiCommand == RIDI_DEVICENAME && pData != NULL) + { + WCHAR buffer[256]; + UINT size = 256; + const UINT ret = GetRawInputDeviceInfoW( hDevice, uiCommand, buffer, &size ); + /* ret is the character count */ + if (ret == (UINT)-1) + { + return ret; + } + else if (ret > 0 && *pcbSize >= ret) + { + const int ret2 = WideCharToMultiByte( CP_ACP, 0, buffer, ret, pData, *pcbSize, NULL, NULL ); + return ret2 ? ret2 : (UINT)-1; + } + else if (ret > 0) + { + *pcbSize = ret; + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return (UINT)-1; + } + else + { + *pcbSize = size; + return ret; + } + } + else + return GetRawInputDeviceInfoW( hDevice, uiCommand, pData, pcbSize ); +} /****************************************************************** * GetRawInputDeviceInfoW (USER32.@) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index c5045e8..adbc23b 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1809,18 +1809,18 @@ static void test_get_raw_input_device_info_a(void) SetLastError(0xdeadbeef); ret = pGetRawInputDeviceInfoA(NULL, 0, NULL, NULL); error = GetLastError(); - todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " + ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " "expected (UINT)-1, got %u\n", ret); - todo_wine ok(error == ERROR_NOACCESS, "GetRawInputDeviceInfoA returned " + ok(error == ERROR_NOACCESS, "GetRawInputDeviceInfoA returned " "wrong error code: %u\n", error); SetLastError(0xdeadbeef); size = 0; ret = pGetRawInputDeviceInfoA(NULL, 0, NULL, &size); error = GetLastError(); - todo_wine ok(ret == (UINT)-1, + ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: expected (UINT)-1, got %u\n", ret); - todo_wine ok(error == ERROR_INVALID_HANDLE, + ok(error == ERROR_INVALID_HANDLE, "GetRawInputDeviceInfoA returned wrong error code: %u\n", error); ret = pGetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)); @@ -1840,51 +1840,51 @@ static void test_get_raw_input_device_info_a(void) size = 0; ret = pGetRawInputDeviceInfoA(devices[0].hDevice, 0, NULL, &size); error = GetLastError(); - todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " + ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " "expected (UINT)-1, got %u\n", ret); - todo_wine ok(error == ERROR_INVALID_PARAMETER, "GetRawInputDeviceInfoA returned " + ok(error == ERROR_INVALID_PARAMETER, "GetRawInputDeviceInfoA returned " "wrong error code: %u\n", error); SetLastError(0xdeadbeef); size = 0; ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICENAME, buffer, &size); error = GetLastError(); - todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " + ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " "expected (UINT)-1, got %u\n", ret); - todo_wine ok(error == ERROR_INSUFFICIENT_BUFFER, "GetRawInputDeviceInfoA returned " + ok(error == ERROR_INSUFFICIENT_BUFFER, "GetRawInputDeviceInfoA returned " "wrong error code: %u\n", error); size = 0; ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICENAME, NULL, &size); ok(ret == 0, "GetRawInputDeviceInfoA returned wrong value: expected 0, got %u\n", ret); - todo_wine ok(size > 5, "GetRawInputDeviceInfoA returned wrong " + ok(size > 5, "GetRawInputDeviceInfoA returned wrong " "device name size: expected x > 5, got %u\n", size); buffer[0] = 0; ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICENAME, buffer, &size); - todo_wine ok(ret != (UINT)-1 && ret > 0, "GetRawInputDeviceInfoA returned wrong value: " + ok(ret != (UINT)-1 && ret > 0, "GetRawInputDeviceInfoA returned wrong value: " "expected 0 < x < (UINT)-1, got %u\n", ret); size = strlen(buffer); - todo_wine ok(size > 5, "GetRawInputDeviceInfoA returned too short device name: " + ok(size > 5, "GetRawInputDeviceInfoA returned too short device name: " "expected x > 5, got %u\n", size); size = 0; ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICEINFO, NULL, &size); ok(ret == 0, "GetRawInputDeviceInfoA returned wrong value: expected 0, got %u\n", ret); - todo_wine ok(size == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoA returned " + ok(size == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoA returned " "wrong device info size: expected sizeof(RID_DEVICE_INFO), got %u\n", size); size = sizeof(RID_DEVICE_INFO); info.cbSize = sizeof(RID_DEVICE_INFO); ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICEINFO, &info, &size); - todo_wine ok(ret == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoA returned wrong value: " + ok(ret == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoA returned wrong value: " "expected sizeof(RID_DEVICE_INFO), got %u\n", ret); size = 0xdeadbeef; ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_PREPARSEDDATA, NULL, &size); ok(ret == 0, "GetRawInputDeviceInfoA returned wrong value: " "expected 0, got %u\n", ret); - todo_wine ok(size == 0, "GetRawInputDeviceInfoA returned wrong preparsed data size: " + ok(size == 0, "GetRawInputDeviceInfoA returned wrong preparsed data size: " "expected 0, got %u\n", size); HeapFree(GetProcessHeap(), 0, devices); -- 1.7.3.4