[DINPUT] resend of patch 03-04 sync from current cvs

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

 



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

Hi,

After alexandre last commits, here is the 2 patches resync from current tree 
for avoiding conflits

Changelog:
- - DInput WideChar classes support try 2: with this unreal tournament 2003 is
playable and unreal2 can launch. This time all dinput versions have widechar
classes.
 - fix a stupid bug in callback handling catched by Lionel.
 - add some forgotten IID on class factory (better if we want to active the
code)
 - make lionel happy: many cleanup on COM Macros (don't need A and W variants
as they are the same)

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

iD8DBQE+6vDrp7NA3AmQTU4RAhXXAJwNIHOUZcf2DhWKgqm7TwtiM8Ub6ACfdKxI
MF6A2XOfjRpxRsVC4ZAWpYc=
=5pj3
-----END PGP SIGNATURE-----
Index: device.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/device.c,v
retrieving revision 1.13
diff -u -r1.13 device.c
--- device.c	13 Jun 2003 18:55:41 -0000	1.13
+++ device.c	14 Jun 2003 09:47:08 -0000
@@ -28,6 +28,7 @@
 
 #include <string.h>
 #include "wine/debug.h"
+#include "wine/unicode.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "windef.h"
@@ -107,6 +108,13 @@
   }
 }
 
+void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) {
+  if (TRACE_ON(dinput)) {
+    DPRINTF("    - enumerating : %s - %2ld - 0x%08lx - %s\n",
+	    debugstr_guid(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, debugstr_w(ddoi->tszName));
+  }
+}
+
 /* Conversion between internal data buffer and external data buffer */
 void fill_DataFormat(void *out, void *in, DataFormat *df) {
   int i;
@@ -267,6 +275,40 @@
   return ret;
 }
 
+BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
+  DIDEVICEOBJECTINSTANCEW ddtmp;
+  device_enumobjects_AtoWcb_data* data;
+
+  data = (device_enumobjects_AtoWcb_data*) lpvRef;
+  
+  memset(&ddtmp, 0, sizeof(DIDEVICEINSTANCEW)); 
+
+  ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
+  ddtmp.guidType     = lpddi->guidType;
+  ddtmp.dwOfs        = lpddi->dwOfs;
+  ddtmp.dwType       = lpddi->dwType;
+  ddtmp.dwFlags      = lpddi->dwFlags;
+  MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
+#if(DIRECTINPUT_VERSION >= 0x0500)
+  if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
+    /**
+     * if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
+     *  force feedback and other newer datas aren't available
+     */
+    ddtmp.dwFFMaxForce        = lpddi->dwFFMaxForce;
+    ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
+    ddtmp.wCollectionNumber   = lpddi->wCollectionNumber;
+    ddtmp.wDesignatorIndex    = lpddi->wDesignatorIndex;
+    ddtmp.wUsagePage          = lpddi->wUsagePage;
+    ddtmp.wUsage              = lpddi->wUsage;
+    ddtmp.dwDimension         = lpddi->dwDimension;
+    ddtmp.wExponent           = lpddi->wExponent;
+    ddtmp.wReserved           = lpddi->wReserved;
+  }
+#endif
+  return data->lpCallBack(&ddtmp, data->lpvRef);
+}
+
 /******************************************************************************
  *	IDirectInputDeviceA
  */
@@ -355,6 +397,37 @@
 	return E_FAIL;
 }
 
+HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
+	LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
+)
+{
+	ICOM_THIS(IDirectInputDevice2AImpl,iface);
+
+	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+	if (IsEqualGUID(&IID_IUnknown,riid)) {
+		IDirectInputDevice2_AddRef(iface);
+		*ppobj = This;
+		return DI_OK;
+	}
+	if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
+		IDirectInputDevice2_AddRef(iface);
+		*ppobj = This;
+		return DI_OK;
+	}
+	if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
+		IDirectInputDevice2_AddRef(iface);
+		*ppobj = This;
+		return DI_OK;
+ 	}
+	if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
+		IDirectInputDevice7_AddRef(iface);
+		*ppobj = This;
+		return DI_OK;
+  	}
+  	TRACE("Unsupported interface !\n");
+  	return E_FAIL;
+}
+
 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
 	LPDIRECTINPUTDEVICE8A iface)
 {
@@ -378,6 +451,22 @@
 	return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+	FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
+	if (TRACE_ON(dinput)) {
+	  DPRINTF("  - flags = ");
+	  _dump_EnumObjects_flags(dwFlags);
+	  DPRINTF("\n");
+	}
+
+	return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
 	LPDIRECTINPUTDEVICE8A iface,
 	REFGUID rguid,
@@ -404,6 +493,18 @@
 	return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIDEVICEOBJECTINSTANCEW pdidoi,
+	DWORD dwObj,
+	DWORD dwHow)
+{
+	FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
+	      iface, pdidoi, dwObj, dwHow);
+
+	return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVICEINSTANCEA pdidi)
@@ -413,6 +514,15 @@
 
 	return DI_OK;
 }
+HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIDEVICEINSTANCEW pdidi)
+{
+	FIXME("(this=%p,%p): stub!\n",
+	      iface, pdidi);
+
+	return DI_OK;
+}
 
 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
 	LPDIRECTINPUTDEVICE8A iface,
@@ -466,6 +576,20 @@
 	return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMEFFECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+	FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
+	      iface, lpCallback, lpvRef, dwFlags);
+
+	if (lpCallback)
+		lpCallback(NULL, lpvRef);
+	return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIEFFECTINFOA lpdei,
@@ -476,6 +600,16 @@
 	return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIEFFECTINFOW lpdei,
+	REFGUID rguid)
+{
+	FIXME("(this=%p,%p,%s): stub!\n",
+	      iface, lpdei, debugstr_guid(rguid));
+	return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDWORD pdwOut)
@@ -547,6 +681,17 @@
   return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
+							  LPCWSTR lpszFileName,
+							  LPDIENUMEFFECTSINFILECALLBACK pec,
+							  LPVOID pvRef,
+							  DWORD dwFlags)
+{
+  FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
+
+  return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
 							  LPCSTR lpszFileName,
 							  DWORD dwEntries,
@@ -558,6 +703,17 @@
   return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
+							  LPCWSTR lpszFileName,
+							  DWORD dwEntries,
+							  LPDIFILEEFFECT rgDiFileEft,
+							  DWORD dwFlags)
+{
+  FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
+
+  return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
 						       LPDIACTIONFORMATA lpdiaf,
 						       LPCSTR lpszUserName,
@@ -568,6 +724,16 @@
   return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+						       LPDIACTIONFORMATW lpdiaf,
+						       LPCWSTR lpszUserName,
+						       DWORD dwFlags)
+{
+  FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+  return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
 						     LPDIACTIONFORMATA lpdiaf,
 						     LPCSTR lpszUserName,
@@ -578,8 +744,26 @@
   return DI_OK;
 }
 
+HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+						     LPDIACTIONFORMATW lpdiaf,
+						     LPCWSTR lpszUserName,
+						     DWORD dwFlags)
+{
+  FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+  return DI_OK;
+}
+
 HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
 						     LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
+{
+  FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
+
+  return DI_OK;
+}
+
+HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
+						     LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
 {
   FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
 
Index: device_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dinput/device_private.h,v
retrieving revision 1.4
diff -u -r1.4 device_private.h
--- device_private.h	14 Jun 2002 00:39:44 -0000	1.4
+++ device_private.h	14 Jun 2003 09:47:09 -0000
@@ -70,12 +70,24 @@
   }										\
 }
 
+/**
+ * Callback Data used by specific callback 
+ *  for EnumObject on 'W' interfaces
+ */
+typedef struct {
+  LPDIENUMDEVICEOBJECTSCALLBACKW lpCallBack;
+  LPVOID lpvRef;
+} device_enumobjects_AtoWcb_data;
+
+extern BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA, LPVOID);
+
 
 /* Various debug tools */
 extern void _dump_cooperativelevel_DI(DWORD dwFlags) ;
 extern void _dump_EnumObjects_flags(DWORD dwFlags) ;
 extern void _dump_DIPROPHEADER(DIPROPHEADER *diph) ;
 extern void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) ;
+extern void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) ;
 
 /* And the stubs */
 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
@@ -85,8 +97,8 @@
 extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
 	LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ;
 extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
-	LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj ) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj);
+extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj);
 extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
 	LPDIRECTINPUTDEVICE8A iface) ;
 extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
@@ -94,6 +106,11 @@
 	LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
 	LPVOID lpvRef,
 	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
 	LPDIRECTINPUTDEVICE8A iface,
 	REFGUID rguid,
@@ -103,9 +120,16 @@
 	LPDIDEVICEOBJECTINSTANCEA pdidoi,
 	DWORD dwObj,
 	DWORD dwHow) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, 
+							     LPDIDEVICEOBJECTINSTANCEW pdidoi,
+							     DWORD dwObj,
+							     DWORD dwHow);
 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVICEINSTANCEA pdidi) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIDEVICEINSTANCEW pdidi) ;
 extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
 	LPDIRECTINPUTDEVICE8A iface,
 	HWND hwndOwner,
@@ -126,10 +150,19 @@
 	LPDIENUMEFFECTSCALLBACKA lpCallback,
 	LPVOID lpvRef,
 	DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMEFFECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags) ;
 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIEFFECTINFOA lpdei,
 	REFGUID rguid) ;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIEFFECTINFOW lpdei,
+	REFGUID rguid) ;
 extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDWORD pdwOut) ;
@@ -157,20 +190,40 @@
 								 LPDIENUMEFFECTSINFILECALLBACK pec,
 								 LPVOID pvRef,
 								 DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
+								 LPCWSTR lpszFileName,
+								 LPDIENUMEFFECTSINFILECALLBACK pec,
+								 LPVOID pvRef,
+								 DWORD dwFlags) ;
 extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
 								 LPCSTR lpszFileName,
 								 DWORD dwEntries,
 								 LPDIFILEEFFECT rgDiFileEft,
 								 DWORD dwFlags) ;
+extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
+								 LPCWSTR lpszFileName,
+								 DWORD dwEntries,
+								 LPDIFILEEFFECT rgDiFileEft,
+								 DWORD dwFlags) ;
 extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
 							      LPDIACTIONFORMATA lpdiaf,
 							      LPCSTR lpszUserName,
 							      DWORD dwFlags);
+extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+							      LPDIACTIONFORMATW lpdiaf,
+							      LPCWSTR lpszUserName,
+							      DWORD dwFlags);
 extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
 							    LPDIACTIONFORMATA lpdiaf,
 							    LPCSTR lpszUserName,
 							    DWORD dwFlags);
+extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+							    LPDIACTIONFORMATW lpdiaf,
+							    LPCWSTR lpszUserName,
+							    DWORD dwFlags);
 extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
 							    LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader);
+extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
+							    LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader);
 
 #endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */
Index: dinput.spec
===================================================================
RCS file: /home/wine/wine/dlls/dinput/dinput.spec,v
retrieving revision 1.12
diff -u -r1.12 dinput.spec
--- dinput.spec	20 Mar 2003 03:53:15 -0000	1.12
+++ dinput.spec	14 Jun 2003 09:47:09 -0000
@@ -1,5 +1,5 @@
 @ stdcall DirectInputCreateA(long long ptr ptr)
-@ stub DirectInputCreateW
+@ stdcall DirectInputCreateW(long long ptr ptr)
 @ stdcall DirectInputCreateEx(long long ptr ptr ptr)
 @ stdcall DllCanUnloadNow() DINPUT_DllCanUnloadNow
 @ stdcall DllGetClassObject(ptr ptr ptr) DINPUT_DllGetClassObject
Index: dinput_main.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/dinput_main.c,v
retrieving revision 1.35
diff -u -r1.35 dinput_main.c
--- dinput_main.c	13 Jun 2003 18:55:41 -0000	1.35
+++ dinput_main.c	14 Jun 2003 09:47:14 -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"
@@ -43,7 +44,9 @@
 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 static ICOM_VTABLE(IDirectInput7A) ddi7avt;
+static ICOM_VTABLE(IDirectInput7W) ddi7wvt;
 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
@@ -94,17 +97,16 @@
  */
 HRESULT WINAPI DirectInputCreateEx(
 	HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
-	LPUNKNOWN punkOuter
-) {
-	IDirectInputAImpl* This;
+	LPUNKNOWN punkOuter) 
+{
+	IDirectInputImpl* This;
+
+	TRACE("(0x%08lx,%04lx,%s,%p,%p)\n", (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter);
 
-	TRACE("(0x%08lx,%04lx,%s,%p,%p)\n",
-		(DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter
-	);
 	if (IsEqualGUID(&IID_IDirectInputA,riid) ||
 	    IsEqualGUID(&IID_IDirectInput2A,riid) ||
 	    IsEqualGUID(&IID_IDirectInput7A,riid)) {
-	  This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	  This->lpVtbl = &ddi7avt;
 	  This->ref = 1;
 	  This->version = 1;
@@ -113,9 +115,20 @@
 	  return DI_OK;
 	}
 
+	if (IsEqualGUID(&IID_IDirectInputW,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2W,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7W,riid)) {
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This->lpVtbl = &ddi7wvt;
+	  This->ref = 1;
+	  This->version = 1;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
 
 	if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
-	  This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	  This->lpVtbl = &ddi8avt;
 	  This->ref = 1;
 	  This->version = 8;
@@ -124,6 +137,16 @@
 	  return DI_OK;
 	}
 
+	if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This->lpVtbl = &ddi8wvt;
+	  This->ref = 1;
+	  This->version = 8;
+	  *ppDI = This;
+
+	  return DI_OK;
+	}
+
 	return DIERR_OLDDIRECTINPUTVERSION;
 }
 
@@ -132,26 +155,39 @@
  */
 HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
 {
-	IDirectInputAImpl* This;
-	TRACE("(0x%08lx,%04lx,%p,%p)\n",
-		(DWORD)hinst,dwVersion,ppDI,punkOuter
-	);
-	This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
+	IDirectInputImpl* This;
+	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
+	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	This->lpVtbl = &ddi7avt;
 	This->ref = 1;
-	*ppDI=(IDirectInputA*)This;
+	*ppDI = (IDirectInputA*)This;
+	return 0;
+
+}
+
+/******************************************************************************
+ *	DirectInputCreateW (DINPUT.@)
+ */
+HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
+{
+	IDirectInputImpl* This;
+	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
+	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	This->lpVtbl = &ddi7wvt;
+	This->ref = 1;
+	*ppDI = (IDirectInputW*)This;
 	return 0;
 
 }
+
 /******************************************************************************
  *	IDirectInputA_EnumDevices
  */
 static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
 	LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
-	LPVOID pvRef, DWORD dwFlags
-)
+	LPVOID pvRef, DWORD dwFlags)
 {
-	ICOM_THIS(IDirectInputAImpl,iface);
+	ICOM_THIS(IDirectInputImpl,iface);
 	DIDEVICEINSTANCEA devInstance;
 	int i;
 
@@ -159,7 +195,7 @@
 
 	for (i = 0; i < nrof_dinput_devices; i++) {
 	  devInstance.dwSize = sizeof(devInstance);
-	  if (dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance, This->version)) {
+	  if (dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version)) {
 	    if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
 	      return 0;
 	  }
@@ -167,34 +203,39 @@
 
 	return 0;
 }
+/******************************************************************************
+ *	IDirectInputW_EnumDevices
+ */
+static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
+	LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
+	LPVOID pvRef, DWORD dwFlags) 
+{
+	ICOM_THIS(IDirectInputImpl,iface);
+	DIDEVICEINSTANCEW devInstance;
+	int i;
 
-static HRESULT WINAPI IDirectInputAImpl_QueryInterface(
-	LPDIRECTINPUT7A iface,REFIID riid,LPVOID *ppobj
-) {
-	ICOM_THIS(IDirectInputAImpl,iface);
+	TRACE("(this=%p,0x%04lx,%p,%p,%04lx)\n", This, dwDevType, lpCallback, pvRef, dwFlags);
 
-	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
-	if (IsEqualGUID(&IID_IUnknown,riid) ||
-	    IsEqualGUID(&IID_IDirectInputA,riid) ||
-	    IsEqualGUID(&IID_IDirectInput2A,riid) ||
-	    IsEqualGUID(&IID_IDirectInput7A,riid)) {
-		IDirectInputA_AddRef(iface);
-		*ppobj = This;
-		return 0;
+	for (i = 0; i < nrof_dinput_devices; i++) {
+	  devInstance.dwSize = sizeof(devInstance);
+	  if (dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version)) {
+	    if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
+	      return 0;
+	  }
 	}
-	TRACE("Unsupported interface !\n");
-	return E_FAIL;
+
+	return 0;
 }
 
 static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface)
 {
-	ICOM_THIS(IDirectInputAImpl,iface);
+	ICOM_THIS(IDirectInputImpl,iface);
 	return ++(This->ref);
 }
 
 static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
 {
-	ICOM_THIS(IDirectInputAImpl,iface);
+	ICOM_THIS(IDirectInputImpl,iface);
 	if (!(--This->ref)) {
 		HeapFree(GetProcessHeap(),0,This);
 		return 0;
@@ -202,11 +243,43 @@
 	return This->ref;
 }
 
+static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj) {
+	ICOM_THIS(IDirectInputImpl,iface);
+
+	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+	if (IsEqualGUID(&IID_IUnknown,riid) ||
+	    IsEqualGUID(&IID_IDirectInputA,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2A,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7A,riid)) {
+		IDirectInputAImpl_AddRef(iface);
+		*ppobj = This;
+		return 0;
+	}
+	TRACE("Unsupported interface !\n");
+	return E_FAIL;
+}
+
+static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj) {
+	ICOM_THIS(IDirectInputImpl,iface);
+
+	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+	if (IsEqualGUID(&IID_IUnknown,riid) ||
+	    IsEqualGUID(&IID_IDirectInputW,riid) ||
+	    IsEqualGUID(&IID_IDirectInput2W,riid) ||
+	    IsEqualGUID(&IID_IDirectInput7W,riid)) {
+		IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
+		*ppobj = This;
+		return 0;
+	}
+	TRACE("Unsupported interface !\n");
+	return E_FAIL;
+}
+
 static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
 	LPDIRECTINPUT7A iface,REFGUID rguid,LPDIRECTINPUTDEVICEA* pdev,
 	LPUNKNOWN punk
 ) {
-	ICOM_THIS(IDirectInputAImpl,iface);
+	ICOM_THIS(IDirectInputImpl,iface);
 	HRESULT ret_value = DIERR_DEVICENOTREG;
 	int i;
 
@@ -215,7 +288,7 @@
 	/* Loop on all the devices to see if anyone matches the given GUID */
 	for (i = 0; i < nrof_dinput_devices; i++) {
 	  HRESULT ret;
-	  if ((ret = dinput_devices[i]->create_device(This, rguid, NULL, pdev)) == DI_OK)
+	  if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
 	    return DI_OK;
 
 	  if (ret == DIERR_NOINTERFACE)
@@ -225,15 +298,34 @@
 	return ret_value;
 }
 
-static HRESULT WINAPI IDirectInputAImpl_Initialize(
-	LPDIRECTINPUT7A iface,HINSTANCE hinst,DWORD x
-) {
+static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface, 
+						     REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) {
+        ICOM_THIS(IDirectInputImpl,iface);
+	HRESULT ret_value = DIERR_DEVICENOTREG;
+	int i;
+
+	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
+
+	/* Loop on all the devices to see if anyone matches the given GUID */
+	for (i = 0; i < nrof_dinput_devices; i++) {
+	  HRESULT ret;
+	  if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
+	    return DI_OK;
+
+	  if (ret == DIERR_NOINTERFACE)
+	    ret_value = DIERR_NOINTERFACE;
+	}
+
+	return ret_value;
+}
+
+static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
 	return DIERR_ALREADYINITIALIZED;
 }
 
 static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
 							REFGUID rguid) {
-  ICOM_THIS(IDirectInputAImpl,iface);
+  ICOM_THIS(IDirectInputImpl,iface);
 
   FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
 
@@ -243,7 +335,7 @@
 static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
 							HWND hwndOwner,
 							DWORD dwFlags) {
-  ICOM_THIS(IDirectInputAImpl,iface);
+  ICOM_THIS(IDirectInputImpl,iface);
   FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
 
   return DI_OK;
@@ -251,16 +343,24 @@
 
 static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
 						    LPCSTR pszName, LPGUID pguidInstance) {
-  ICOM_THIS(IDirectInputAImpl,iface);
+  ICOM_THIS(IDirectInputImpl,iface);
   FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance);
 
   return DI_OK;
 }
 
+static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid,
+						    LPCWSTR pszName, LPGUID pguidInstance) {
+  ICOM_THIS(IDirectInputImpl,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)
 {
-  ICOM_THIS(IDirectInputAImpl,iface);
+  ICOM_THIS(IDirectInputImpl,iface);
   HRESULT ret_value = DIERR_DEVICENOTREG;
   int i;
 
@@ -269,7 +369,7 @@
   /* Loop on all the devices to see if anyone matches the given GUID */
   for (i = 0; i < nrof_dinput_devices; i++) {
     HRESULT ret;
-    if ((ret = dinput_devices[i]->create_device(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
+    if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
       return DI_OK;
 
     if (ret == DIERR_NOINTERFACE)
@@ -279,20 +379,54 @@
   return ret_value;
 }
 
-static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(
-      LPDIRECTINPUT8A iface,REFIID riid,LPVOID *ppobj
-) {
-      ICOM_THIS(IDirectInputAImpl,iface);
+static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
+							REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
+{
+  ICOM_THIS(IDirectInputImpl,iface);
+  HRESULT ret_value = DIERR_DEVICENOTREG;
+  int i;
+
+  TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
+
+  /* Loop on all the devices to see if anyone matches the given GUID */
+  for (i = 0; i < nrof_dinput_devices; i++) {
+    HRESULT ret;
+    if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
+      return DI_OK;
+
+    if (ret == DIERR_NOINTERFACE)
+      ret_value = DIERR_NOINTERFACE;
+  }
+
+  return ret_value;
+}
+
+static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) {
+      ICOM_THIS(IDirectInputImpl,iface);
 
       TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
       if (IsEqualGUID(&IID_IUnknown,riid) ||
           IsEqualGUID(&IID_IDirectInput8A,riid)) {
-              IDirectInputA_AddRef(iface);
+              IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
+              *ppobj = This;
+              return 0;
+      }
+      TRACE("Unsupported interface !\n");
+      return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) {
+      ICOM_THIS(IDirectInputImpl,iface);
+
+      TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
+      if (IsEqualGUID(&IID_IUnknown,riid) ||
+          IsEqualGUID(&IID_IDirectInput8W,riid)) {
+              IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
               *ppobj = This;
               return 0;
       }
       TRACE("Unsupported interface !\n");
-      return E_FAIL;
+      return E_NOINTERFACE;
 }
 
 static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
@@ -301,19 +435,44 @@
       LPVOID pvRef, DWORD dwFlags
 )
 {
-      ICOM_THIS(IDirectInputAImpl,iface);
+      ICOM_THIS(IDirectInputImpl,iface);
 
       FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat,
             lpCallback, pvRef, dwFlags);
       return 0;
 }
 
+static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
+      LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
+      LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
+      LPVOID pvRef, DWORD dwFlags
+)
+{
+      ICOM_THIS(IDirectInputImpl,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
 )
 {
-      ICOM_THIS(IDirectInputAImpl,iface);
+      ICOM_THIS(IDirectInputImpl,iface);
+
+      FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
+            dwFlags, pvRefData);
+      return 0;
+}
+
+static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
+      LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
+      LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
+)
+{
+      ICOM_THIS(IDirectInputImpl,iface);
 
       FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
             dwFlags, pvRefData);
@@ -337,7 +496,28 @@
 	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
 	XCAST(Initialize)IDirectInputAImpl_Initialize,
 	XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
-	IDirectInput7AImpl_CreateDeviceEx
+	XCAST(CreateDeviceEx)IDirectInput7AImpl_CreateDeviceEx
+};
+
+#undef XCAST
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)   (typeof(ddi7wvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static ICOM_VTABLE(IDirectInput7W) ddi7wvt = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	XCAST(QueryInterface)IDirectInputWImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
+	XCAST(CreateDeviceEx)IDirectInput7WImpl_CreateDeviceEx
 };
 #undef XCAST
 
@@ -358,8 +538,29 @@
 	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
 	XCAST(Initialize)IDirectInputAImpl_Initialize,
 	XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
-	IDirectInput8AImpl_EnumDevicesBySemantics,
-	IDirectInput8AImpl_ConfigureDevices
+	XCAST(EnumDevicesBySemantics)IDirectInput8AImpl_EnumDevicesBySemantics,
+	XCAST(ConfigureDevices)IDirectInput8AImpl_ConfigureDevices
+};
+#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)IDirectInput8WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputAImpl_AddRef,
+	XCAST(Release)IDirectInputAImpl_Release,
+	XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
+	XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
+	XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
+	XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputAImpl_Initialize,
+	XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
+	XCAST(EnumDevicesBySemantics)IDirectInput8WImpl_EnumDevicesBySemantics,
+	XCAST(ConfigureDevices)IDirectInput8WImpl_ConfigureDevices
 };
 #undef XCAST
 
@@ -398,9 +599,13 @@
 
 	TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
 	if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
+	     IsEqualGUID( &IID_IDirectInputW, riid ) ||
 	     IsEqualGUID( &IID_IDirectInput2A, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput2W, riid ) ||
 	     IsEqualGUID( &IID_IDirectInput7A, riid ) ||
-	     IsEqualGUID( &IID_IDirectInput8A, riid ) ) {
+	     IsEqualGUID( &IID_IDirectInput7W, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput8A, riid ) ||
+	     IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
 		/* FIXME: reuse already created dinput if present? */
 		return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
 	}
Index: dinput_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dinput/dinput_private.h,v
retrieving revision 1.9
diff -u -r1.9 dinput_private.h
--- dinput_private.h	13 Jun 2003 18:55:41 -0000	1.9
+++ dinput_private.h	14 Jun 2003 09:47:14 -0000
@@ -23,8 +23,8 @@
 #include "dinput.h"
 
 /* Implementation specification */
-typedef struct IDirectInputAImpl IDirectInputAImpl;
-struct IDirectInputAImpl
+typedef struct IDirectInputImpl IDirectInputImpl;
+struct IDirectInputImpl
 {
    LPVOID lpVtbl;
    DWORD  ref;
@@ -38,11 +38,13 @@
 /* Function called by all devices that Wine supports */
 typedef struct dinput_device {
   INT pref;
-  BOOL (*enum_device)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version);
-  HRESULT (*create_device)(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
+  BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version);
+  BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version);
+  HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
+  HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
 } dinput_device;
 
-extern void dinput_register_device(dinput_device *device) ;
+extern void dinput_register_device(dinput_device *device);
 
 extern HINSTANCE DINPUT_instance;
 
Index: joystick/linux.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/joystick/linux.c,v
retrieving revision 1.15
diff -u -r1.15 linux.c
--- joystick/linux.c	13 Jun 2003 18:55:41 -0000	1.15
+++ joystick/linux.c	14 Jun 2003 09:47:14 -0000
@@ -47,6 +47,7 @@
 #define JOYDEV	"/dev/js0"
 
 #include "wine/debug.h"
+#include "wine/unicode.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "windef.h"
@@ -61,16 +62,17 @@
 #define WINE_JOYSTICK_AXIS_BASE   0
 #define WINE_JOYSTICK_BUTTON_BASE 8
 
-typedef struct JoystickAImpl JoystickAImpl;
+typedef struct JoystickImpl JoystickImpl;
 static ICOM_VTABLE(IDirectInputDevice8A) JoystickAvt;
-struct JoystickAImpl
+static ICOM_VTABLE(IDirectInputDevice8W) JoystickWvt;
+struct JoystickImpl
 {
         LPVOID                          lpVtbl;
         DWORD                           ref;
         GUID                            guid;
 
 	/* The 'parent' DInput */
-	IDirectInputAImpl *dinput;
+	IDirectInputImpl               *dinput;
 
 	/* joystick private */
 	int				joyfd;
@@ -89,7 +91,7 @@
   {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
 };
 
-static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
 {
   int fd = -1;
 
@@ -121,11 +123,43 @@
   return FALSE;
 }
 
-static JoystickAImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputAImpl *dinput)
+static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
 {
-  JoystickAImpl* newDevice;
+  int fd = -1;
+
+  if (dwFlags & DIEDFL_FORCEFEEDBACK)
+    return FALSE;
+
+  if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
+    /* check whether we have a joystick */
+    if ((fd = open(JOYDEV,O_RDONLY) != -1) || (errno!=ENODEV && errno!=ENOENT)) {
+      TRACE("Enumerating the linux Joystick device\n");
+
+      /* Return joystick */
+      lpddi->guidInstance	= GUID_Joystick;
+      lpddi->guidProduct	= DInput_Wine_Joystick_GUID;
+      /* we only support traditional joysticks for now */
+      lpddi->dwDevType	= DIDEVTYPE_JOYSTICK |
+	 		 (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
 
-  newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
+      MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
+      /* ioctl JSIOCGNAME(len) */
+      MultiByteToWideChar(CP_ACP, 0, "Wine Joystick", -1, lpddi->tszProductName, MAX_PATH);
+      lpddi->guidFFDriver = GUID_NULL;
+      if (fd != -1)
+	close(fd);
+      return TRUE;
+    }
+  }
+
+  return FALSE;
+}
+
+static JoystickImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput)
+{
+  JoystickImpl* newDevice;
+
+  newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
   newDevice->lpVtbl = jvt;
   newDevice->ref = 1;
   newDevice->joyfd = -1;
@@ -137,7 +171,7 @@
   return newDevice;
 }
 
-static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
 {
   if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
       (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
@@ -157,10 +191,32 @@
   return DIERR_DEVICENOTREG;
 }
 
+static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
+      (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
+
+      TRACE("Creating a Joystick device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+
+  return DIERR_DEVICENOTREG;
+}
+
 static dinput_device joydev = {
   10,
-  joydev_enum_device,
-  joydev_create_device
+  joydev_enum_deviceA,
+  joydev_enum_deviceW,
+  joydev_create_deviceA,
+  joydev_create_deviceW
 };
 
 DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
@@ -170,7 +226,7 @@
  */
 static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
 {
-	ICOM_THIS(JoystickAImpl,iface);
+	ICOM_THIS(JoystickImpl,iface);
 
 	This->ref--;
 	if (This->ref)
@@ -195,7 +251,7 @@
 	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
 )
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
   int i;
 
   TRACE("(this=%p,%p)\n",This,df);
@@ -227,7 +283,7 @@
   */
 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
 {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     TRACE("(this=%p)\n",This);
     if (This->joyfd!=-1)
@@ -243,7 +299,7 @@
   */
 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
 {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     TRACE("(this=%p)\n",This);
     if (This->joyfd!=-1) {
@@ -255,7 +311,7 @@
 
 #define map_axis(val) ((val+32768)*(This->lMax-This->lMin)/65536+This->lMin)
 
-static void joy_polldev(JoystickAImpl *This) {
+static void joy_polldev(JoystickImpl *This) {
     struct timeval tv;
     fd_set	readfds;
     struct	js_event jse;
@@ -305,7 +361,7 @@
 static HRESULT WINAPI JoystickAImpl_GetDeviceState(
 	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
 ) {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     joy_polldev(This);
     TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
@@ -327,7 +383,7 @@
 					      LPDWORD entries,
 					      DWORD flags
 ) {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
 
   FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
 
@@ -348,7 +404,7 @@
 					    REFGUID rguid,
 					    LPCDIPROPHEADER ph)
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
 
   FIXME("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
   FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
@@ -390,7 +446,7 @@
 static HRESULT WINAPI JoystickAImpl_SetEventNotification(
 	LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
 ) {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
     This->hEvent = hnd;
@@ -401,7 +457,7 @@
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVCAPS lpDIDevCaps)
 {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
     BYTE	axes,buttons;
     int		xfd = This->joyfd;
 
@@ -425,7 +481,7 @@
     return DI_OK;
 }
 static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
     TRACE("(),stub!\n");
 
     joy_polldev(This);
@@ -441,7 +497,7 @@
 	LPVOID lpvRef,
 	DWORD dwFlags)
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
   DIDEVICEOBJECTINSTANCEA ddoi;
   int xfd = This->joyfd;
 
@@ -518,13 +574,32 @@
 }
 
 /******************************************************************************
+  *     EnumObjects : enumerate the different buttons and axis...
+  */
+static HRESULT WINAPI JoystickWImpl_EnumObjects(
+	LPDIRECTINPUTDEVICE8W iface,
+	LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+	LPVOID lpvRef,
+	DWORD dwFlags)
+{
+  ICOM_THIS(JoystickImpl,iface);
+
+  device_enumobjects_AtoWcb_data data;
+
+  data.lpCallBack = lpCallback;
+  data.lpvRef = lpvRef;
+
+  return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
+}
+
+/******************************************************************************
   *     GetProperty : get input device properties
   */
 static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
 						REFGUID rguid,
 						LPDIPROPHEADER pdiph)
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
 
   TRACE("(this=%p,%s,%p): stub!\n",
 	iface, debugstr_guid(rguid), pdiph);
@@ -601,5 +676,49 @@
 	IDirectInputDevice8AImpl_SetActionMap,
 	IDirectInputDevice8AImpl_GetImageInfo
 };
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(SysJoystickWvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static ICOM_VTABLE(IDirectInputDevice8W) SysJoystickWvt =
+{
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectInputDevice2WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
+	XCAST(Release)JoystickAImpl_Release,
+	XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
+	JoystickWImpl_EnumObjects,
+	XCAST(GetProperty)JoystickAImpl_GetProperty,
+	XCAST(SetProperty)JoystickAImpl_SetProperty,
+	XCAST(Acquire)JoystickAImpl_Acquire,
+	XCAST(Unacquire)JoystickAImpl_Unacquire,
+	XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
+	XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
+	XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
+	XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
+	XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
+	IDirectInputDevice2WImpl_GetObjectInfo,
+	IDirectInputDevice2WImpl_GetDeviceInfo,
+	XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
+	XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
+	IDirectInputDevice2WImpl_EnumEffects,
+	IDirectInputDevice2WImpl_GetEffectInfo,
+	XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
+	XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+	XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+	XCAST(Escape)IDirectInputDevice2AImpl_Escape,
+	XCAST(Poll)JoystickAImpl_Poll,
+	XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+        IDirectInputDevice7WImpl_EnumEffectsInFile,
+        IDirectInputDevice7WImpl_WriteEffectToFile,
+        IDirectInputDevice8WImpl_BuildActionMap,
+        IDirectInputDevice8WImpl_SetActionMap,
+        IDirectInputDevice8WImpl_GetImageInfo
+};
+#undef XCAST
 
 #endif  /* HAVE_LINUX_22_JOYSTICK_API */
Index: joystick/linuxinput.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/joystick/linuxinput.c,v
retrieving revision 1.15
diff -u -r1.15 linuxinput.c
--- joystick/linuxinput.c	13 Jun 2003 18:55:41 -0000	1.15
+++ joystick/linuxinput.c	14 Jun 2003 09:47:15 -0000
@@ -53,6 +53,7 @@
 #define EVDEVPREFIX	"/dev/input/event"
 
 #include "wine/debug.h"
+#include "wine/unicode.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "windef.h"
@@ -67,9 +68,10 @@
 #define WINE_JOYSTICK_AXIS_BASE   0
 #define WINE_JOYSTICK_BUTTON_BASE 8
 
-typedef struct JoystickAImpl JoystickAImpl;
+typedef struct JoystickImpl JoystickImpl;
 static ICOM_VTABLE(IDirectInputDevice8A) JoystickAvt;
-struct JoystickAImpl
+static ICOM_VTABLE(IDirectInputDevice8W) JoystickWvt;
+struct JoystickImpl
 {
         LPVOID                          lpVtbl;
         DWORD                           ref;
@@ -77,7 +79,7 @@
 
 
 	/* The 'parent' DInput */
-	IDirectInputAImpl *dinput;
+	IDirectInputImpl               *dinput;
 
 	/* joystick private */
 	/* what range and deadzone the game wants */
@@ -122,15 +124,10 @@
 
 #define test_bit(arr,bit) (((BYTE*)arr)[bit>>3]&(1<<(bit&7)))
 
-static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+static int joydev_have(void)
 {
-  int i, fd, havejoy = 0;
-
-  if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
-      return FALSE;
-
-  if (dwFlags & DIEDFL_FORCEFEEDBACK)
-    return FALSE;
+  int i, fd;
+  int havejoy = 0;
 
   for (i=0;i<64;i++) {
       char	buf[200];
@@ -164,6 +161,20 @@
       if (havejoy || (errno==ENODEV))
 	  break;
   }
+  return havejoy;
+}
+
+static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+{
+  int havejoy = 0;
+
+  if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
+      return FALSE;
+
+  if (dwFlags & DIEDFL_FORCEFEEDBACK)
+    return FALSE;
+
+  havejoy = joydev_have();
 
   if (!havejoy)
       return FALSE;
@@ -175,21 +186,50 @@
   lpddi->guidProduct	= DInput_Wine_Joystick_GUID;
 
   lpddi->guidFFDriver = GUID_NULL;
-  lpddi->dwDevType	= DIDEVTYPE_JOYSTICK |
-		       (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
+  lpddi->dwDevType    = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
 
-  strcpy(lpddi->tszInstanceName,	"Joystick");
+  strcpy(lpddi->tszInstanceName, "Joystick");
   /* ioctl JSIOCGNAME(len) */
   strcpy(lpddi->tszProductName,	"Wine Joystick");
   return TRUE;
 }
 
-static JoystickAImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputAImpl *dinput)
+static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
+{
+  int havejoy = 0;
+
+  if ((dwDevType != 0) && (GET_DIDEVICE_TYPE(dwDevType) != DIDEVTYPE_JOYSTICK))
+      return FALSE;
+
+  if (dwFlags & DIEDFL_FORCEFEEDBACK)
+    return FALSE;
+
+  havejoy = joydev_have();
+
+  if (!havejoy)
+      return FALSE;
+
+  TRACE("Enumerating the linuxinput Joystick device\n");
+
+  /* Return joystick */
+  lpddi->guidInstance	= GUID_Joystick;
+  lpddi->guidProduct	= DInput_Wine_Joystick_GUID;
+
+  lpddi->guidFFDriver = GUID_NULL;
+  lpddi->dwDevType    = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
+
+  MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
+  /* ioctl JSIOCGNAME(len) */
+  MultiByteToWideChar(CP_ACP, 0, "Wine Joystick", -1, lpddi->tszProductName, MAX_PATH);
+  return TRUE;
+}
+
+static JoystickImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput)
 {
-  JoystickAImpl* newDevice;
+  JoystickImpl* newDevice;
   int i;
 
-  newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
+  newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
   newDevice->lpVtbl = jvt;
   newDevice->ref = 1;
   newDevice->joyfd = -1;
@@ -203,42 +243,11 @@
   return newDevice;
 }
 
-static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
 {
-  int i, fd, havejoy = 0;
+  int havejoy = 0;
 
-  for (i=0;i<64;i++) {
-      char	buf[200];
-      BYTE	absbits[(ABS_MAX+7)/8],keybits[(KEY_MAX+7)/8];
-
-      sprintf(buf,EVDEVPREFIX"%d",i);
-      if (-1!=(fd=open(buf,O_RDONLY))) {
-	  if (-1==ioctl(fd,EVIOCGBIT(EV_ABS,sizeof(absbits)),absbits)) {
-	      perror("EVIOCGBIT EV_ABS");
-	      close(fd);
-	      continue;
-	  }
-	  if (-1==ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(keybits)),keybits)) {
-	      perror("EVIOCGBIT EV_KEY");
-	      close(fd);
-	      continue;
-	  }
-	  /* A true joystick has at least axis X and Y, and at least 1
-	   * button. copied from linux/drivers/input/joydev.c */
-	  if (test_bit(absbits,ABS_X) && test_bit(absbits,ABS_Y) &&
-	      (   test_bit(keybits,BTN_TRIGGER)	||
-		  test_bit(keybits,BTN_A) 	||
-		  test_bit(keybits,BTN_1)
-	      )
-	  ) {
-	      FIXME("found a joystick at %s!\n",buf);
-	      havejoy = 1;
-	  }
-	  close(fd);
-      }
-      if (havejoy || (errno==ENODEV))
-	  break;
-  }
+  havejoy = joydev_have();
 
   if (!havejoy)
       return DIERR_DEVICENOTREG;
@@ -250,7 +259,34 @@
 	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
 	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
 	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
-      *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
+      *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
+      TRACE("Creating a Joystick device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+
+  return DIERR_DEVICENOTREG;
+}
+
+
+static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  int havejoy = 0;
+
+  havejoy = joydev_have();
+
+  if (!havejoy)
+      return DIERR_DEVICENOTREG;
+
+  if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
+      (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
       TRACE("Creating a Joystick device (%p)\n", *pdev);
       return DI_OK;
     } else
@@ -262,8 +298,10 @@
 
 static dinput_device joydev = {
   20,
-  joydev_enum_device,
-  joydev_create_device
+  joydev_enum_deviceA,
+  joydev_enum_deviceW,
+  joydev_create_deviceA,
+  joydev_create_deviceW
 };
 
 DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
@@ -273,7 +311,7 @@
  */
 static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
 {
-	ICOM_THIS(JoystickAImpl,iface);
+	ICOM_THIS(JoystickImpl,iface);
 
 	This->ref--;
 	if (This->ref)
@@ -298,7 +336,7 @@
 	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
 )
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
   int i;
 
   TRACE("(this=%p,%p)\n",This,df);
@@ -331,7 +369,7 @@
 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
 {
     int		i;
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
     char	buf[200];
 
     TRACE("(this=%p)\n",This);
@@ -387,7 +425,7 @@
   */
 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
 {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     TRACE("(this=%p)\n",This);
     if (This->joyfd!=-1) {
@@ -403,7 +441,7 @@
  * adapts values accordingly.
  */
 static int
-map_axis(JoystickAImpl* This, int axis, int val) {
+map_axis(JoystickImpl* This, int axis, int val) {
     int	xmid = This->axes[axis][AXE_ABS];
     int	xmin = This->axes[axis][AXE_ABSMIN];
     int	xmax = This->axes[axis][AXE_ABSMAX];
@@ -436,7 +474,7 @@
     return ret;
 }
 
-static void joy_polldev(JoystickAImpl *This) {
+static void joy_polldev(JoystickImpl *This) {
     struct timeval tv;
     fd_set	readfds;
     struct	input_event ie;
@@ -515,7 +553,7 @@
 static HRESULT WINAPI JoystickAImpl_GetDeviceState(
 	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
 ) {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     joy_polldev(This);
 
@@ -538,7 +576,7 @@
 					      LPDWORD entries,
 					      DWORD flags
 ) {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
 
   FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
 
@@ -559,7 +597,7 @@
 					    REFGUID rguid,
 					    LPCDIPROPHEADER ph)
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
 
   FIXME("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
   FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
@@ -612,7 +650,7 @@
 static HRESULT WINAPI JoystickAImpl_SetEventNotification(
 	LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
 ) {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
 
     TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
     This->hEvent = hnd;
@@ -623,7 +661,7 @@
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVCAPS lpDIDevCaps)
 {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
     int		xfd = This->joyfd;
     int		i,axes,buttons;
     int		wasacquired = 1;
@@ -653,7 +691,7 @@
 }
 
 static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
-    ICOM_THIS(JoystickAImpl,iface);
+    ICOM_THIS(JoystickImpl,iface);
     TRACE("(),stub!\n");
 
     joy_polldev(This);
@@ -669,7 +707,7 @@
 	LPVOID lpvRef,
 	DWORD dwFlags)
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
   DIDEVICEOBJECTINSTANCEA ddoi;
   int xfd = This->joyfd;
 
@@ -825,6 +863,21 @@
   return DI_OK;
 }
 
+static HRESULT WINAPI JoystickWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
+						LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+						LPVOID lpvRef,
+						DWORD dwFlags)
+{
+  ICOM_THIS(JoystickImpl,iface);
+
+  device_enumobjects_AtoWcb_data data;
+
+  data.lpCallBack = lpCallback;
+  data.lpvRef = lpvRef;
+
+  return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
+}
+
 /******************************************************************************
   *     GetProperty : get input device properties
   */
@@ -832,7 +885,7 @@
 						REFGUID rguid,
 						LPDIPROPHEADER pdiph)
 {
-  ICOM_THIS(JoystickAImpl,iface);
+  ICOM_THIS(JoystickImpl,iface);
 
   TRACE("(this=%p,%s,%p): stub!\n",
 	iface, debugstr_guid(rguid), pdiph);
@@ -907,6 +960,50 @@
         IDirectInputDevice8AImpl_SetActionMap,
         IDirectInputDevice8AImpl_GetImageInfo
 };
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(JoystickWvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static ICOM_VTABLE(IDirectInputDevice8W) JoystickWvt =
+{
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectInputDevice2WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
+	XCAST(Release)JoystickAImpl_Release,
+	XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
+	JoystickWImpl_EnumObjects,
+	XCAST(GetProperty)JoystickAImpl_GetProperty,
+	XCAST(SetProperty)JoystickAImpl_SetProperty,
+	XCAST(Acquire)JoystickAImpl_Acquire,
+	XCAST(Unacquire)JoystickAImpl_Unacquire,
+	XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
+	XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
+	XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
+	XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
+	XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
+	IDirectInputDevice2WImpl_GetObjectInfo,
+	IDirectInputDevice2WImpl_GetDeviceInfo,
+	XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
+	XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
+	IDirectInputDevice2WImpl_EnumEffects,
+	IDirectInputDevice2WImpl_GetEffectInfo,
+	XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
+	XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+	XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+	XCAST(Escape)IDirectInputDevice2AImpl_Escape,
+	XCAST(Poll)JoystickAImpl_Poll,
+	XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+        IDirectInputDevice7WImpl_EnumEffectsInFile,
+        IDirectInputDevice7WImpl_WriteEffectToFile,
+        IDirectInputDevice8WImpl_BuildActionMap,
+        IDirectInputDevice8WImpl_SetActionMap,
+        IDirectInputDevice8WImpl_GetImageInfo
+};
+#undef XCAST
 
 #endif  /* HAVE_LINUX_INPUT_H */
 
Index: keyboard/main.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/keyboard/main.c,v
retrieving revision 1.24
diff -u -r1.24 main.c
--- keyboard/main.c	13 Jun 2003 18:55:41 -0000	1.24
+++ keyboard/main.c	14 Jun 2003 09:47:16 -0000
@@ -31,19 +31,21 @@
 #include "dinput_private.h"
 #include "device_private.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt;
+static ICOM_VTABLE(IDirectInputDevice8W) SysKeyboardWvt;
 
-typedef struct SysKeyboardAImpl SysKeyboardAImpl;
-struct SysKeyboardAImpl
+typedef struct SysKeyboardImpl SysKeyboardImpl;
+struct SysKeyboardImpl
 {
         LPVOID                          lpVtbl;
         DWORD                           ref;
         GUID                            guid;
 
-	IDirectInputAImpl *dinput;
+	IDirectInputImpl*               dinput;
 
 	HANDLE	hEvent;
         /* SysKeyboardAImpl */
@@ -61,7 +63,7 @@
         CRITICAL_SECTION                crit;
 };
 
-SysKeyboardAImpl *current; /* Today's acquired device
+SysKeyboardImpl *current; /* Today's acquired device
 FIXME: currently this can be only one.
 Maybe this should be a linked list or st.
 I don't know what the rules are for multiple acquired keyboards,
@@ -138,7 +140,7 @@
   {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
 };
 
-static void fill_keyboard_dideviceinstancea(LPDIDEVICEINSTANCEA lpddi, int version) {
+static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
     DWORD dwSize;
     DIDEVICEINSTANCEA ddi;
     
@@ -162,14 +164,53 @@
     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
 }
 
-static BOOL keyboarddev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
+    DWORD dwSize;
+    DIDEVICEINSTANCEW ddi;
+    
+    dwSize = lpddi->dwSize;
+
+    TRACE("%ld %p\n", dwSize, lpddi);
+    
+    memset(lpddi, 0, dwSize);
+    memset(&ddi, 0, sizeof(ddi));
+ 
+    ddi.dwSize = dwSize;
+    ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
+    ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
+    if (version >= 8)
+        ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
+    else
+        ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
+    MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
+
+    memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
+}
+ 
+static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+{
+  if ((dwDevType == 0) ||
+      ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
+      ((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
+    TRACE("Enumerating the Keyboard device\n");
+ 
+    fill_keyboard_dideviceinstanceA(lpddi, version);
+    
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
 {
   if ((dwDevType == 0) ||
       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
       ((dwDevType == DI8DEVTYPE_KEYBOARD) && (version >= 8))) {
     TRACE("Enumerating the Keyboard device\n");
 
-    fill_keyboard_dideviceinstancea(lpddi, version);
+    fill_keyboard_dideviceinstanceW(lpddi, version);
     
     return TRUE;
   }
@@ -177,10 +218,10 @@
   return FALSE;
 }
 
-static SysKeyboardAImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputAImpl *dinput)
+static SysKeyboardImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
 {
-    SysKeyboardAImpl* newDevice;
-    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardAImpl));
+    SysKeyboardImpl* newDevice;
+    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
     newDevice->lpVtbl = kvt;
     newDevice->ref = 1;
     memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
@@ -195,7 +236,7 @@
 }
 
 
-static HRESULT keyboarddev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
 {
   if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
       (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
@@ -204,27 +245,46 @@
 	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
 	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
 	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
-      *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
+      *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
       TRACE("Creating a Keyboard device (%p)\n", *pdev);
       return DI_OK;
     } else
       return DIERR_NOINTERFACE;
   }
+  return DIERR_DEVICENOTREG;
+}
 
+static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
+      (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
+      TRACE("Creating a Keyboard device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
   return DIERR_DEVICENOTREG;
 }
 
 static dinput_device keyboarddev = {
   100,
-  keyboarddev_enum_device,
-  keyboarddev_create_device
+  keyboarddev_enum_deviceA,
+  keyboarddev_enum_deviceW,
+  keyboarddev_create_deviceA,
+  keyboarddev_create_deviceW
 };
 
 DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register) { dinput_register_device(&keyboarddev); }
 
 static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
 {
-	ICOM_THIS(SysKeyboardAImpl,iface);
+	ICOM_THIS(SysKeyboardImpl,iface);
 
 	This->ref--;
 	if (This->ref)
@@ -251,7 +311,7 @@
 	LPDIRECTINPUTDEVICE8A iface,REFGUID rguid,LPCDIPROPHEADER ph
 )
 {
-	ICOM_THIS(SysKeyboardAImpl,iface);
+	ICOM_THIS(SysKeyboardImpl,iface);
 
 	TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
 	TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
@@ -299,7 +359,7 @@
 	LPDWORD entries,DWORD flags
 )
 {
-	ICOM_THIS(SysKeyboardAImpl,iface);
+	ICOM_THIS(SysKeyboardImpl,iface);
 	int ret = DI_OK, i = 0;
 
 	TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
@@ -360,7 +420,7 @@
 	LPVOID lpvRef,
 	DWORD dwFlags)
 {
-    ICOM_THIS(SysKeyboardAImpl,iface);
+    ICOM_THIS(SysKeyboardImpl,iface);
     DIDEVICEOBJECTINSTANCEA ddoi;
     int i;
     
@@ -388,11 +448,26 @@
     return DI_OK;
 }
 
+static HRESULT WINAPI SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
+						   LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
+						   LPVOID lpvRef,
+						   DWORD dwFlags)
+{
+  ICOM_THIS(SysKeyboardImpl,iface);
+
+  device_enumobjects_AtoWcb_data data;
+
+  data.lpCallBack = lpCallback;
+  data.lpvRef = lpvRef;
+
+  return SysKeyboardAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
+}
+
 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
 
 static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
 {
-	ICOM_THIS(SysKeyboardAImpl,iface);
+	ICOM_THIS(SysKeyboardImpl,iface);
 
 	TRACE("(this=%p)\n",This);
 
@@ -426,7 +501,7 @@
 
 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
 {
-	ICOM_THIS(SysKeyboardAImpl,iface);
+	ICOM_THIS(SysKeyboardImpl,iface);
 	TRACE("(this=%p)\n",This);
 
         if (This->acquired == 0)
@@ -451,7 +526,7 @@
 
 static HRESULT WINAPI SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
 							    HANDLE hnd) {
-  ICOM_THIS(SysKeyboardAImpl,iface);
+  ICOM_THIS(SysKeyboardImpl,iface);
 
   TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
 
@@ -466,7 +541,7 @@
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVCAPS lpDIDevCaps)
 {
-  ICOM_THIS(SysKeyboardAImpl,iface);
+  ICOM_THIS(SysKeyboardImpl,iface);
 
   TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
 
@@ -503,7 +578,7 @@
 	DWORD dwObj,
 	DWORD dwHow)
 {
-    ICOM_THIS(SysKeyboardAImpl,iface);
+    ICOM_THIS(SysKeyboardImpl,iface);
     DIDEVICEOBJECTINSTANCEA ddoi;
     DWORD dwSize = pdidoi->dwSize;
     
@@ -531,6 +606,39 @@
     return DI_OK;
 }
 
+static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
+						     LPDIDEVICEOBJECTINSTANCEW pdidoi,
+						     DWORD dwObj,
+						     DWORD dwHow)
+{
+    ICOM_THIS(SysKeyboardImpl,iface);
+    DIDEVICEOBJECTINSTANCEW ddoi;
+    DWORD dwSize = pdidoi->dwSize;
+    
+    TRACE("(this=%p,%p,%ld,0x%08lx)\n", This, pdidoi, dwObj, dwHow);
+
+    if (dwHow == DIPH_BYID) {
+        WARN(" querying by id not supported yet...\n");
+	return DI_OK;
+    }
+
+    memset(pdidoi, 0, dwSize);
+    memset(&ddoi, 0, sizeof(ddoi));
+
+    ddoi.dwSize = dwSize;
+    ddoi.guidType = GUID_Key;
+    ddoi.dwOfs = dwObj;
+    ddoi.dwType = DIDFT_MAKEINSTANCE(dwObj) | DIDFT_BUTTON;
+    GetKeyNameTextW(((dwObj & 0x7f) << 16) | ((dwObj & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName));
+
+    /* And return our just filled device object instance structure */
+    memcpy(pdidoi, &ddoi, (dwSize < sizeof(ddoi) ? dwSize : sizeof(ddoi)));
+    
+    _dump_OBJECTINSTANCEW(pdidoi);
+
+    return DI_OK;
+}
+
 /******************************************************************************
   *     GetDeviceInfo : get information about a device's identity
   */
@@ -538,7 +646,7 @@
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVICEINSTANCEA pdidi)
 {
-    ICOM_THIS(SysKeyboardAImpl,iface);
+    ICOM_THIS(SysKeyboardImpl,iface);
     TRACE("(this=%p,%p)\n", This, pdidi);
 
     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
@@ -546,11 +654,25 @@
 	return DI_OK;
     }
 
-    fill_keyboard_dideviceinstancea(pdidi, This->dinput->version);
+    fill_keyboard_dideviceinstanceA(pdidi, This->dinput->version);
     
     return DI_OK;
 }
 
+static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) 
+{
+    ICOM_THIS(SysKeyboardImpl,iface);
+    TRACE("(this=%p,%p)\n", This, pdidi);
+
+    if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
+        WARN(" dinput3 not supporte yet...\n");
+	return DI_OK;
+    }
+
+    fill_keyboard_dideviceinstanceW(pdidi, This->dinput->version);
+    
+    return DI_OK;
+}
 
 static ICOM_VTABLE(IDirectInputDevice8A) SysKeyboardAvt =
 {
@@ -588,3 +710,47 @@
         IDirectInputDevice8AImpl_SetActionMap,
         IDirectInputDevice8AImpl_GetImageInfo
 };
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(SysKeyboardWvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static ICOM_VTABLE(IDirectInputDevice8W) SysKeyboardWvt =
+{
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectInputDevice2WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
+	XCAST(Release)SysKeyboardAImpl_Release,
+	XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
+	SysKeyboardWImpl_EnumObjects,
+	XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
+	XCAST(SetProperty)SysKeyboardAImpl_SetProperty,
+	XCAST(Acquire)SysKeyboardAImpl_Acquire,
+	XCAST(Unacquire)SysKeyboardAImpl_Unacquire,
+	XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
+	XCAST(GetDeviceData)SysKeyboardAImpl_GetDeviceData,
+	XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
+	XCAST(SetEventNotification)SysKeyboardAImpl_SetEventNotification,
+	XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
+	SysKeyboardWImpl_GetObjectInfo,
+	SysKeyboardWImpl_GetDeviceInfo,
+	XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
+	XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
+	IDirectInputDevice2WImpl_EnumEffects,
+	IDirectInputDevice2WImpl_GetEffectInfo,
+	XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
+	XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+	XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+	XCAST(Escape)IDirectInputDevice2AImpl_Escape,
+	XCAST(Poll)IDirectInputDevice2AImpl_Poll,
+        XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+        IDirectInputDevice7WImpl_EnumEffectsInFile,
+        IDirectInputDevice7WImpl_WriteEffectToFile,
+        IDirectInputDevice8WImpl_BuildActionMap,
+        IDirectInputDevice8WImpl_SetActionMap,
+        IDirectInputDevice8WImpl_GetImageInfo
+};
+#undef XCAST
Index: mouse/main.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/mouse/main.c,v
retrieving revision 1.23
diff -u -r1.23 main.c
--- mouse/main.c	13 Jun 2003 18:55:41 -0000	1.23
+++ mouse/main.c	14 Jun 2003 09:47:18 -0000
@@ -33,6 +33,7 @@
 #include "dinput_private.h"
 #include "device_private.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
 
 #define MOUSE_HACK
 
@@ -92,7 +93,9 @@
 };
 
 static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt;
-typedef struct SysMouseAImpl SysMouseAImpl;
+static ICOM_VTABLE(IDirectInputDevice8W) SysMouseWvt;
+
+typedef struct SysMouseImpl SysMouseImpl;
 
 typedef enum {
   WARP_NEEDED,  /* Warping is needed */
@@ -100,13 +103,13 @@
   WARP_DONE     /* Warping has been done */
 } WARP_STATUS;
 
-struct SysMouseAImpl
+struct SysMouseImpl
 {
         LPVOID                          lpVtbl;
         DWORD                           ref;
         GUID                            guid;
 
-	IDirectInputAImpl *dinput;
+	IDirectInputImpl               *dinput;
 
 	/* The current data format and the conversion between internal
 	   and external data formats */
@@ -146,7 +149,7 @@
   {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
 };
 
-static void fill_mouse_dideviceinstancea(LPDIDEVICEINSTANCEA lpddi, int version) {
+static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
     DWORD dwSize;
     DIDEVICEINSTANCEA ddi;
     
@@ -170,14 +173,53 @@
     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
 }
 
-static BOOL mousedev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
+    DWORD dwSize;
+    DIDEVICEINSTANCEW ddi;
+    
+    dwSize = lpddi->dwSize;
+
+    TRACE("%ld %p\n", dwSize, lpddi);
+    
+    memset(lpddi, 0, dwSize);
+    memset(&ddi, 0, sizeof(ddi));
+
+    ddi.dwSize = dwSize;
+    ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
+    ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
+    if (version >= 8)
+        ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
+    else
+        ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
+    MultiByteToWideChar(CP_ACP, 0, "Mouse", -1, ddi.tszInstanceName, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, "Wine Mouse", -1, ddi.tszProductName, MAX_PATH);
+
+    memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
+}
+
+static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
+{
+  if ((dwDevType == 0) ||
+      ((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
+      ((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
+    TRACE("Enumerating the mouse device\n");
+
+    fill_mouse_dideviceinstanceA(lpddi, version);
+
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
 {
   if ((dwDevType == 0) ||
       ((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
       ((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
     TRACE("Enumerating the mouse device\n");
 
-    fill_mouse_dideviceinstancea(lpddi, version);
+    fill_mouse_dideviceinstanceW(lpddi, version);
 
     return TRUE;
   }
@@ -185,7 +227,7 @@
   return FALSE;
 }
 
-static SysMouseAImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputAImpl *dinput)
+static SysMouseImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
 {
     int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
       FIELD_OFFSET(Wine_InternalMouseData, lX),
@@ -195,8 +237,8 @@
       FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 1,
       FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 2
     };
-    SysMouseAImpl* newDevice;
-    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseAImpl));
+    SysMouseImpl* newDevice;
+    newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
     newDevice->ref = 1;
     newDevice->lpVtbl = mvt;
     InitializeCriticalSection(&(newDevice->crit));
@@ -214,7 +256,7 @@
     return newDevice;
 }
 
-static HRESULT mousedev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
 {
   if ((IsEqualGUID(&GUID_SysMouse,rguid)) ||             /* Generic Mouse */
       (IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
@@ -223,7 +265,7 @@
 	IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
 	IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
 	IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
-      *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
+      *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
       TRACE("Creating a Mouse device (%p)\n", *pdev);
       return DI_OK;
     } else
@@ -233,10 +275,30 @@
   return DIERR_DEVICENOTREG;
 }
 
+static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
+{
+  if ((IsEqualGUID(&GUID_SysMouse,rguid)) ||             /* Generic Mouse */
+      (IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
+    if ((riid == NULL) ||
+	IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
+	IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
+      *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
+      TRACE("Creating a Mouse device (%p)\n", *pdev);
+      return DI_OK;
+    } else
+      return DIERR_NOINTERFACE;
+  }
+
+  return DIERR_DEVICENOTREG;
+}
 static dinput_device mousedev = {
   100,
-  mousedev_enum_device,
-  mousedev_create_device
+  mousedev_enum_deviceA,
+  mousedev_enum_deviceW,
+  mousedev_create_deviceA,
+  mousedev_create_deviceW
 };
 
 DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
@@ -250,7 +312,7 @@
   */
 static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
 {
-	ICOM_THIS(SysMouseAImpl,iface);
+	ICOM_THIS(SysMouseImpl,iface);
 
 	This->ref--;
 	if (This->ref)
@@ -286,7 +348,7 @@
 	LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
 )
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
 
   TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
 
@@ -316,7 +378,7 @@
 	LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
 )
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
   int i;
 
   TRACE("(this=%p,%p)\n",This,df);
@@ -357,7 +419,7 @@
 {
     LRESULT ret;
     MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
-    SysMouseAImpl* This = (SysMouseAImpl*) current_lock;
+    SysMouseImpl* This = (SysMouseImpl*) current_lock;
     DWORD dwCoop;
     static long last_event = 0;
     int wdata;
@@ -489,7 +551,7 @@
 }
 
 
-static void dinput_window_check(SysMouseAImpl* This)
+static void dinput_window_check(SysMouseImpl* This)
 {
   RECT rect;
   DWORD centerX, centerY;
@@ -513,7 +575,7 @@
   */
 static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
   RECT	rect;
 
   TRACE("(this=%p)\n",This);
@@ -575,7 +637,7 @@
   */
 static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
 {
-    ICOM_THIS(SysMouseAImpl,iface);
+    ICOM_THIS(SysMouseImpl,iface);
 
     TRACE("(this=%p)\n",This);
 
@@ -610,7 +672,7 @@
 static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
 	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
 ) {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
 
   EnterCriticalSection(&(This->crit));
   TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
@@ -656,7 +718,7 @@
 					      LPDWORD entries,
 					      DWORD flags
 ) {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
   DWORD len, nqtail;
 
   TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
@@ -731,7 +793,7 @@
 					    REFGUID rguid,
 					    LPCDIPROPHEADER ph)
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
 
   TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
 
@@ -771,7 +833,7 @@
 						REFGUID rguid,
 						LPDIPROPHEADER pdiph)
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
 
   TRACE("(this=%p,%s,%p): stub!\n",
 	iface, debugstr_guid(rguid), pdiph);
@@ -831,7 +893,7 @@
   */
 static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
 							 HANDLE hnd) {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
 
   TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
 
@@ -847,7 +909,7 @@
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVCAPS lpDIDevCaps)
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
 
   TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
 
@@ -883,7 +945,7 @@
 	LPVOID lpvRef,
 	DWORD dwFlags)
 {
-  ICOM_THIS(SysMouseAImpl,iface);
+  ICOM_THIS(SysMouseImpl,iface);
   DIDEVICEOBJECTINSTANCEA ddoi;
 
   TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
@@ -954,6 +1016,18 @@
   return DI_OK;
 }
 
+static HRESULT WINAPI SysMouseWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,	LPVOID lpvRef,DWORD dwFlags)
+{
+  ICOM_THIS(SysMouseImpl,iface);
+
+  device_enumobjects_AtoWcb_data data;
+
+  data.lpCallBack = lpCallback;
+  data.lpvRef = lpvRef;
+
+  return SysMouseAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
+}
+
 /******************************************************************************
   *     GetDeviceInfo : get information about a device's identity
   */
@@ -961,7 +1035,7 @@
 	LPDIRECTINPUTDEVICE8A iface,
 	LPDIDEVICEINSTANCEA pdidi)
 {
-    ICOM_THIS(SysMouseAImpl,iface);
+    ICOM_THIS(SysMouseImpl,iface);
     TRACE("(this=%p,%p)\n", This, pdidi);
 
     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
@@ -969,11 +1043,27 @@
 	return DI_OK;
     }
 
-    fill_mouse_dideviceinstancea(pdidi, This->dinput->version);
+    fill_mouse_dideviceinstanceA(pdidi, This->dinput->version);
     
     return DI_OK;
 }
 
+static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
+{
+    ICOM_THIS(SysMouseImpl,iface);
+    TRACE("(this=%p,%p)\n", This, pdidi);
+
+    if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
+        WARN(" dinput3 not supporte yet...\n");
+	return DI_OK;
+    }
+
+    fill_mouse_dideviceinstanceW(pdidi, This->dinput->version);
+    
+    return DI_OK;
+}
+
+
 static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt =
 {
 	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
@@ -1010,3 +1100,47 @@
         IDirectInputDevice8AImpl_SetActionMap,
         IDirectInputDevice8AImpl_GetImageInfo
 };
+
+#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
+# define XCAST(fun)	(typeof(SysMouseWvt.fun))
+#else
+# define XCAST(fun)	(void*)
+#endif
+
+static ICOM_VTABLE(IDirectInputDevice8W) SysMouseWvt =
+{
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectInputDevice2WImpl_QueryInterface,
+	XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
+	XCAST(Release)SysMouseAImpl_Release,
+	XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,
+	SysMouseWImpl_EnumObjects,
+	XCAST(GetProperty)SysMouseAImpl_GetProperty,
+	XCAST(SetProperty)SysMouseAImpl_SetProperty,
+	XCAST(Acquire)SysMouseAImpl_Acquire,
+	XCAST(Unacquire)SysMouseAImpl_Unacquire,
+	XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState,
+	XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData,
+	XCAST(SetDataFormat)SysMouseAImpl_SetDataFormat,
+	XCAST(SetEventNotification)SysMouseAImpl_SetEventNotification,
+	XCAST(SetCooperativeLevel)SysMouseAImpl_SetCooperativeLevel,
+	IDirectInputDevice2WImpl_GetObjectInfo,
+	SysMouseWImpl_GetDeviceInfo,
+	XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
+	XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
+	XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
+	IDirectInputDevice2WImpl_EnumEffects,
+	IDirectInputDevice2WImpl_GetEffectInfo,
+	XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
+	XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+	XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+	XCAST(Escape)IDirectInputDevice2AImpl_Escape,
+	XCAST(Poll)IDirectInputDevice2AImpl_Poll,
+	XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+        IDirectInputDevice7WImpl_EnumEffectsInFile,
+        IDirectInputDevice7WImpl_WriteEffectToFile,
+        IDirectInputDevice8WImpl_BuildActionMap,
+        IDirectInputDevice8WImpl_SetActionMap,
+        IDirectInputDevice8WImpl_GetImageInfo
+};
+#undef XCAST

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

  Powered by Linux