Update the address of the Free Software Foundation.
[wine/testsucceed.git] / dlls / dinput8 / dinput8_main.c
blob54ea66eda1b25b72e98a7bc70f9ab211d5c705f3
1 /* DirectInput 8
3 * Copyright 2002 TransGaming Technologies Inc.
4 * Copyright 2006 Roderick Colenbrander
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.
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.
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
21 #include "config.h"
22 #include <assert.h>
23 #include <stdarg.h>
24 #include <string.h>
26 #define COBJMACROS
28 #include "wine/debug.h"
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winerror.h"
32 #include "dinput.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
35 static LONG dll_count;
38 * Dll lifetime tracking declaration
40 static void LockModule(void)
42 InterlockedIncrement(&dll_count);
45 static void UnlockModule(void)
47 InterlockedDecrement(&dll_count);
50 /******************************************************************************
51 * DirectInput8Create (DINPUT8.@)
53 HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter) {
54 /* TODO: Create the interface using CoCreateInstance as that's what windows does too and check if the version number >= 0x800 */
55 return DirectInputCreateEx(hinst, dwVersion, riid, ppDI, punkOuter);
58 /*******************************************************************************
59 * DirectInput8 ClassFactory
61 typedef struct
63 /* IUnknown fields */
64 const IClassFactoryVtbl *lpVtbl;
65 } IClassFactoryImpl;
67 static HRESULT WINAPI DI8CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
68 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
69 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
70 return E_NOINTERFACE;
73 static ULONG WINAPI DI8CF_AddRef(LPCLASSFACTORY iface) {
74 LockModule();
75 return 2;
78 static ULONG WINAPI DI8CF_Release(LPCLASSFACTORY iface) {
79 UnlockModule();
80 return 1;
83 static HRESULT WINAPI DI8CF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
84 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
86 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
87 if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
88 return DirectInput8Create(0, DIRECTINPUT_VERSION, riid, ppobj, pOuter);
91 ERR("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
92 return E_NOINTERFACE;
95 static HRESULT WINAPI DI8CF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
96 TRACE("(%p)->(%d)\n", iface, dolock);
98 if(dolock)
99 LockModule();
100 else
101 UnlockModule();
103 return S_OK;
106 static const IClassFactoryVtbl DI8CF_Vtbl = {
107 DI8CF_QueryInterface,
108 DI8CF_AddRef,
109 DI8CF_Release,
110 DI8CF_CreateInstance,
111 DI8CF_LockServer
113 static IClassFactoryImpl DINPUT8_CF = { &DI8CF_Vtbl };
116 /***********************************************************************
117 * DllCanUnloadNow (DINPUT8.@)
119 HRESULT WINAPI DllCanUnloadNow(void)
121 return dll_count == 0 ? S_OK : S_FALSE;
124 /***********************************************************************
125 * DllGetClassObject (DINPUT8.@)
127 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
129 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
130 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
131 *ppv = (LPVOID)&DINPUT8_CF;
132 IClassFactory_AddRef((IClassFactory*)*ppv);
133 return S_OK;
136 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
137 return CLASS_E_CLASSNOTAVAILABLE;
140 /***********************************************************************
141 * DllRegisterServer (DINPUT8.@)
143 HRESULT WINAPI DllRegisterServer(void)
145 FIXME("(void): stub\n");
147 return S_OK;
150 /***********************************************************************
151 * DllUnregisterServer (DINPUT8.@)
153 HRESULT WINAPI DllUnregisterServer(void)
155 FIXME("(void): stub\n");
157 return S_OK;