[DINPUT] get Unreal Tournament 2003 (and maybe Unreal2) starting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

 lionel, why the IID_IDirectInput8W is considered as an old version of DINPUT 
? ;))

 Changelog:
  - implement IDirectInput8W interface using IDirectInput8A and IDirectInputA 
interfaces: ugly but works very well (only two "hardcoded" strings must be 
converted to wide char).

Regards,
Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+w2Qip7NA3AmQTU4RAn0tAJ4qUNC7VV2VkgZy0oZukj17oWrr4ACfcEuJ
ueRUtgnoD3A/+QqhyN5H77U=
=SUWG
-----END PGP SIGNATURE-----
Index: dlls/dinput/dinput_main.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/dinput_main.c,v
retrieving revision 1.34
diff -u -r1.34 dinput_main.c
--- dlls/dinput/dinput_main.c	29 Apr 2003 22:43:48 -0000	1.34
+++ dlls/dinput/dinput_main.c	15 May 2003 09:50:08 -0000
@@ -34,6 +34,7 @@
 #include <string.h>
 
 #include "wine/debug.h"
+#include "wine/unicode.h"
 #include "winbase.h"
 #include "winuser.h"
 #include "winerror.h"
@@ -44,6 +45,7 @@
 
 static ICOM_VTABLE(IDirectInput7A) ddi7avt;
 static ICOM_VTABLE(IDirectInput8A) ddi8avt;
+static ICOM_VTABLE(IDirectInput8W) ddi8wvt;
 
 /* This array will be filled a dinput.so loading */
 #define MAX_WINE_DINPUT_DEVICES 4
@@ -122,6 +124,15 @@
 	  return DI_OK;
 	}
 
+	if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
+	  This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
+	  This->lpVtbl = &ddi8wvt;
+	  This->ref = 1;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
+
 	return DIERR_OLDDIRECTINPUTVERSION;
 }
 
@@ -165,6 +176,37 @@
 
 	return 0;
 }
+/******************************************************************************
+ *	IDirectInputW_EnumDevices
+ */
+static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
+	LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
+	LPVOID pvRef, DWORD dwFlags
+)
+{
+	ICOM_THIS(IDirectInputAImpl,iface);
+	DIDEVICEINSTANCEA devInstance;
+	DIDEVICEINSTANCEW newDevInstance;
+	int i;
+
+	TRACE("(this=%p,0x%04lx,%p,%p,%04lx)\n", This, dwDevType, lpCallback, pvRef, dwFlags);
+
+	for (i = 0; i < nrof_dinput_devices; i++) {
+	  devInstance.dwSize = sizeof(devInstance);
+	  if (dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance)) {
+	    newDevInstance.dwSize = sizeof(DIDEVICEINSTANCEW);
+	    newDevInstance.guidInstance = devInstance.guidInstance;
+	    newDevInstance.guidProduct = devInstance.guidProduct;
+	    newDevInstance.dwDevType = devInstance.dwDevType;
+	    MultiByteToWideChar( CP_ACP, 0, devInstance.tszInstanceName, -1, newDevInstance.tszInstanceName, MAX_PATH);
+	    MultiByteToWideChar( CP_ACP, 0, devInstance.tszProductName, -1, newDevInstance.tszProductName, MAX_PATH);	    
+	    if (lpCallback(&newDevInstance,pvRef) == DIENUM_STOP)
+	      return 0;
+	  }
+	}
+
+	return 0;
+}
 
 static HRESULT WINAPI IDirectInputAImpl_QueryInterface(
 	LPDIRECTINPUT7A iface,REFIID riid,LPVOID *ppobj
@@ -224,8 +266,7 @@
 }
 
 static HRESULT WINAPI IDirectInputAImpl_Initialize(
-	LPDIRECTINPUT7A iface,HINSTANCE hinst,DWORD x
-) {
+	LPDIRECTINPUT7A iface,HINSTANCE hinst,DWORD x) {
 	return DIERR_ALREADYINITIALIZED;
 }
 
@@ -255,6 +296,14 @@
   return DI_OK;
 }
 
+static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
+						    LPCWSTR pszName, LPGUID pguidInstance) {
+  ICOM_THIS(IDirectInputAImpl,iface);
+  FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance);
+
+  return DI_OK;
+}
+
 static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
 							REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
 {
@@ -306,6 +355,19 @@
       return 0;
 }
 
+static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
+      LPDIRECTINPUT8A iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
+      LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
+      LPVOID pvRef, DWORD dwFlags
+)
+{
+      ICOM_THIS(IDirectInputAImpl,iface);
+
+      FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
+            lpCallback, pvRef, dwFlags);
+      return 0;
+}
+
 static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
       LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
       LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
@@ -318,6 +380,18 @@
       return 0;
 }
 
+static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
+      LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
+      LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
+)
+{
+      ICOM_THIS(IDirectInputAImpl,iface);
+
+      FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
+            dwFlags, pvRefData);
+      return 0;
+}
+
 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
 # define XCAST(fun)   (typeof(ddi7avt.fun))
 #else
@@ -361,6 +435,27 @@
 };
 #undef XCAST
 
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(ddi8wvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+static ICOM_VTABLE(IDirectInput8W) ddi8wvt = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	XCAST(QueryInterface)IDirectInput8AImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
+	IDirectInput8WImpl_EnumDevicesBySemantics,
+	IDirectInput8WImpl_ConfigureDevices
+};
+#undef XCAST
+
 /*******************************************************************************
  * DirectInput ClassFactory
  */
@@ -398,7 +493,8 @@
 	if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
 	     IsEqualGUID( &IID_IDirectInput2A, riid ) ||
 	     IsEqualGUID( &IID_IDirectInput7A, riid ) ||
-	     IsEqualGUID( &IID_IDirectInput8A, riid ) ) {
+	     IsEqualGUID( &IID_IDirectInput8A, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
 		/* FIXME: reuse already created dinput if present? */
 		return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
 	}
Index: include/dinput.h
===================================================================
RCS file: /home/wine/wine/include/dinput.h,v
retrieving revision 1.34
diff -u -r1.34 dinput.h
--- include/dinput.h	11 Apr 2003 00:31:04 -0000	1.34
+++ include/dinput.h	15 May 2003 09:50:08 -0000
@@ -1439,6 +1439,39 @@
 #define IDirectInput8A_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
 #endif
 
+/*****************************************************************************
+ * IDirectInput8W interface
+ */
+#define INTERFACE IDirectInput8W
+#define IDirectInput8W_METHODS \
+    IUnknown_METHODS \
+    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; \
+    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; \
+    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; \
+    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; \
+    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; \
+    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; \
+    STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; \
+    STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
+ICOM_DEFINE(IDirectInput8W,IUnknown)
+#undef INTERFACE
+
+#ifdef COBJMACROS
+/*** IUnknown methods ***/
+#define IDirectInput8W_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectInput8W_AddRef(p)             (p)->lpVtbl->AddRef(p)
+#define IDirectInput8W_Release(p)            (p)->lpVtbl->Release(p)
+      /*** IDirectInput8W methods ***/
+#define IDirectInput8W_CreateDevice(p,a,b,c)       (p)->lpVtbl->CreateDevice(p,a,b,c)
+#define IDirectInput8W_EnumDevices(p,a,b,c,d)      (p)->lpVtbl->EnumDevices(p,a,b,c,d)
+#define IDirectInput8W_GetDeviceStatus(p,a)        (p)->lpVtbl->GetDeviceStatus(p,a)
+#define IDirectInput8W_RunControlPanel(p,a,b)      (p)->lpVtbl->RunControlPanel(p,a,b)
+#define IDirectInput8W_Initialize(p,a,b)           (p)->lpVtbl->Initialize(p,a,b)
+#define IDirectInput8W_FindDevice(p,a,b,c)         (p)->lpVtbl->FindDevice(p,a,b,c)
+#define IDirectInput8W_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
+#define IDirectInput8W_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
+#endif
+
 #endif /* DI8 */
 
 /* Export functions */

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux