Commit 6d7828e8 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

user32: Support RIDI_PREPARSEDDATA in GetRawInputDeviceInfo.

parent 0b7f4b40
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "ddk/hidsdi.h" #include "ddk/hidsdi.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/server.h" #include "wine/server.h"
#include "wine/hid.h"
#include "user_private.h" #include "user_private.h"
...@@ -467,6 +468,23 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT ...@@ -467,6 +468,23 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT
to_copy = &info; to_copy = &info;
break; break;
case RIDI_PREPARSEDDATA:
avail_bytes = *data_size;
if (device == WINE_MOUSE_HANDLE ||
device == WINE_KEYBOARD_HANDLE)
{
to_copy_bytes = 0;
*data_size = 0;
to_copy = NULL;
}
else
{
to_copy_bytes = ((WINE_HIDP_PREPARSED_DATA*)hid_device->data)->dwSize;
*data_size = to_copy_bytes;
to_copy = hid_device->data;
}
break;
default: default:
FIXME("command %#x not supported\n", command); FIXME("command %#x not supported\n", command);
return ~0U; return ~0U;
......
TESTDLL = user32.dll TESTDLL = user32.dll
IMPORTS = user32 gdi32 advapi32 IMPORTS = user32 gdi32 advapi32 hid
C_SRCS = \ C_SRCS = \
broadcast.c \ broadcast.c \
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "winbase.h" #include "winbase.h"
#include "winuser.h" #include "winuser.h"
#include "winnls.h" #include "winnls.h"
#include "ddk/hidsdi.h"
#include "wine/test.h" #include "wine/test.h"
...@@ -1605,6 +1606,7 @@ static void test_GetRawInputDeviceList(void) ...@@ -1605,6 +1606,7 @@ static void test_GetRawInputDeviceList(void)
RAWINPUTDEVICELIST devices[32]; RAWINPUTDEVICELIST devices[32];
UINT ret, oret, devcount, odevcount, i; UINT ret, oret, devcount, odevcount, i;
DWORD err; DWORD err;
BOOLEAN br;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pGetRawInputDeviceList(NULL, NULL, 0); ret = pGetRawInputDeviceList(NULL, NULL, 0);
...@@ -1642,6 +1644,7 @@ static void test_GetRawInputDeviceList(void) ...@@ -1642,6 +1644,7 @@ static void test_GetRawInputDeviceList(void)
UINT sz, len; UINT sz, len;
RID_DEVICE_INFO info; RID_DEVICE_INFO info;
HANDLE file; HANDLE file;
char *ppd;
/* get required buffer size */ /* get required buffer size */
name[0] = '\0'; name[0] = '\0';
...@@ -1688,6 +1691,44 @@ static void test_GetRawInputDeviceList(void) ...@@ -1688,6 +1691,44 @@ static void test_GetRawInputDeviceList(void)
file = CreateFileW(name, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); file = CreateFileW(name, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
todo_wine_if(info.dwType != RIM_TYPEHID) todo_wine_if(info.dwType != RIM_TYPEHID)
ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError()); ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError());
sz = 0;
ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_PREPARSEDDATA, NULL, &sz);
ok(ret == 0, "GetRawInputDeviceInfo gave wrong return: %u\n", ret);
ok((info.dwType == RIM_TYPEHID && sz != 0) ||
(info.dwType != RIM_TYPEHID && sz == 0),
"Got wrong PPD size for type 0x%x: %u\n", info.dwType, sz);
ppd = HeapAlloc(GetProcessHeap(), 0, sz);
ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_PREPARSEDDATA, ppd, &sz);
ok(ret == sz, "GetRawInputDeviceInfo gave wrong return: %u, should be %u\n", ret, sz);
if (file != INVALID_HANDLE_VALUE && ret == sz)
{
PHIDP_PREPARSED_DATA preparsed;
if (info.dwType == RIM_TYPEHID)
{
br = HidD_GetPreparsedData(file, &preparsed);
ok(br == TRUE, "HidD_GetPreparsedData failed\n");
if (br)
ok(!memcmp(preparsed, ppd, sz), "Expected to get same preparsed data\n");
}
else
{
/* succeeds on hardware, fails in some VMs */
br = HidD_GetPreparsedData(file, &preparsed);
todo_wine
ok(br == TRUE || broken(br == FALSE), "HidD_GetPreparsedData failed\n");
}
if (br)
HidD_FreePreparsedData(preparsed);
}
HeapFree(GetProcessHeap(), 0, ppd);
CloseHandle(file); CloseHandle(file);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment