From fb1082ae737e9d5eea68c1c5e9b42df2589cce1e Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Wed, 27 Jun 2007 06:58:27 -0600 Subject: [PATCH] dinput: Combine all Release functionality into base class. --- dlls/dinput/device.c | 20 +++++++++++--- dlls/dinput/joystick_linux.c | 43 ++----------------------------- dlls/dinput/joystick_linuxinput.c | 37 ++------------------------ dlls/dinput/keyboard.c | 29 ++------------------- dlls/dinput/mouse.c | 33 ++---------------------- 5 files changed, 24 insertions(+), 138 deletions(-) diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index b8fc781b8a5..35bf11704d5 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -677,8 +677,21 @@ ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ref = InterlockedDecrement(&(This->ref)); if (ref) return ref; - DeleteCriticalSection(&This->crit); + IDirectInputDevice_Unacquire(iface); + /* Reset the FF state, free all effects, etc */ + IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET); + HeapFree(GetProcessHeap(), 0, This->data_queue); + + /* Free data format */ + HeapFree(GetProcessHeap(), 0, This->data_format.wine_df->rgodf); + HeapFree(GetProcessHeap(), 0, This->data_format.wine_df); + release_DataFormat(&This->data_format); + + IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput); + This->crit.DebugInfo->Spare[0] = 0; + DeleteCriticalSection(&This->crit); + HeapFree(GetProcessHeap(), 0, This); return DI_OK; @@ -1173,9 +1186,8 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand( LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) { - FIXME("(this=%p,0x%08x): stub!\n", - iface, dwFlags); - return DI_OK; + TRACE("(%p) 0x%08x:\n", iface, dwFlags); + return DI_NOEFFECT; } HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects( diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index acd49307271..57f1d7a31db 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -631,45 +631,6 @@ const struct dinput_device joystick_linux_device = { joydev_create_deviceW }; -/****************************************************************************** - * Joystick - */ -static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickImpl *This = (JoystickImpl *)iface; - ULONG ref; - - ref = InterlockedDecrement(&This->base.ref); - if (ref) - return ref; - - IDirectInputDevice_Unacquire(iface); - - /* Free the device name */ - HeapFree(GetProcessHeap(),0,This->name); - - /* Free the axis map */ - HeapFree(GetProcessHeap(),0,This->axis_map); - - /* Free the data queue */ - HeapFree(GetProcessHeap(), 0, This->base.data_queue); - - /* Free the properties */ - HeapFree(GetProcessHeap(), 0, This->props); - - /* release the data transform filter */ - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df->rgodf); - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df); - release_DataFormat(&This->base.data_format); - - This->base.crit.DebugInfo->Spare[0] = 0; - IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput); - DeleteCriticalSection(&This->base.crit); - - HeapFree(GetProcessHeap(),0,This); - return 0; -} - /****************************************************************************** * Acquire : gets exclusive control of the joystick */ @@ -1214,7 +1175,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = { IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_AddRef, - JoystickAImpl_Release, + IDirectInputDevice2AImpl_Release, JoystickAImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, JoystickAImpl_GetProperty, @@ -1256,7 +1217,7 @@ static const IDirectInputDevice8WVtbl SysJoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, - XCAST(Release)JoystickAImpl_Release, + XCAST(Release)IDirectInputDevice2AImpl_Release, XCAST(GetCapabilities)JoystickAImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, XCAST(GetProperty)JoystickAImpl_GetProperty, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index eff010a36ca..6a8dd447319 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -501,39 +501,6 @@ const struct dinput_device joystick_linuxinput_device = { joydev_create_deviceW }; -/****************************************************************************** - * Joystick - */ -static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface) -{ - JoystickImpl *This = (JoystickImpl *)iface; - ULONG ref; - - ref = InterlockedDecrement(&This->base.ref); - if (ref) - return ref; - - IDirectInputDevice_Unacquire(iface); - - /* Reset the FF state, free all effects, etc */ - IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET); - - /* Free the data queue */ - HeapFree(GetProcessHeap(), 0, This->base.data_queue); - - /* release the data transform filter */ - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df->rgodf); - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df); - release_DataFormat(&This->base.data_format); - - IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput); - This->base.crit.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&This->base.crit); - - HeapFree(GetProcessHeap(),0,This); - return 0; -} - /****************************************************************************** * Acquire : gets exclusive control of the joystick */ @@ -1325,7 +1292,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = { IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_AddRef, - JoystickAImpl_Release, + IDirectInputDevice2AImpl_Release, JoystickAImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, JoystickAImpl_GetProperty, @@ -1367,7 +1334,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = { IDirectInputDevice2WImpl_QueryInterface, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, - XCAST(Release)JoystickAImpl_Release, + XCAST(Release)IDirectInputDevice2AImpl_Release, XCAST(GetCapabilities)JoystickAImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, XCAST(GetProperty)JoystickAImpl_GetProperty, diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index def032c0a5e..c1eb5fb9ba8 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -271,31 +271,6 @@ const struct dinput_device keyboard_device = { keyboarddev_create_deviceW }; -static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface) -{ - SysKeyboardImpl *This = (SysKeyboardImpl *)iface; - ULONG ref; - - ref = InterlockedDecrement(&This->base.ref); - if (ref) return ref; - - IDirectInputDevice_Unacquire(iface); - - HeapFree(GetProcessHeap(), 0, This->base.data_queue); - - /* Free data format */ - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df->rgodf); - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df); - release_DataFormat(&This->base.data_format); - - IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput); - This->base.crit.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&This->base.crit); - HeapFree(GetProcessHeap(), 0, This); - - return DI_OK; -} - static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState( LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr ) @@ -487,7 +462,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = { IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_AddRef, - SysKeyboardAImpl_Release, + IDirectInputDevice2AImpl_Release, SysKeyboardAImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, IDirectInputDevice2AImpl_GetProperty, @@ -529,7 +504,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt = { IDirectInputDevice2WImpl_QueryInterface, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, - XCAST(Release)SysKeyboardAImpl_Release, + XCAST(Release)IDirectInputDevice2AImpl_Release, XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty, diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 22b3b90d99b..3c80e7e47f8 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -254,35 +254,6 @@ const struct dinput_device mouse_device = { * SysMouseA (DInput Mouse support) */ -/****************************************************************************** - * Release : release the mouse buffer. - */ -static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface) -{ - SysMouseImpl *This = (SysMouseImpl *)iface; - ULONG ref; - - ref = InterlockedDecrement(&This->base.ref); - if (ref) - return ref; - - IDirectInputDevice_Unacquire(iface); - - /* Free the data queue */ - HeapFree(GetProcessHeap(), 0, This->base.data_queue); - - /* Free data format */ - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df->rgodf); - HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df); - release_DataFormat(&This->base.data_format); - - IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->base.dinput); - This->base.crit.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&This->base.crit); - HeapFree(GetProcessHeap(),0,This); - return 0; -} - /* low-level mouse hook */ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lparam ) { @@ -738,7 +709,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt = { IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_AddRef, - SysMouseAImpl_Release, + IDirectInputDevice2AImpl_Release, SysMouseAImpl_GetCapabilities, IDirectInputDevice2AImpl_EnumObjects, SysMouseAImpl_GetProperty, @@ -780,7 +751,7 @@ static const IDirectInputDevice8WVtbl SysMouseWvt = { IDirectInputDevice2WImpl_QueryInterface, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, - XCAST(Release)SysMouseAImpl_Release, + XCAST(Release)IDirectInputDevice2AImpl_Release, XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, XCAST(GetProperty)SysMouseAImpl_GetProperty,