Commit fb1082ae authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Combine all Release functionality into base class.

parent d2966c2d
...@@ -677,8 +677,21 @@ ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ...@@ -677,8 +677,21 @@ ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
ref = InterlockedDecrement(&(This->ref)); ref = InterlockedDecrement(&(This->ref));
if (ref) return 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); 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); HeapFree(GetProcessHeap(), 0, This);
return DI_OK; return DI_OK;
...@@ -1173,9 +1186,8 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand( ...@@ -1173,9 +1186,8 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
LPDIRECTINPUTDEVICE8A iface, LPDIRECTINPUTDEVICE8A iface,
DWORD dwFlags) DWORD dwFlags)
{ {
FIXME("(this=%p,0x%08x): stub!\n", TRACE("(%p) 0x%08x:\n", iface, dwFlags);
iface, dwFlags); return DI_NOEFFECT;
return DI_OK;
} }
HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects( HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
......
...@@ -632,45 +632,6 @@ const struct dinput_device joystick_linux_device = { ...@@ -632,45 +632,6 @@ const struct dinput_device joystick_linux_device = {
}; };
/****************************************************************************** /******************************************************************************
* 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 * Acquire : gets exclusive control of the joystick
*/ */
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
...@@ -1214,7 +1175,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = ...@@ -1214,7 +1175,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
{ {
IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef, IDirectInputDevice2AImpl_AddRef,
JoystickAImpl_Release, IDirectInputDevice2AImpl_Release,
JoystickAImpl_GetCapabilities, JoystickAImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects, IDirectInputDevice2AImpl_EnumObjects,
JoystickAImpl_GetProperty, JoystickAImpl_GetProperty,
...@@ -1256,7 +1217,7 @@ static const IDirectInputDevice8WVtbl SysJoystickWvt = ...@@ -1256,7 +1217,7 @@ static const IDirectInputDevice8WVtbl SysJoystickWvt =
{ {
IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)JoystickAImpl_Release, XCAST(Release)IDirectInputDevice2AImpl_Release,
XCAST(GetCapabilities)JoystickAImpl_GetCapabilities, XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
IDirectInputDevice2WImpl_EnumObjects, IDirectInputDevice2WImpl_EnumObjects,
XCAST(GetProperty)JoystickAImpl_GetProperty, XCAST(GetProperty)JoystickAImpl_GetProperty,
......
...@@ -502,39 +502,6 @@ const struct dinput_device joystick_linuxinput_device = { ...@@ -502,39 +502,6 @@ const struct dinput_device joystick_linuxinput_device = {
}; };
/****************************************************************************** /******************************************************************************
* 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 * Acquire : gets exclusive control of the joystick
*/ */
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
...@@ -1325,7 +1292,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = ...@@ -1325,7 +1292,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
{ {
IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef, IDirectInputDevice2AImpl_AddRef,
JoystickAImpl_Release, IDirectInputDevice2AImpl_Release,
JoystickAImpl_GetCapabilities, JoystickAImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects, IDirectInputDevice2AImpl_EnumObjects,
JoystickAImpl_GetProperty, JoystickAImpl_GetProperty,
...@@ -1367,7 +1334,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = ...@@ -1367,7 +1334,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt =
{ {
IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)JoystickAImpl_Release, XCAST(Release)IDirectInputDevice2AImpl_Release,
XCAST(GetCapabilities)JoystickAImpl_GetCapabilities, XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
IDirectInputDevice2WImpl_EnumObjects, IDirectInputDevice2WImpl_EnumObjects,
XCAST(GetProperty)JoystickAImpl_GetProperty, XCAST(GetProperty)JoystickAImpl_GetProperty,
......
...@@ -271,31 +271,6 @@ const struct dinput_device keyboard_device = { ...@@ -271,31 +271,6 @@ const struct dinput_device keyboard_device = {
keyboarddev_create_deviceW 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( static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) )
...@@ -487,7 +462,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = ...@@ -487,7 +462,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt =
{ {
IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef, IDirectInputDevice2AImpl_AddRef,
SysKeyboardAImpl_Release, IDirectInputDevice2AImpl_Release,
SysKeyboardAImpl_GetCapabilities, SysKeyboardAImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects, IDirectInputDevice2AImpl_EnumObjects,
IDirectInputDevice2AImpl_GetProperty, IDirectInputDevice2AImpl_GetProperty,
...@@ -529,7 +504,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt = ...@@ -529,7 +504,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt =
{ {
IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)SysKeyboardAImpl_Release, XCAST(Release)IDirectInputDevice2AImpl_Release,
XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities, XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
IDirectInputDevice2WImpl_EnumObjects, IDirectInputDevice2WImpl_EnumObjects,
XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty, XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
......
...@@ -254,35 +254,6 @@ const struct dinput_device mouse_device = { ...@@ -254,35 +254,6 @@ const struct dinput_device mouse_device = {
* SysMouseA (DInput Mouse support) * 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 */ /* low-level mouse hook */
static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lparam ) static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lparam )
{ {
...@@ -738,7 +709,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt = ...@@ -738,7 +709,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt =
{ {
IDirectInputDevice2AImpl_QueryInterface, IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef, IDirectInputDevice2AImpl_AddRef,
SysMouseAImpl_Release, IDirectInputDevice2AImpl_Release,
SysMouseAImpl_GetCapabilities, SysMouseAImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects, IDirectInputDevice2AImpl_EnumObjects,
SysMouseAImpl_GetProperty, SysMouseAImpl_GetProperty,
...@@ -780,7 +751,7 @@ static const IDirectInputDevice8WVtbl SysMouseWvt = ...@@ -780,7 +751,7 @@ static const IDirectInputDevice8WVtbl SysMouseWvt =
{ {
IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_QueryInterface,
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef, XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
XCAST(Release)SysMouseAImpl_Release, XCAST(Release)IDirectInputDevice2AImpl_Release,
XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities, XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,
IDirectInputDevice2WImpl_EnumObjects, IDirectInputDevice2WImpl_EnumObjects,
XCAST(GetProperty)SysMouseAImpl_GetProperty, XCAST(GetProperty)SysMouseAImpl_GetProperty,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment