On Windows dinput sometimes ignores injected input events.
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/dinput8/tests/device.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c index 7d6f8442085..56aa7b353aa 100644 --- a/dlls/dinput8/tests/device.c +++ b/dlls/dinput8/tests/device.c @@ -869,11 +869,16 @@ static void test_keyboard_events(void) data_size = ARRAY_SIZE(obj_data); hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), obj_data, &data_size, 0); ok(SUCCEEDED(hr), "Failed to get data hr=%08x\n", hr); - ok(data_size == 1, "Expected 1 element, received %d\n", data_size); - - hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(kbdata), kbdata); - ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceState failed: %08x\n", hr); - ok(kbdata[DIK_SPACE], "Expected DIK_SPACE key state down\n"); + if (data_size != 1) + { + win_skip("We're not able to inject input into Windows dinput8 with events\n"); + } + else + { + hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(kbdata), kbdata); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceState failed: %08x\n", hr); + ok(kbdata[DIK_SPACE], "Expected DIK_SPACE key state down\n"); + }
keybd_event(VK_SPACE, DIK_SPACE, KEYEVENTF_KEYUP, 0); flush_events(); @@ -881,7 +886,8 @@ static void test_keyboard_events(void) data_size = ARRAY_SIZE(obj_data); hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), obj_data, &data_size, 0); ok(SUCCEEDED(hr), "Failed to get data hr=%08x\n", hr); - ok(data_size == 1, "Expected 1 element, received %d\n", data_size); + if (data_size != 1) + win_skip("We're not able to inject input into Windows dinput8 with events\n");
/* Test injecting keyboard events with scancode=0. * Windows DInput ignores the VK, sets scancode 0 to be pressed, and GetDeviceData returns no elements. */ @@ -895,8 +901,10 @@ static void test_keyboard_events(void)
hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(kbdata), kbdata); ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceState failed: %08x\n", hr); - todo_wine - ok(kbdata[0], "Expected key 0 state down\n"); + if (!strcmp(winetest_platform, "windows") && !kbdata[0]) + skip("We're not able to inject input into Windows dinput8 with events\n"); + else + todo_wine ok(kbdata[0], "Expected key 0 state down\n");
keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0); flush_events();