usp10: Handle Ligature Substitution Subtable from GSUB.
[wine/testsucceed.git] / dlls / dinput8 / dinput8_main.c
blob87dd07bf3a3c16cdc5d2eb17c25b2a24fa48e79e
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 DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter) {
54 HRESULT hr, hrCo;
56 TRACE("hInst (%p), dwVersion: %d, riid (%s), punkOuter (%p))\n", hinst, dwVersion, debugstr_guid(riid), punkOuter);
58 /* The specified version needs to be dinput8 (0x800) or higher */
59 if(dwVersion < 0x800)
60 return DIERR_OLDDIRECTINPUTVERSION;
62 if( !(IsEqualGUID(&IID_IDirectInput8A, riid) || IsEqualGUID(&IID_IDirectInput8W, riid) || IsEqualGUID(&IID_IUnknown, riid)) )
63 return DIERR_INVALIDPARAM;
65 hrCo = CoInitialize(NULL);
67 hr = CoCreateInstance( &CLSID_DirectInput8, punkOuter, CLSCTX_INPROC_SERVER, riid, ppDI);
68 if(FAILED(hr)) {
69 ERR("CoCreateInstance failed with hr = %d; Try running wineprefixcreate to fix it.\n", hr);
70 return DIERR_INVALIDPARAM;
73 /* ensure balance of calls */
74 if(hrCo == S_OK || hrCo == S_FALSE)
75 CoUninitialize();
77 /* When aggregation is used (punkOuter!=NULL) the application needs to manually call Initialize. */
78 if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8A, riid)) {
79 LPDIRECTINPUTA DI = *ppDI;
80 IDirectInput8_Initialize(DI, hinst, dwVersion);
83 if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8W, riid)) {
84 LPDIRECTINPUTW DI = *ppDI;
85 IDirectInput8_Initialize(DI, hinst, dwVersion);
88 return S_OK;
91 /*******************************************************************************
92 * DirectInput8 ClassFactory
94 typedef struct
96 /* IUnknown fields */
97 const IClassFactoryVtbl *lpVtbl;
98 } IClassFactoryImpl;
100 static HRESULT WINAPI DI8CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
101 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
102 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
103 return E_NOINTERFACE;
106 static ULONG WINAPI DI8CF_AddRef(LPCLASSFACTORY iface) {
107 LockModule();
108 return 2;
111 static ULONG WINAPI DI8CF_Release(LPCLASSFACTORY iface) {
112 UnlockModule();
113 return 1;
116 static HRESULT WINAPI DI8CF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
117 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
119 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
120 if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) || IsEqualGUID( &IID_IUnknown, riid )) {
121 return DirectInputCreateEx(0, DIRECTINPUT_VERSION, riid, ppobj, pOuter);
124 ERR("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
125 return E_NOINTERFACE;
128 static HRESULT WINAPI DI8CF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
129 TRACE("(%p)->(%d)\n", iface, dolock);
131 if(dolock)
132 LockModule();
133 else
134 UnlockModule();
136 return S_OK;
139 static const IClassFactoryVtbl DI8CF_Vtbl = {
140 DI8CF_QueryInterface,
141 DI8CF_AddRef,
142 DI8CF_Release,
143 DI8CF_CreateInstance,
144 DI8CF_LockServer
146 static IClassFactoryImpl DINPUT8_CF = { &DI8CF_Vtbl };
149 /***********************************************************************
150 * DllCanUnloadNow (DINPUT8.@)
152 HRESULT WINAPI DllCanUnloadNow(void)
154 return dll_count == 0 ? S_OK : S_FALSE;
157 /***********************************************************************
158 * DllGetClassObject (DINPUT8.@)
160 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
162 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
163 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
164 *ppv = &DINPUT8_CF;
165 IClassFactory_AddRef((IClassFactory*)*ppv);
166 return S_OK;
169 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
170 return CLASS_E_CLASSNOTAVAILABLE;