mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[DINPUT_WINETEST] Sync with Wine Staging 4.18. CORE-16441
This commit is contained in:
parent
41c8c312e1
commit
8de4fae42b
4 changed files with 223 additions and 39 deletions
|
@ -269,23 +269,19 @@ static void test_QueryInterface(void)
|
|||
&IID_IDirectInput2A, &IID_IDirectInput2W,
|
||||
&IID_IDirectInput7A, &IID_IDirectInput7W};
|
||||
|
||||
static const struct
|
||||
static REFIID no_interface_list[] =
|
||||
{
|
||||
REFIID riid;
|
||||
int test_todo;
|
||||
} no_interface_list[] =
|
||||
{
|
||||
{&IID_IDirectInput8A, 1},
|
||||
{&IID_IDirectInput8W, 1},
|
||||
{&IID_IDirectInputDeviceA},
|
||||
{&IID_IDirectInputDeviceW},
|
||||
{&IID_IDirectInputDevice2A},
|
||||
{&IID_IDirectInputDevice2W},
|
||||
{&IID_IDirectInputDevice7A},
|
||||
{&IID_IDirectInputDevice7W},
|
||||
{&IID_IDirectInputDevice8A},
|
||||
{&IID_IDirectInputDevice8W},
|
||||
{&IID_IDirectInputEffect},
|
||||
&IID_IDirectInput8A,
|
||||
&IID_IDirectInput8W,
|
||||
&IID_IDirectInputDeviceA,
|
||||
&IID_IDirectInputDeviceW,
|
||||
&IID_IDirectInputDevice2A,
|
||||
&IID_IDirectInputDevice2W,
|
||||
&IID_IDirectInputDevice7A,
|
||||
&IID_IDirectInputDevice7W,
|
||||
&IID_IDirectInputDevice8A,
|
||||
&IID_IDirectInputDevice8W,
|
||||
&IID_IDirectInputEffect,
|
||||
};
|
||||
|
||||
IDirectInputA *pDI;
|
||||
|
@ -323,22 +319,10 @@ static void test_QueryInterface(void)
|
|||
for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
|
||||
{
|
||||
pUnk = (void *)0xdeadbeef;
|
||||
hr = IDirectInput_QueryInterface(pDI, no_interface_list[i].riid, (void **)&pUnk);
|
||||
if (no_interface_list[i].test_todo)
|
||||
{
|
||||
todo_wine
|
||||
ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr);
|
||||
todo_wine
|
||||
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
|
||||
|
||||
if (pUnk) IUnknown_Release(pUnk);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = IDirectInput_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk);
|
||||
ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr);
|
||||
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectInput_Release(pDI);
|
||||
}
|
||||
|
@ -402,6 +386,30 @@ static BOOL CALLBACK enum_devices_callback(const DIDEVICEINSTANCEA *instance, vo
|
|||
wine_dbgstr_guid(&instance->guidProduct));
|
||||
}
|
||||
|
||||
if ((instance->dwDevType & 0xff) == DIDEVTYPE_KEYBOARD)
|
||||
ok(IsEqualGUID(&instance->guidProduct, &GUID_SysKeyboard),
|
||||
"Keyboard guidProduct (%s) does not match GUID_SysKeyboard (%s)\n",
|
||||
wine_dbgstr_guid(&instance->guidProduct),
|
||||
wine_dbgstr_guid(&GUID_SysMouse));
|
||||
else if ((instance->dwDevType & 0xff) == DIDEVTYPE_MOUSE)
|
||||
ok(IsEqualGUID(&instance->guidProduct, &GUID_SysMouse),
|
||||
"Mouse guidProduct (%s) does not match GUID_SysMouse (%s)\n",
|
||||
wine_dbgstr_guid(&instance->guidProduct),
|
||||
wine_dbgstr_guid(&GUID_SysMouse));
|
||||
else {
|
||||
/* Non-keyboard/mouse devices use the "PIDVID" guidProduct */
|
||||
static const GUID pidvid_product_guid = { /* device_pidvid-0000-0000-0000-504944564944 "PIDVID" */
|
||||
0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44}
|
||||
};
|
||||
|
||||
ok(instance->guidProduct.Data2 == pidvid_product_guid.Data2,
|
||||
"guidProduct.Data2 is %04x\n", instance->guidProduct.Data2);
|
||||
ok(instance->guidProduct.Data3 == pidvid_product_guid.Data3,
|
||||
"guidProduct.Data3 is %04x\n", instance->guidProduct.Data3);
|
||||
ok(!memcmp(instance->guidProduct.Data4, pidvid_product_guid.Data4, sizeof(pidvid_product_guid.Data4)),
|
||||
"guidProduct.Data4 does not match: %s\n", wine_dbgstr_guid(&instance->guidProduct));
|
||||
}
|
||||
|
||||
enum_test->device_count++;
|
||||
return enum_test->return_value;
|
||||
}
|
||||
|
@ -604,10 +612,14 @@ static void test_DirectInputJoyConfig8(void)
|
|||
"IDirectInputJoyConfig8_GetConfig returned 0x%08x\n", hr);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
ok (SUCCEEDED(IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL)),
|
||||
"IDirectInput_CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr);
|
||||
{
|
||||
hr = IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL);
|
||||
ok (SUCCEEDED(hr), "IDirectInput_CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr);
|
||||
IDirectInputDevice_Release(pDID);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectInputJoyConfig8_Release(pDIJC);
|
||||
IDirectInput_Release(pDI);
|
||||
}
|
||||
|
||||
|
|
|
@ -270,6 +270,29 @@ static const HRESULT SetCoop_real_window[16] = {
|
|||
E_INVALIDARG, S_OK, S_OK, E_INVALIDARG,
|
||||
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
|
||||
|
||||
static BOOL CALLBACK EnumAllFeedback(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
|
||||
{
|
||||
trace("---- Device Information ----\n"
|
||||
"Product Name : %s\n"
|
||||
"Instance Name : %s\n"
|
||||
"devType : 0x%08x\n"
|
||||
"GUID Product : %s\n"
|
||||
"GUID Instance : %s\n"
|
||||
"HID Page : 0x%04x\n"
|
||||
"HID Usage : 0x%04x\n",
|
||||
lpddi->tszProductName,
|
||||
lpddi->tszInstanceName,
|
||||
lpddi->dwDevType,
|
||||
wine_dbgstr_guid(&lpddi->guidProduct),
|
||||
wine_dbgstr_guid(&lpddi->guidInstance),
|
||||
lpddi->wUsagePage,
|
||||
lpddi->wUsage);
|
||||
|
||||
ok(!(IsEqualGUID(&GUID_SysMouse, &lpddi->guidProduct) || IsEqualGUID(&GUID_SysKeyboard, &lpddi->guidProduct)), "Invalid device returned.\n");
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -298,7 +321,7 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
|
|||
DIPROPDWORD dip_gain_set, dip_gain_get;
|
||||
struct effect_enum effect_data;
|
||||
|
||||
ok(data->version > 0x0300, "Joysticks not supported in version 0x%04x\n", data->version);
|
||||
ok(data->version >= 0x0300, "Joysticks not supported in version 0x%04x\n", data->version);
|
||||
|
||||
hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, NULL, NULL);
|
||||
ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned "
|
||||
|
@ -379,7 +402,23 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
|
|||
dpg.diph.dwHow = DIPH_DEVICE;
|
||||
|
||||
hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_GUIDANDPATH, &dpg.diph);
|
||||
todo_wine ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_GUIDANDPATH failed: %08x\n", hr);
|
||||
ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_GUIDANDPATH failed: %08x\n", hr);
|
||||
|
||||
{
|
||||
static const WCHAR formatW[] = {'\\','\\','?','\\','%','*','[','^','#',']','#','v','i','d','_',
|
||||
'%','0','4','x','&','p','i','d','_','%','0','4','x',0};
|
||||
static const WCHAR miW[] = {'m','i','_',0};
|
||||
static const WCHAR igW[] = {'i','g','_',0};
|
||||
int vid, pid;
|
||||
|
||||
_wcslwr(dpg.wszPath);
|
||||
count = swscanf(dpg.wszPath, formatW, &vid, &pid);
|
||||
ok(count == 2, "DIPROP_GUIDANDPATH path has wrong format. Expected count: 2 Got: %i Path: %s\n",
|
||||
count, wine_dbgstr_w(dpg.wszPath));
|
||||
ok(wcsstr(dpg.wszPath, miW) != 0 || wcsstr(dpg.wszPath, igW) != 0,
|
||||
"DIPROP_GUIDANDPATH path should contain either 'ig_' or 'mi_' substring. Path: %s\n",
|
||||
wine_dbgstr_w(dpg.wszPath));
|
||||
}
|
||||
|
||||
hr = IDirectInputDevice_SetDataFormat(pJoystick, NULL);
|
||||
ok(hr==E_POINTER,"IDirectInputDevice_SetDataFormat() should have returned "
|
||||
|
@ -870,6 +909,24 @@ static void joystick_tests(DWORD version)
|
|||
trace(" Version Not Supported\n");
|
||||
}
|
||||
|
||||
static void test_enum_feedback(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirectInputA *pDI;
|
||||
ULONG ref;
|
||||
HINSTANCE hInstance = GetModuleHandleW(NULL);
|
||||
|
||||
hr = DirectInputCreateA(hInstance, 0x0700, &pDI, NULL);
|
||||
ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateA() failed: %08x\n", hr);
|
||||
if (hr==DI_OK && pDI!=0) {
|
||||
hr = IDirectInput_EnumDevices(pDI, 0, EnumAllFeedback, NULL, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK);
|
||||
ok(hr==DI_OK,"IDirectInput_EnumDevices() failed: %08x\n", hr);
|
||||
ref = IDirectInput_Release(pDI);
|
||||
ok(ref==0,"IDirectInput_Release() reference count = %d\n", ref);
|
||||
} else if (hr==DIERR_OLDDIRECTINPUTVERSION)
|
||||
trace(" Version Not Supported\n");
|
||||
}
|
||||
|
||||
START_TEST(joystick)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
|
@ -878,5 +935,7 @@ START_TEST(joystick)
|
|||
joystick_tests(0x0500);
|
||||
joystick_tests(0x0300);
|
||||
|
||||
test_enum_feedback();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ static void acquire_tests(IDirectInputA *pDI, HWND hwnd)
|
|||
};
|
||||
DIDATAFORMAT df;
|
||||
HKL hkl, hkl_orig;
|
||||
UINT prev_raw_devices_count, raw_devices_count;
|
||||
|
||||
hkl = activate_keyboard_layout(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), &hkl_orig);
|
||||
if (!hkl) return;
|
||||
|
@ -165,6 +166,22 @@ static void acquire_tests(IDirectInputA *pDI, HWND hwnd)
|
|||
}
|
||||
keybd_event('Q', 0, KEYEVENTF_KEYUP, 0);
|
||||
|
||||
prev_raw_devices_count = 0;
|
||||
GetRegisteredRawInputDevices(NULL, &prev_raw_devices_count, sizeof(RAWINPUTDEVICE));
|
||||
ok(prev_raw_devices_count == 0 || broken(prev_raw_devices_count == 1) /* wxppro, w2003std */,
|
||||
"Unexpected raw devices registered: %d\n", prev_raw_devices_count);
|
||||
|
||||
hr = IDirectInputDevice_Acquire(pKeyboard);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr);
|
||||
|
||||
raw_devices_count = 0;
|
||||
GetRegisteredRawInputDevices(NULL, &raw_devices_count, sizeof(RAWINPUTDEVICE));
|
||||
ok(raw_devices_count == prev_raw_devices_count,
|
||||
"Unexpected raw devices registered: %d\n", raw_devices_count);
|
||||
|
||||
hr = IDirectInputDevice_Unacquire(pKeyboard);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %08x\n", hr);
|
||||
|
||||
if (pKeyboard) IUnknown_Release(pKeyboard);
|
||||
|
||||
ActivateKeyboardLayout(hkl_orig, 0);
|
||||
|
@ -453,6 +470,35 @@ fail:
|
|||
IUnknown_Release(device);
|
||||
}
|
||||
|
||||
static void test_GetDeviceInfo(IDirectInputA *pDI)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirectInputDeviceA *pKey = NULL;
|
||||
DIDEVICEINSTANCEA instA;
|
||||
DIDEVICEINSTANCE_DX3A inst3A;
|
||||
|
||||
hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKey, NULL);
|
||||
ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
instA.dwSize = sizeof(instA);
|
||||
hr = IDirectInputDevice_GetDeviceInfo(pKey, &instA);
|
||||
ok(SUCCEEDED(hr), "got %08x\n", hr);
|
||||
|
||||
inst3A.dwSize = sizeof(inst3A);
|
||||
hr = IDirectInputDevice_GetDeviceInfo(pKey, (DIDEVICEINSTANCEA *)&inst3A);
|
||||
ok(SUCCEEDED(hr), "got %08x\n", hr);
|
||||
|
||||
ok(instA.dwSize != inst3A.dwSize, "got %d, %d \n", instA.dwSize, inst3A.dwSize);
|
||||
ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n",
|
||||
wine_dbgstr_guid(&instA.guidInstance), wine_dbgstr_guid(&inst3A.guidInstance) );
|
||||
ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n",
|
||||
wine_dbgstr_guid(&instA.guidProduct), wine_dbgstr_guid(&inst3A.guidProduct) );
|
||||
ok(instA.dwDevType == inst3A.dwDevType, "got %d, %d\n", instA.dwDevType, inst3A.dwDevType);
|
||||
|
||||
IUnknown_Release(pKey);
|
||||
}
|
||||
|
||||
static void keyboard_tests(DWORD version)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -483,6 +529,7 @@ static void keyboard_tests(DWORD version)
|
|||
test_set_coop(pDI, hwnd);
|
||||
test_get_prop(pDI, hwnd);
|
||||
test_capabilities(pDI, hwnd);
|
||||
test_GetDeviceInfo(pDI);
|
||||
|
||||
test_dik_codes(pDI, hwnd, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT));
|
||||
test_dik_codes(pDI, hwnd, MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH));
|
||||
|
|
|
@ -152,15 +152,20 @@ else {
|
|||
ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
|
||||
|
||||
mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
|
||||
IDirectInputDevice_Unacquire(pMouse);
|
||||
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);
|
||||
|
||||
IDirectInputDevice_Acquire(pMouse);
|
||||
hr = IDirectInputDevice_Acquire(pMouse);
|
||||
ok(hr == S_OK, "Failed: %08x\n", hr);
|
||||
mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
|
||||
IDirectInputDevice_Unacquire(pMouse);
|
||||
IDirectInputDevice_Acquire(pMouse);
|
||||
hr = IDirectInputDevice_Unacquire(pMouse);
|
||||
ok(hr == S_OK, "Failed: %08x\n", hr);
|
||||
|
||||
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);
|
||||
|
@ -202,6 +207,65 @@ else {
|
|||
DestroyWindow( hwnd2 );
|
||||
}
|
||||
|
||||
static void test_GetDeviceInfo(IDirectInputA *pDI)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirectInputDeviceA *pMouse = NULL;
|
||||
DIDEVICEINSTANCEA instA;
|
||||
DIDEVICEINSTANCE_DX3A inst3A;
|
||||
|
||||
hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
|
||||
ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
instA.dwSize = sizeof(instA);
|
||||
hr = IDirectInputDevice_GetDeviceInfo(pMouse, &instA);
|
||||
ok(SUCCEEDED(hr), "got %08x\n", hr);
|
||||
|
||||
inst3A.dwSize = sizeof(inst3A);
|
||||
hr = IDirectInputDevice_GetDeviceInfo(pMouse, (DIDEVICEINSTANCEA *)&inst3A);
|
||||
ok(SUCCEEDED(hr), "got %08x\n", hr);
|
||||
|
||||
ok(instA.dwSize != inst3A.dwSize, "got %d, %d \n", instA.dwSize, inst3A.dwSize);
|
||||
ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n",
|
||||
wine_dbgstr_guid(&instA.guidInstance), wine_dbgstr_guid(&inst3A.guidInstance) );
|
||||
ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n",
|
||||
wine_dbgstr_guid(&instA.guidProduct), wine_dbgstr_guid(&inst3A.guidProduct) );
|
||||
ok(instA.dwDevType == inst3A.dwDevType, "got %d, %d\n", instA.dwDevType, inst3A.dwDevType);
|
||||
|
||||
IUnknown_Release(pMouse);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK EnumAxes(const DIDEVICEOBJECTINSTANCEA *pdidoi, void *pContext)
|
||||
{
|
||||
if (IsEqualIID(&pdidoi->guidType, &GUID_XAxis) ||
|
||||
IsEqualIID(&pdidoi->guidType, &GUID_YAxis) ||
|
||||
IsEqualIID(&pdidoi->guidType, &GUID_ZAxis))
|
||||
{
|
||||
ok(pdidoi->dwFlags & DIDOI_ASPECTPOSITION, "Missing DIDOI_ASPECTPOSITION, flags are 0x%x\n",
|
||||
pdidoi->dwFlags);
|
||||
}
|
||||
else
|
||||
ok(pdidoi->dwFlags == 0, "Flags are 0x%x\n", pdidoi->dwFlags);
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
static void test_mouse_EnumObjects(IDirectInputA *pDI)
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirectInputDeviceA *pMouse = NULL;
|
||||
|
||||
hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
|
||||
ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
hr = IDirectInputDevice_EnumObjects(pMouse, EnumAxes, NULL, DIDFT_ALL);
|
||||
ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %08x\n", hr);
|
||||
|
||||
if (pMouse) IUnknown_Release(pMouse);
|
||||
}
|
||||
|
||||
static void mouse_tests(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -228,6 +292,8 @@ static void mouse_tests(void)
|
|||
|
||||
test_set_coop(pDI, hwnd);
|
||||
test_acquire(pDI, hwnd);
|
||||
test_GetDeviceInfo(pDI);
|
||||
test_mouse_EnumObjects(pDI);
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue