Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/dinput/tests/mouse.c | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 69051bb2a34..2d4699bb9a0 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -106,7 +106,7 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) DIMOUSESTATE m_state; HWND hwnd2; DIPROPDWORD di_op; - DIDEVICEOBJECTDATA mouse_state; + DIDEVICEOBJECTDATA mouse_state[30]; DWORD cnt; int i;
@@ -159,16 +159,20 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) ok(hr == S_OK, "Acquire() failed: %08x\n", hr);
mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); + cnt = ARRAY_SIZE(mouse_state); + mouse_state[0].dwTimeStamp = 0xdeadbeef; + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0); + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef, + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); hr = IDirectInputDevice_Unacquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); + cnt = ARRAY_SIZE(mouse_state); + mouse_state[0].dwTimeStamp = 0xdeadbeef; + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0); + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef, + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr); @@ -178,20 +182,26 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); + cnt = ARRAY_SIZE(mouse_state); + mouse_state[0].dwTimeStamp = 0xdeadbeef; + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0); + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef, + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
/* Check for buffer overflow */ for (i = 0; i < 6; i++) mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0);
- cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == DI_OK, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); + cnt = ARRAY_SIZE(mouse_state); + mouse_state[0].dwTimeStamp = 0xdeadbeef; + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0); + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef, + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp); + cnt = ARRAY_SIZE(mouse_state); + mouse_state[0].dwTimeStamp = 0xdeadbeef; + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0); + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef, + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
/* Check for granularity property using BYOFFSET */ memset(&di_op, 0, sizeof(di_op));
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/dinput/tests/device.c | 122 -------------------------------- dlls/dinput8/tests/device.c | 136 ++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 122 deletions(-)
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index 6307957b6e2..485acca4f61 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -292,126 +292,6 @@ static BOOL CALLBACK enum_devices(const DIDEVICEINSTANCEA *lpddi, void *pvRef) return DIENUM_CONTINUE; }
-struct overlapped_state -{ - BYTE keys[4]; - DWORD extra_element; -}; - -static const DIOBJECTDATAFORMAT obj_overlapped_slider_format[] = { - { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_A),0}, - { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_S),0}, - { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_D),0}, - { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_F),0}, - { &GUID_Slider, 0, DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION}, -}; - -static const DIDATAFORMAT overlapped_slider_format = { - sizeof(DIDATAFORMAT), - sizeof(DIOBJECTDATAFORMAT), - DIDF_ABSAXIS, - sizeof(struct overlapped_state), - ARRAY_SIZE(obj_overlapped_slider_format), - (LPDIOBJECTDATAFORMAT)obj_overlapped_slider_format -}; - -static const DIOBJECTDATAFORMAT obj_overlapped_pov_format[] = { - { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_A),0}, - { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_S),0}, - { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_D),0}, - { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_F),0}, - { &GUID_POV, 0, DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0}, -}; - -static const DIDATAFORMAT overlapped_pov_format = { - sizeof(DIDATAFORMAT), - sizeof(DIOBJECTDATAFORMAT), - DIDF_ABSAXIS, - sizeof(struct overlapped_state), - ARRAY_SIZE(obj_overlapped_pov_format), - (LPDIOBJECTDATAFORMAT)obj_overlapped_pov_format -}; - -static void pump_messages(void) -{ - MSG msg; - - while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessageA(&msg); - } -} - -void overlapped_format_tests(IDirectInputA *pDI, HWND hwnd) -{ - HRESULT hr; - struct overlapped_state state; - IDirectInputDeviceA *keyboard = NULL; - - hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &keyboard, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr); - - /* test overlapped slider - default value 0 */ - hr = IDirectInputDevice_SetDataFormat(keyboard, &overlapped_slider_format); - ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); - hr = IDirectInputDevice_Acquire(keyboard); - ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr); - - SetFocus(hwnd); - pump_messages(); - - /* press D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); - pump_messages(); - - memset(&state, 0xFF, sizeof(state)); - hr = IDirectInputDevice_GetDeviceState(keyboard, sizeof(state), &state); - ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr); - - ok(state.keys[0] == 0x00, "key A should be still up\n"); - ok(state.keys[1] == 0x00, "key S should be still up\n"); - ok(state.keys[2] == 0x80, "keydown for D did not register\n"); - ok(state.keys[3] == 0x00, "key F should be still up\n"); - ok(state.extra_element == 0, "State struct was not memset to zero\n"); - - /* release D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); - pump_messages(); - - hr = IDirectInputDevice_Unacquire(keyboard); - ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %08x\n", hr); - - /* test overlapped pov - default value - 0xFFFFFFFF */ - hr = IDirectInputDevice_SetDataFormat(keyboard, &overlapped_pov_format); - ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); - hr = IDirectInputDevice_Acquire(keyboard); - ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr); - - SetFocus(hwnd); - pump_messages(); - - /* press D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); - pump_messages(); - - memset(&state, 0xFF, sizeof(state)); - hr = IDirectInputDevice_GetDeviceState(keyboard, sizeof(state), &state); - ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr); - - ok(state.keys[0] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[1] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[2] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[3] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.extra_element == 0, "State struct was not memset to zero\n"); - - /* release D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); - pump_messages(); - - if (keyboard) IUnknown_Release(keyboard); -} - static void device_tests(void) { HRESULT hr; @@ -462,8 +342,6 @@ static void device_tests(void) if (device) IUnknown_Release(device); }
- overlapped_format_tests(pDI, hwnd); - DestroyWindow(hwnd); } if (obj) IUnknown_Release(obj); diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c index 17deed193dd..4a6fc21ecec 100644 --- a/dlls/dinput8/tests/device.c +++ b/dlls/dinput8/tests/device.c @@ -1011,6 +1011,141 @@ static void test_appdata_property(void) IDirectInput_Release(pDI); }
+struct overlapped_state +{ + BYTE keys[4]; + DWORD extra_element; +}; + +static const DIOBJECTDATAFORMAT obj_overlapped_slider_format[] = { + { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_A),0}, + { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_S),0}, + { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_D),0}, + { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_F),0}, + { &GUID_Slider, 0, DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION}, +}; + +static const DIDATAFORMAT overlapped_slider_format = { + sizeof(DIDATAFORMAT), + sizeof(DIOBJECTDATAFORMAT), + DIDF_ABSAXIS, + sizeof(struct overlapped_state), + ARRAY_SIZE(obj_overlapped_slider_format), + (LPDIOBJECTDATAFORMAT)obj_overlapped_slider_format +}; + +static const DIOBJECTDATAFORMAT obj_overlapped_pov_format[] = { + { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_A),0}, + { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_S),0}, + { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_D),0}, + { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_F),0}, + { &GUID_POV, 0, DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0}, +}; + +static const DIDATAFORMAT overlapped_pov_format = { + sizeof(DIDATAFORMAT), + sizeof(DIOBJECTDATAFORMAT), + DIDF_ABSAXIS, + sizeof(struct overlapped_state), + ARRAY_SIZE(obj_overlapped_pov_format), + (LPDIOBJECTDATAFORMAT)obj_overlapped_pov_format +}; + +void test_overlapped_format(void) +{ + HRESULT hr; + HWND hwnd; + IDirectInput8A *di = NULL; + IDirectInputDevice8A *di_keyboard; + struct overlapped_state state; + + hr = CoCreateInstance(&CLSID_DirectInput8, 0, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (LPVOID*)&di); + if (hr == DIERR_OLDDIRECTINPUTVERSION || + hr == DIERR_BETADIRECTINPUTVERSION || + hr == REGDB_E_CLASSNOTREG) + { + win_skip("test_overlapped_format requires dinput8\n"); + return; + } + ok(SUCCEEDED(hr), "DirectInput8Create failed: %08x\n", hr); + + hr = IDirectInput8_Initialize(di, GetModuleHandleA(NULL), DIRECTINPUT_VERSION); + if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION) + { + win_skip("test_overlapped_format requires dinput8\n"); + return; + } + ok(SUCCEEDED(hr), "IDirectInput8_Initialize failed: %08x\n", hr); + + hwnd = CreateWindowExA(WS_EX_TOPMOST, "static", "dinput", WS_POPUP | WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, NULL, NULL); + ok(hwnd != NULL, "CreateWindowExA failed\n"); + + hr = IDirectInput8_CreateDevice(di, &GUID_SysKeyboard, &di_keyboard, NULL); + ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr); + + /* test overlapped slider - default value 0 */ + hr = IDirectInputDevice8_SetDataFormat(di_keyboard, &overlapped_slider_format); + ok(SUCCEEDED(hr), "IDirectInputDevice8_SetDataFormat() failed: %08x\n", hr); + hr = IDirectInputDevice8_Acquire(di_keyboard); + ok(SUCCEEDED(hr), "IDirectInputDevice8_Acquire() failed: %08x\n", hr); + + SetFocus(hwnd); + flush_events(); + + /* press D */ + keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); + flush_events(); + + memset(&state, 0xFF, sizeof(state)); + hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(state), &state); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceState() failed: %08x\n", hr); + + ok(state.keys[0] == 0x00, "key A should be still up\n"); + ok(state.keys[1] == 0x00, "key S should be still up\n"); + ok(state.keys[2] == 0x80, "keydown for D did not register\n"); + ok(state.keys[3] == 0x00, "key F should be still up\n"); + ok(state.extra_element == 0, "State struct was not memset to zero\n"); + + /* release D */ + keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); + flush_events(); + + hr = IDirectInputDevice8_Unacquire(di_keyboard); + ok(SUCCEEDED(hr), "IDirectInputDevice8_Unacquire() failed: %08x\n", hr); + + /* test overlapped pov - default value - 0xFFFFFFFF */ + hr = IDirectInputDevice8_SetDataFormat(di_keyboard, &overlapped_pov_format); + ok(SUCCEEDED(hr), "IDirectInputDevice8_SetDataFormat() failed: %08x\n", hr); + hr = IDirectInputDevice8_Acquire(di_keyboard); + ok(SUCCEEDED(hr), "IDirectInputDevice8_Acquire() failed: %08x\n", hr); + + SetFocus(hwnd); + flush_events(); + + /* press D */ + keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); + flush_events(); + + memset(&state, 0xFF, sizeof(state)); + hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(state), &state); + ok(SUCCEEDED(hr), "IDirectInputDevice_8GetDeviceState() failed: %08x\n", hr); + + ok(state.keys[0] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.keys[1] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.keys[2] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.keys[3] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.extra_element == 0, "State struct was not memset to zero\n"); + + /* release D */ + keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); + flush_events(); + + IDirectInputDevice8_Release(di_keyboard); + IDirectInput8_Release(di); + + DestroyWindow(hwnd); +} + START_TEST(device) { CoInitialize(NULL); @@ -1020,6 +1155,7 @@ START_TEST(device) test_mouse_keyboard(); test_keyboard_events(); test_appdata_property(); + test_overlapped_format();
CoUninitialize(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=94474
Your paranoid android.
=== w7u_adm (32 bit report) ===
dinput8: device: Timeout
On Windows dinput sometimes ignores injected input events. We already do similar check in test_device_input().
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/dinput8/tests/device.c | 68 ++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c index 4a6fc21ecec..fd6da6e0495 100644 --- a/dlls/dinput8/tests/device.c +++ b/dlls/dinput8/tests/device.c @@ -1058,6 +1058,8 @@ void test_overlapped_format(void) IDirectInput8A *di = NULL; IDirectInputDevice8A *di_keyboard; struct overlapped_state state; + DIPROPDWORD dp; + DWORD data_size;
hr = CoCreateInstance(&CLSID_DirectInput8, 0, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (LPVOID*)&di); if (hr == DIERR_OLDDIRECTINPUTVERSION || @@ -1083,6 +1085,14 @@ void test_overlapped_format(void) hr = IDirectInput8_CreateDevice(di, &GUID_SysKeyboard, &di_keyboard, NULL); ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
+ dp.diph.dwSize = sizeof(DIPROPDWORD); + dp.diph.dwHeaderSize = sizeof(DIPROPHEADER); + dp.diph.dwObj = 0; + dp.diph.dwHow = DIPH_DEVICE; + dp.dwData = 10; + hr = IDirectInputDevice8_SetProperty(di_keyboard, DIPROP_BUFFERSIZE, &(dp.diph)); + ok(SUCCEEDED(hr), "IDirectInputDevice8_SetProperty() failed: %08x\n", hr); + /* test overlapped slider - default value 0 */ hr = IDirectInputDevice8_SetDataFormat(di_keyboard, &overlapped_slider_format); ok(SUCCEEDED(hr), "IDirectInputDevice8_SetDataFormat() failed: %08x\n", hr); @@ -1091,20 +1101,33 @@ void test_overlapped_format(void)
SetFocus(hwnd); flush_events(); + data_size = INFINITE; + hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), NULL, &data_size, 0); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceData() failed: %08x\n", hr);
/* press D */ keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); flush_events();
- memset(&state, 0xFF, sizeof(state)); - hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(state), &state); - ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceState() failed: %08x\n", hr); + data_size = 10; + hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), NULL, &data_size, 0); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceData() failed: %08x\n", hr); + if (data_size != 1) + { + win_skip("We're not able to inject input into Windows dinput8 with events\n"); + } + else + { + memset(&state, 0xFF, sizeof(state)); + hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(state), &state); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceState() failed: %08x\n", hr);
- ok(state.keys[0] == 0x00, "key A should be still up\n"); - ok(state.keys[1] == 0x00, "key S should be still up\n"); - ok(state.keys[2] == 0x80, "keydown for D did not register\n"); - ok(state.keys[3] == 0x00, "key F should be still up\n"); - ok(state.extra_element == 0, "State struct was not memset to zero\n"); + ok(state.keys[0] == 0x00, "key A should be still up\n"); + ok(state.keys[1] == 0x00, "key S should be still up\n"); + ok(state.keys[2] == 0x80, "keydown for D did not register\n"); + ok(state.keys[3] == 0x00, "key F should be still up\n"); + ok(state.extra_element == 0, "State struct was not memset to zero\n"); + }
/* release D */ keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); @@ -1121,20 +1144,33 @@ void test_overlapped_format(void)
SetFocus(hwnd); flush_events(); + data_size = INFINITE; + hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), NULL, &data_size, 0); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceData() failed: %08x\n", hr);
/* press D */ keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); flush_events();
- memset(&state, 0xFF, sizeof(state)); - hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(state), &state); - ok(SUCCEEDED(hr), "IDirectInputDevice_8GetDeviceState() failed: %08x\n", hr); + data_size = 10; + hr = IDirectInputDevice8_GetDeviceData(di_keyboard, sizeof(DIDEVICEOBJECTDATA), NULL, &data_size, 0); + ok(SUCCEEDED(hr), "IDirectInputDevice8_GetDeviceData() failed: %08x\n", hr); + if (data_size != 1) + { + win_skip("We're not able to inject input into Windows dinput8 with events\n"); + } + else + { + memset(&state, 0xFF, sizeof(state)); + hr = IDirectInputDevice8_GetDeviceState(di_keyboard, sizeof(state), &state); + ok(SUCCEEDED(hr), "IDirectInputDevice_8GetDeviceState() failed: %08x\n", hr);
- ok(state.keys[0] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[1] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[2] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[3] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.extra_element == 0, "State struct was not memset to zero\n"); + ok(state.keys[0] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.keys[1] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.keys[2] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.keys[3] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); + ok(state.extra_element == 0, "State struct was not memset to zero\n"); + }
/* release D */ keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=94475
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
dinput8: device.c:866: Test failed: Expected 1 element, received 0 device.c:870: Test failed: Expected DIK_SPACE key state down device.c:878: Test failed: Expected 1 element, received 0 device.c:893: Test failed: Expected key 0 state down
On Windows dinput sometimes ignores injected input events.
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/dinput8/tests/device.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c index fd6da6e0495..1028e39c27c 100644 --- a/dlls/dinput8/tests/device.c +++ b/dlls/dinput8/tests/device.c @@ -127,10 +127,16 @@ static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWO
data_size = 1; hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0); - ok(hr == DI_BUFFEROVERFLOW, "GetDeviceData() failed: %08x\n", hr); - data_size = 1; - hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0); - ok(hr == DI_OK && data_size == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, data_size); + if (hr != DI_BUFFEROVERFLOW) + { + win_skip("We're not able to inject input into Windows dinput8 with events\n"); + } + else + { + data_size = 1; + hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0); + ok(hr == DI_OK && data_size == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, data_size); + }
/* drain device's queue */ while (data_size == 1)
On 7/23/21 10:37 AM, Arkadiusz Hiler wrote:
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com
dlls/dinput/tests/mouse.c | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 69051bb2a34..2d4699bb9a0 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -106,7 +106,7 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) DIMOUSESTATE m_state; HWND hwnd2; DIPROPDWORD di_op;
- DIDEVICEOBJECTDATA mouse_state;
- DIDEVICEOBJECTDATA mouse_state[30]; DWORD cnt; int i;
@@ -159,16 +159,20 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) ok(hr == S_OK, "Acquire() failed: %08x\n", hr);
mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
- cnt = ARRAY_SIZE(mouse_state);
- mouse_state[0].dwTimeStamp = 0xdeadbeef;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
- todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
"GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
Any reason not to make this three separate ok calls?
mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); hr = IDirectInputDevice_Unacquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
cnt = ARRAY_SIZE(mouse_state);
mouse_state[0].dwTimeStamp = 0xdeadbeef;
hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
"GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp); hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr);
@@ -178,20 +182,26 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
cnt = ARRAY_SIZE(mouse_state);
mouse_state[0].dwTimeStamp = 0xdeadbeef;
hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
"GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp); /* Check for buffer overflow */ for (i = 0; i < 6; i++) mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == DI_OK, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
- cnt = 1;
- hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
- ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
cnt = ARRAY_SIZE(mouse_state);
mouse_state[0].dwTimeStamp = 0xdeadbeef;
hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
"GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
cnt = ARRAY_SIZE(mouse_state);
mouse_state[0].dwTimeStamp = 0xdeadbeef;
hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
"GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp); /* Check for granularity property using BYOFFSET */ memset(&di_op, 0, sizeof(di_op));