~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/dinput/tests/mouse.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Copyright (c) 2005 Robert Reif
  3  * Copyright (c) 2006 Vitaliy Margolen
  4  *
  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.
  9  *
 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.
 14  *
 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
 18  */
 19 
 20 #define DIRECTINPUT_VERSION 0x0700
 21 
 22 #define COBJMACROS
 23 #include <windows.h>
 24 
 25 #include <math.h>
 26 #include <stdlib.h>
 27 
 28 #include "wine/test.h"
 29 #include "windef.h"
 30 #include "wingdi.h"
 31 #include "dinput.h"
 32 #include "dinput_test.h"
 33 
 34 static const HRESULT SetCoop_null_window[16] =  {
 35     E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
 36     E_INVALIDARG, E_HANDLE,     E_HANDLE,     E_INVALIDARG,
 37     E_INVALIDARG, E_HANDLE,     S_OK,         E_INVALIDARG,
 38     E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
 39 
 40 static const HRESULT SetCoop_real_window[16] =  {
 41     E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
 42     E_INVALIDARG, S_OK,         S_OK,         E_INVALIDARG,
 43     E_INVALIDARG, E_NOTIMPL,    S_OK,         E_INVALIDARG,
 44     E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
 45 
 46 static void test_set_coop(LPDIRECTINPUT pDI, HWND hwnd)
 47 {
 48     HRESULT hr;
 49     LPDIRECTINPUTDEVICE pMouse = NULL;
 50     int i;
 51 
 52     hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
 53     ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
 54     if (FAILED(hr)) return;
 55 
 56     for (i=0; i<16; i++)
 57     {
 58         hr = IDirectInputDevice_SetCooperativeLevel(pMouse, NULL, i);
 59         ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %08x\n", i, hr);
 60     }
 61     for (i=0; i<16; i++)
 62     {
 63         hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, i);
 64         ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr);
 65     }
 66 
 67     if (pMouse) IUnknown_Release(pMouse);
 68 }
 69 
 70 static void test_acquire(LPDIRECTINPUT pDI, HWND hwnd)
 71 {
 72     HRESULT hr;
 73     LPDIRECTINPUTDEVICE pMouse = NULL;
 74     DIMOUSESTATE m_state;
 75 
 76     hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
 77     ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %08x\n", hr);
 78     if (FAILED(hr)) return;
 79 
 80     hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
 81     ok(hr == S_OK, "SetCooperativeLevel: %08x\n", hr);
 82 
 83     hr = IDirectInputDevice_SetDataFormat(pMouse, &c_dfDIMouse);
 84     ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %08x\n", hr);
 85     hr = IDirectInputDevice_Unacquire(pMouse);
 86     ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have failed: %08x\n", hr);
 87     hr = IDirectInputDevice_Acquire(pMouse);
 88     ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %08x\n", hr);
 89     hr = IDirectInputDevice_Acquire(pMouse);
 90     ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have failed: %08x\n", hr);
 91 
 92     /* Foreground coop level requires window to have focus */
 93     /* This should make dinput loose mouse input */
 94     SetActiveWindow( 0 );
 95 
 96     hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state);
 97     ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %08x\n", hr);
 98     /* Workaround so we can test other things. Remove when Wine is fixed */
 99     IDirectInputDevice_Unacquire(pMouse);
100 
101     hr = IDirectInputDevice_Acquire(pMouse);
102     ok(hr == DIERR_OTHERAPPHASPRIO, "Acquire() should have failed: %08x\n", hr);
103 
104     SetActiveWindow( hwnd );
105     hr = IDirectInputDevice_Acquire(pMouse);
106     ok(hr == S_OK, "Acquire() failed: %08x\n", hr);
107 
108     if (pMouse) IUnknown_Release(pMouse);
109 }
110 
111 static void mouse_tests(void)
112 {
113     HRESULT hr;
114     LPDIRECTINPUT pDI = NULL;
115     HINSTANCE hInstance = GetModuleHandle(NULL);
116     HWND hwnd;
117     ULONG ref = 0;
118 
119     hr = DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &pDI, NULL);
120     if (hr == DIERR_OLDDIRECTINPUTVERSION)
121     {
122         skip("Tests require a newer dinput version\n");
123         return;
124     }
125     ok(SUCCEEDED(hr), "DirectInputCreate() failed: %08x\n", hr);
126     if (FAILED(hr)) return;
127 
128     hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW,
129                         10, 10, 200, 200, NULL, NULL, NULL, NULL);
130     ok(hwnd != NULL, "err: %d\n", GetLastError());
131     if (hwnd)
132     {
133         ShowWindow(hwnd, SW_SHOW);
134 
135         test_set_coop(pDI, hwnd);
136         test_acquire(pDI, hwnd);
137 
138         DestroyWindow(hwnd);
139     }
140     if (pDI) ref = IUnknown_Release(pDI);
141     ok(!ref, "IDirectInput_Release() reference count = %d\n", ref);
142 }
143 
144 START_TEST(mouse)
145 {
146     CoInitialize(NULL);
147 
148     trace("DLL Version: %s\n", get_file_version("dinput.dll"));
149 
150     mouse_tests();
151 
152     CoUninitialize();
153 }
154 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.