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

Wine Cross Reference
wine/dlls/dinput8/dinput8_main.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ 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 ] ~

  1 /* DirectInput 8
  2  *
  3  * Copyright 2002 TransGaming Technologies Inc.
  4  * Copyright 2006 Roderick Colenbrander
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 #include <assert.h>
 23 #include <stdarg.h>
 24 #include <string.h>
 25 
 26 #define COBJMACROS
 27 
 28 #include "wine/debug.h"
 29 #include "windef.h"
 30 #include "winbase.h"
 31 #include "winerror.h"
 32 #include "objbase.h"
 33 #include "rpcproxy.h"
 34 #include "dinput.h"
 35 
 36 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 37 
 38 static HINSTANCE instance;
 39 static LONG dll_count;
 40 
 41 /*
 42  * Dll lifetime tracking declaration
 43  */
 44 static void LockModule(void)
 45 {
 46     InterlockedIncrement(&dll_count);
 47 }
 48 
 49 static void UnlockModule(void)
 50 {
 51     InterlockedDecrement(&dll_count);
 52 }
 53 
 54 /******************************************************************************
 55  *      DirectInput8Create (DINPUT8.@)
 56  */
 57 HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter) {
 58     HRESULT hr, hrCo;
 59 
 60     TRACE("hInst (%p), dwVersion: %d, riid (%s), punkOuter (%p))\n", hinst, dwVersion, debugstr_guid(riid), punkOuter);
 61 
 62     /* The specified version needs to be dinput8 (0x800) or higher */
 63     if(dwVersion < 0x800)
 64         return DIERR_OLDDIRECTINPUTVERSION;
 65 
 66     if( !(IsEqualGUID(&IID_IDirectInput8A, riid) || IsEqualGUID(&IID_IDirectInput8W, riid) || IsEqualGUID(&IID_IUnknown, riid)) )
 67         return DIERR_INVALIDPARAM;
 68 
 69     hrCo = CoInitialize(NULL);
 70     
 71     hr = CoCreateInstance( &CLSID_DirectInput8, punkOuter, CLSCTX_INPROC_SERVER, riid, ppDI);
 72     if(FAILED(hr)) {
 73         ERR("CoCreateInstance failed with hr = %d\n", hr);
 74         return DIERR_INVALIDPARAM;
 75     }
 76 
 77     /*  ensure balance of calls */
 78     if(hrCo == S_OK || hrCo == S_FALSE)
 79         CoUninitialize();
 80 
 81     /* When aggregation is used (punkOuter!=NULL) the application needs to manually call Initialize. */
 82     if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8A, riid)) {
 83         LPDIRECTINPUTA DI = *ppDI;
 84         IDirectInput8_Initialize(DI, hinst, dwVersion);
 85     }
 86 
 87     if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8W, riid)) {
 88         LPDIRECTINPUTW DI = *ppDI;
 89         IDirectInput8_Initialize(DI, hinst, dwVersion);
 90     }
 91 
 92     return S_OK;
 93 }
 94 
 95 /*******************************************************************************
 96  * DirectInput8 ClassFactory
 97  */
 98 typedef struct
 99 {
100     /* IUnknown fields */
101     IClassFactory IClassFactory_iface;
102 } IClassFactoryImpl;
103 
104 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
105 {
106     return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
107 }
108 
109 static HRESULT WINAPI DI8CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
110     IClassFactoryImpl *This = impl_from_IClassFactory(iface);
111     FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
112     return E_NOINTERFACE;
113 }
114 
115 static ULONG WINAPI DI8CF_AddRef(LPCLASSFACTORY iface) {
116     LockModule();
117     return 2;
118 }
119 
120 static ULONG WINAPI DI8CF_Release(LPCLASSFACTORY iface) {
121     UnlockModule();
122     return 1;
123 }
124 
125 static HRESULT WINAPI DI8CF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
126     IClassFactoryImpl *This = impl_from_IClassFactory(iface);
127 
128     TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
129     if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) || IsEqualGUID( &IID_IUnknown, riid )) {
130         return DirectInputCreateEx(0, DIRECTINPUT_VERSION, riid, ppobj, pOuter);
131     }
132 
133     ERR("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);    
134     return E_NOINTERFACE;
135 }
136 
137 static HRESULT WINAPI DI8CF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
138     TRACE("(%p)->(%d)\n", iface, dolock);
139 
140     if(dolock)
141         LockModule();
142     else
143         UnlockModule();
144 
145     return S_OK;
146 }
147 
148 static const IClassFactoryVtbl DI8CF_Vtbl = {
149     DI8CF_QueryInterface,
150     DI8CF_AddRef,
151     DI8CF_Release,
152     DI8CF_CreateInstance,
153     DI8CF_LockServer
154 };
155 static IClassFactoryImpl DINPUT8_CF = { { &DI8CF_Vtbl } };
156 
157 
158 /***********************************************************************
159  *              DllCanUnloadNow (DINPUT8.@)
160  */
161 HRESULT WINAPI DllCanUnloadNow(void)
162 {
163     return dll_count == 0 ? S_OK : S_FALSE;
164 }
165 
166 /***********************************************************************
167  *              DllGetClassObject (DINPUT8.@)
168  */
169 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
170 {
171     TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
172     if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
173         *ppv = &DINPUT8_CF;
174         IClassFactory_AddRef((IClassFactory*)*ppv);
175         return S_OK;
176     }
177 
178     FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
179     return CLASS_E_CLASSNOTAVAILABLE;
180 }
181 
182 /***********************************************************************
183  *              DllMain
184  */
185 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID lpv)
186 {
187     switch (reason)
188     {
189     case DLL_PROCESS_ATTACH:
190         instance = hInstDLL;
191         DisableThreadLibraryCalls( hInstDLL );
192         break;
193     }
194     return TRUE;
195 }
196 
197 /***********************************************************************
198  *              DllRegisterServer (DINPUT8.@)
199  */
200 HRESULT WINAPI DllRegisterServer(void)
201 {
202     return __wine_register_resources( instance, NULL );
203 }
204 
205 /***********************************************************************
206  *              DllUnregisterServer (DINPUT8.@)
207  */
208 HRESULT WINAPI DllUnregisterServer(void)
209 {
210     return __wine_unregister_resources( instance, NULL );
211 }
212 

~ [ 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.