dinput: Use dinput device as a base class for keyboard,  mouse and joystick.
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index a2777c2..b5c88bf 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -30,9 +30,9 @@
 typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
 struct IDirectInputDevice2AImpl
 {
-        const IDirectInputDevice2AVtbl *lpVtbl;
-        LONG                            ref;
-        GUID                            guid;
+    const void                 *lpVtbl;
+    LONG                        ref;
+    GUID                        guid;
 };
 
 /* Routines to do DataFormat / WineFormat conversions */
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 62a59c1..885d91f 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -89,9 +89,8 @@
 static const IDirectInputDevice8WVtbl JoystickWvt;
 struct JoystickImpl
 {
-        const void                     *lpVtbl;
-        LONG                            ref;
-        GUID                            guid;
+        struct IDirectInputDevice2AImpl base;
+
 	char				dev[32];
 
 	/* The 'parent' DInput */
@@ -495,12 +494,12 @@
     }
 #endif
 
-    newDevice->lpVtbl = jvt;
-    newDevice->ref = 1;
+    newDevice->base.lpVtbl = jvt;
+    newDevice->base.ref = 1;
     newDevice->dinput = dinput;
     newDevice->acquired = FALSE;
     newDevice->overflow = FALSE;
-    CopyMemory(&(newDevice->guid),rguid,sizeof(*rguid));
+    CopyMemory(&newDevice->base.guid, rguid, sizeof(*rguid));
 
     /* setup_dinput_options may change these */
     newDevice->deadzone = 5000;
@@ -672,7 +671,7 @@
     JoystickImpl *This = (JoystickImpl *)iface;
     ULONG ref;
 
-    ref = InterlockedDecrement((&This->ref));
+    ref = InterlockedDecrement(&This->base.ref);
     if (ref)
         return ref;
 
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index ef8af3d..335dc89 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -118,9 +118,8 @@
 
 struct JoystickImpl
 {
-        const void                     *lpVtbl;
-        LONG                            ref;
-        GUID                            guid;
+        struct IDirectInputDevice2AImpl base;
+
         struct JoyDev                  *joydev;
 
 	/* The 'parent' DInput */
@@ -373,15 +372,15 @@
     return NULL;
   }
 
-  newDevice->lpVtbl = jvt;
-  newDevice->ref = 1;
+  newDevice->base.lpVtbl = jvt;
+  newDevice->base.ref = 1;
+  memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
   newDevice->joyfd = -1;
   newDevice->dinput = dinput;
   newDevice->joydev = joydev;
 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
   newDevice->ff_state = FF_STATUS_STOPPED;
 #endif
-  memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
   for (i=0;i<ABS_MAX;i++) {
     /* apps expect the range to be the same they would get from the
      * GetProperty/range method */
@@ -522,7 +521,7 @@
 	JoystickImpl *This = (JoystickImpl *)iface;
 	ULONG ref;
 
-	ref = InterlockedDecrement(&(This->ref));
+	ref = InterlockedDecrement(&This->base.ref);
 	if (ref)
 		return ref;
 
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index 8cff814..8dcf063 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -46,9 +46,7 @@
 typedef struct SysKeyboardImpl SysKeyboardImpl;
 struct SysKeyboardImpl
 {
-    const void                 *lpVtbl;
-    LONG                        ref;
-    GUID                        guid;
+    struct IDirectInputDevice2AImpl base;
 
     IDirectInputImpl*           dinput;
 
@@ -204,9 +202,9 @@
     SysKeyboardImpl* newDevice;
 
     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
-    newDevice->lpVtbl = kvt;
-    newDevice->ref = 1;
-    memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
+    newDevice->base.lpVtbl = kvt;
+    newDevice->base.ref = 1;
+    memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
     newDevice->dinput = dinput;
     InitializeCriticalSection(&(newDevice->crit));
 
@@ -263,7 +261,7 @@
     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
     ULONG ref;
 
-    ref = InterlockedDecrement(&(This->ref));
+    ref = InterlockedDecrement(&This->base.ref);
     if (ref) return ref;
 
     set_dinput_hook(WH_KEYBOARD_LL, NULL);
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index b426af1..894dcb2 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -108,9 +108,7 @@
 
 struct SysMouseImpl
 {
-    const void                     *lpVtbl;
-    LONG                            ref;
-    GUID                            guid;
+    struct IDirectInputDevice2AImpl base;
     
     IDirectInputImpl               *dinput;
     
@@ -251,10 +249,10 @@
     };
     SysMouseImpl* newDevice;
     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
-    newDevice->ref = 1;
-    newDevice->lpVtbl = mvt;
+    newDevice->base.lpVtbl = mvt;
+    newDevice->base.ref = 1;
+    memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
     InitializeCriticalSection(&(newDevice->crit));
-    memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
 
     /* Per default, Wine uses its internal data format */
     newDevice->df = (DIDATAFORMAT *) &Wine_InternalMouseFormat;
@@ -327,7 +325,7 @@
     SysMouseImpl *This = (SysMouseImpl *)iface;
     ULONG ref;
  
-    ref = InterlockedDecrement(&(This->ref));
+    ref = InterlockedDecrement(&This->base.ref);
     if (ref)
 	return ref;