From dbc10ef93756954a8fc218c77f1ec3d26565ee3b Mon Sep 17 00:00:00 2001 From: Lucas Zawacki Date: Mon, 13 Aug 2012 20:36:55 -0300 Subject: [PATCH] dinput/tests: Tests for IDirectInputJoyConfig8_GetConfig. --- dlls/dinput/tests/dinput.c | 44 ++++++++++++++++++++++++++++++++++++++ include/dinputd.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 1cdc90bf9fa..c5386d6ccfc 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "wine/test.h" @@ -562,6 +563,48 @@ static void test_RunControlPanel(void) IDirectInput_Release(pDI); } +static void test_DirectInputJoyConfig8(void) +{ + IDirectInputA *pDI; + IDirectInputDeviceA *pDID; + IDirectInputJoyConfig8 *pDIJC; + DIJOYCONFIG info; + HRESULT hr; + int i; + + hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); + if (FAILED(hr)) + { + win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); + return; + } + + hr = IDirectInput_QueryInterface(pDI, &IID_IDirectInputJoyConfig8, (void **)&pDIJC); + if (FAILED(hr)) + { + win_skip("Failed to instantiate a IDirectInputJoyConfig8 instance: 0x%08x\n", hr); + return; + } + + info.dwSize = sizeof(info); + hr = DI_OK; + i = 0; + + /* Enumerate all connected joystick GUIDs and try to create the respective devices */ + for (i = 0; SUCCEEDED(hr); i++) + { + hr = IDirectInputJoyConfig8_GetConfig(pDIJC, i, &info, DIJC_GUIDINSTANCE); + + todo_wine ok (hr == DI_OK || hr == DIERR_NOMOREITEMS, + "IDirectInputJoyConfig8_GetConfig returned 0x%08x\n", hr); + + if (SUCCEEDED(hr)) + todo_wine ok (SUCCEEDED(IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL)), + "IDirectInput_CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr); + } + +} + START_TEST(dinput) { HMODULE dinput_mod = GetModuleHandleA("dinput.dll"); @@ -579,5 +622,6 @@ START_TEST(dinput) test_GetDeviceStatus(); test_Initialize(); test_RunControlPanel(); + test_DirectInputJoyConfig8(); CoUninitialize(); } diff --git a/include/dinputd.h b/include/dinputd.h index ac24a2c56b1..9c3b435cc6c 100644 --- a/include/dinputd.h +++ b/include/dinputd.h @@ -44,6 +44,8 @@ typedef BOOL (CALLBACK *LPDIJOYTYPECALLBACK)(LPCWSTR, LPVOID); #define JOY_POVVAL_LEFT 2 #define JOY_POVVAL_RIGHT 3 +#define DIERR_NOMOREITEMS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NO_MORE_ITEMS) + typedef struct joypos_tag { DWORD dwX;