dinput: Combine all Release functionality into base class.

This commit is contained in:
Vitaliy Margolen 2007-06-27 06:58:27 -06:00 committed by Alexandre Julliard
parent d2966c2dfb
commit fb1082ae73
5 changed files with 24 additions and 138 deletions

View file

@ -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(

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,