2 * Copyright (c) 2005 Robert Reif
3 * Copyright (c) 2006 Vitaliy Margolen
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define DIRECTINPUT_VERSION 0x0700
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
30 #include "wine/test.h"
35 #include "dinput_test.h"
37 static const HRESULT SetCoop_null_window[16] = {
38 E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
39 E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
40 E_INVALIDARG, E_HANDLE, S_OK, E_INVALIDARG,
41 E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
43 static const HRESULT SetCoop_real_window[16] = {
44 E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
45 E_INVALIDARG, S_OK, S_OK, E_INVALIDARG,
46 E_INVALIDARG, E_NOTIMPL, S_OK, E_INVALIDARG,
47 E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
49 static void test_set_coop(LPDIRECTINPUT pDI, HWND hwnd)
52 LPDIRECTINPUTDEVICE pMouse = NULL;
55 hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
56 ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %s\n", DXGetErrorString8(hr));
57 if (FAILED(hr)) return;
61 hr = IDirectInputDevice_SetCooperativeLevel(pMouse, NULL, i);
62 ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %s\n", i, DXGetErrorString8(hr));
66 hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, i);
67 ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %s\n", i, DXGetErrorString8(hr));
70 if (pMouse) IUnknown_Release(pMouse);
73 static void mouse_tests(void)
76 LPDIRECTINPUT pDI = NULL;
77 HINSTANCE hInstance = GetModuleHandle(NULL);
80 hr = DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &pDI, NULL);
81 ok(SUCCEEDED(hr), "DirectInputCreate() failed: %s\n", DXGetErrorString8(hr));
82 if (FAILED(hr)) return;
84 hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW,
85 10, 10, 200, 200, NULL, NULL, NULL, NULL);
86 ok(hwnd != NULL, "err: %d\n", GetLastError());
89 ShowWindow(hwnd, SW_SHOW);
91 test_set_coop(pDI, hwnd);
94 if (pDI) IUnknown_Release(pDI);
101 trace("DLL Version: %s\n", get_file_version("dinput.dll"));