Commit 7c4e91f6 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Move CreateEffect generic implementation to device.c.

parent 4ddd257f
......@@ -1645,20 +1645,37 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface,
return DI_OK;
}
/******************************************************************************
* IDirectInputDevice2A
*/
HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIEFFECT lpeff,
LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter)
HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect( IDirectInputDevice8W *iface, const GUID *guid,
const DIEFFECT *params, IDirectInputEffect **out,
IUnknown *outer )
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
FIXME("(%p)->(%s,%p,%p,%p): stub!\n", This, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
if (!ppdef) return E_POINTER;
IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface );
DWORD flags = DIEP_ALLPARAMS;
HRESULT hr;
FIXME("not available in the generic implementation\n");
*ppdef = NULL;
return DIERR_UNSUPPORTED;
TRACE( "iface %p, guid %s, params %p, out %p, outer %p\n", iface, debugstr_guid( guid ),
params, out, outer );
if (!out) return E_POINTER;
*out = NULL;
if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
if (!impl->vtbl->create_effect) return DIERR_UNSUPPORTED;
if (FAILED(hr = impl->vtbl->create_effect( iface, out ))) return hr;
hr = IDirectInputEffect_Initialize( *out, DINPUT_instance, impl->dinput->dwVersion, guid );
if (FAILED(hr)) goto failed;
if (!params) return DI_OK;
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) flags |= DIEP_NODOWNLOAD;
hr = IDirectInputEffect_SetParameters( *out, params, flags );
if (FAILED(hr)) goto failed;
return hr;
failed:
IDirectInputEffect_Release( *out );
*out = NULL;
return hr;
}
HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback,
......
......@@ -69,6 +69,7 @@ struct dinput_device_vtbl
HRESULT (*set_property)( IDirectInputDevice8W *iface, DWORD property, const DIPROPHEADER *header,
const DIDEVICEOBJECTINSTANCEW *instance );
HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid );
HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out );
};
#define DEVICE_STATE_MAX_SIZE 1024
......
......@@ -803,40 +803,7 @@ static HRESULT hid_joystick_internal_unacquire( IDirectInputDevice8W *iface )
return DI_OK;
}
static HRESULT hid_joystick_effect_create( struct hid_joystick *joystick, IDirectInputEffect **out );
static HRESULT WINAPI hid_joystick_CreateEffect( IDirectInputDevice8W *iface, const GUID *guid,
const DIEFFECT *params, IDirectInputEffect **out,
IUnknown *outer )
{
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
DWORD flags = DIEP_ALLPARAMS;
HRESULT hr;
TRACE( "iface %p, guid %s, params %p, out %p, outer %p\n", iface, debugstr_guid( guid ),
params, out, outer );
if (!out) return E_POINTER;
*out = NULL;
if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
if (FAILED(hr = hid_joystick_effect_create( impl, out ))) return hr;
hr = IDirectInputEffect_Initialize( *out, DINPUT_instance, impl->base.dinput->dwVersion, guid );
if (FAILED(hr)) goto failed;
if (!params) return DI_OK;
if (!impl->base.acquired || !(impl->base.dwCoopLevel & DISCL_EXCLUSIVE))
flags |= DIEP_NODOWNLOAD;
hr = IDirectInputEffect_SetParameters( *out, params, flags );
if (FAILED(hr)) goto failed;
return hr;
failed:
IDirectInputEffect_Release( *out );
*out = NULL;
return hr;
}
static HRESULT hid_joystick_internal_create_effect( IDirectInputDevice8W *iface, IDirectInputEffect **out );
static HRESULT hid_joystick_internal_get_effect_info( IDirectInputDevice8W *iface, DIEFFECTINFOW *info,
const GUID *guid )
......@@ -1068,7 +1035,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
IDirectInputDevice2WImpl_RunControlPanel,
IDirectInputDevice2WImpl_Initialize,
/*** IDirectInputDevice2 methods ***/
hid_joystick_CreateEffect,
IDirectInputDevice2WImpl_CreateEffect,
IDirectInputDevice2WImpl_EnumEffects,
IDirectInputDevice2WImpl_GetEffectInfo,
IDirectInputDevice2WImpl_GetForceFeedbackState,
......@@ -1312,6 +1279,7 @@ static const struct dinput_device_vtbl hid_joystick_internal_vtbl =
hid_joystick_internal_get_property,
hid_joystick_internal_set_property,
hid_joystick_internal_get_effect_info,
hid_joystick_internal_create_effect,
};
static DWORD device_type_for_version( DWORD type, DWORD version )
......@@ -2826,8 +2794,9 @@ static IDirectInputEffectVtbl hid_joystick_effect_vtbl =
hid_joystick_effect_Escape,
};
static HRESULT hid_joystick_effect_create( struct hid_joystick *joystick, IDirectInputEffect **out )
static HRESULT hid_joystick_internal_create_effect( IDirectInputDevice8W *iface, IDirectInputEffect **out )
{
struct hid_joystick *joystick = impl_from_IDirectInputDevice8W( iface );
struct hid_joystick_effect *impl;
ULONG report_len;
......
......@@ -339,6 +339,7 @@ static const struct dinput_device_vtbl keyboard_internal_vtbl =
keyboard_internal_get_property,
keyboard_internal_set_property,
NULL,
NULL,
};
static const IDirectInputDevice8WVtbl SysKeyboardWvt =
......
......@@ -652,6 +652,7 @@ static const struct dinput_device_vtbl mouse_internal_vtbl =
mouse_internal_get_property,
mouse_internal_set_property,
NULL,
NULL,
};
static const IDirectInputDevice8WVtbl SysMouseWvt =
......
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