Module: wine Branch: refs/heads/master Commit: 951f4657b796dd128c6797e65fe497faee4f12f5 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=951f4657b796dd128c6797e6...
Author: Roderick Colenbrander thunderbird2k@gmx.net Date: Thu Jul 20 12:42:23 2006 +0200
dinput8: DirectInput8Create rewrite.
---
dlls/dinput8/Makefile.in | 2 +- dlls/dinput8/dinput8_main.c | 39 +++++++++++++++++++++++++++++++++++---- tools/wine.inf | 3 +++ 3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/dlls/dinput8/Makefile.in b/dlls/dinput8/Makefile.in index 34135c1..4466d1d 100644 --- a/dlls/dinput8/Makefile.in +++ b/dlls/dinput8/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = dinput8.dll IMPORTLIB = libdinput8.$(IMPLIBEXT) -IMPORTS = dinput kernel32 +IMPORTS = dinput ole32 advapi32 kernel32 EXTRALIBS = -luuid -ldxguid
C_SRCS = \ diff --git a/dlls/dinput8/dinput8_main.c b/dlls/dinput8/dinput8_main.c index 54ea66e..95aa919 100644 --- a/dlls/dinput8/dinput8_main.c +++ b/dlls/dinput8/dinput8_main.c @@ -51,8 +51,39 @@ static void UnlockModule(void) * DirectInput8Create (DINPUT8.@) */ HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter) { - /* TODO: Create the interface using CoCreateInstance as that's what windows does too and check if the version number >= 0x800 */ - return DirectInputCreateEx(hinst, dwVersion, riid, ppDI, punkOuter); + HRESULT hr; + + TRACE("hInst (%p), dwVersion: %ld, riid (%s), punkOuter (%p))\n", hinst, dwVersion, debugstr_guid(riid), punkOuter); + + /* The specified version needs to be dinput8 (0x800) or higher */ + if(dwVersion < 0x800) + return DIERR_OLDDIRECTINPUTVERSION; + + if( !(IsEqualGUID(&IID_IDirectInput8A, riid) || IsEqualGUID(&IID_IDirectInput8W, riid) || IsEqualGUID(&IID_IUnknown, riid)) ) + return DIERR_INVALIDPARAM; + + CoInitialize(NULL); + + hr = CoCreateInstance( &CLSID_DirectInput8, punkOuter, CLSCTX_INPROC_SERVER, riid, ppDI); + if(FAILED(hr)) { + ERR("CoCreateInstance failed with hr = %ld\n", hr); + return DIERR_INVALIDPARAM; + } + + CoUninitialize(); + + /* When aggregation is used (punkOuter!=NULL) the application needs to manually call Initialize. */ + if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8A, riid)) { + LPDIRECTINPUTA DI = (LPDIRECTINPUTA)*ppDI; + IDirectInput8_Initialize(DI, hinst, dwVersion); + } + + if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8W, riid)) { + LPDIRECTINPUTW DI = (LPDIRECTINPUTW)*ppDI; + IDirectInput8_Initialize(DI, hinst, dwVersion); + } + + return S_OK; }
/******************************************************************************* @@ -84,8 +115,8 @@ static HRESULT WINAPI DI8CF_CreateInstan IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj); - if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) ) { - return DirectInput8Create(0, DIRECTINPUT_VERSION, riid, ppobj, pOuter); + if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) || IsEqualGUID( &IID_IUnknown, riid )) { + return DirectInputCreateEx(0, DIRECTINPUT_VERSION, riid, ppobj, pOuter); }
ERR("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj); diff --git a/tools/wine.inf b/tools/wine.inf index d1a280e..316c25a 100644 --- a/tools/wine.inf +++ b/tools/wine.inf @@ -126,6 +126,9 @@ HKCR,AVIFile\Extensions\AVI,,,"{00020000 HKCR,AVIFile\Extensions\WAV,,,"{00020003-0000-0000-C000-000000000046}" HKCR,AVIFile\RIFFHandlers\AVI,,,"{00020000-0000-0000-C000-000000000046}" HKCR,AVIFile\RIFFHandlers\WAVE,,,"{00020003-0000-0000-C000-000000000046}" +HKCR,CLSID{25E609E4-B259-11CF-BFC7-444553540000},,,"DirectInput8 Object" +HKCR,CLSID{25E609E4-B259-11CF-BFC7-444553540000}\InProcServer32,,,"dinput8.dll" +HKCR,CLSID{25E609E4-B259-11CF-BFC7-444553540000}\InProcServer32,ThreadingModel,,"Both" HKCR,TypeLib{00020430-0000-0000-C000-000000000046}\1.0,,,"OLE Automation" HKCR,TypeLib{00020430-0000-0000-C000-000000000046}\1.0\0\win16,,,"stdole.tlb" HKCR,TypeLib{00020430-0000-0000-C000-000000000046}\1.0\0\win32,,,"stdole32.tlb"