dinput: Cleanup IDirectInput7W names and traces.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-02-07 09:23:28 +01:00 committed by Alexandre Julliard
parent 44f7ccfcd1
commit d33103bf05
1 changed files with 86 additions and 98 deletions

View File

@ -55,7 +55,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput); WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static const IDirectInput7WVtbl ddi7wvt; static const IDirectInput7WVtbl dinput7_vtbl;
static const IDirectInput8WVtbl ddi8wvt; static const IDirectInput8WVtbl ddi8wvt;
static const IDirectInputJoyConfig8Vtbl joy_config_vtbl; static const IDirectInputJoyConfig8Vtbl joy_config_vtbl;
@ -146,7 +146,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IDirectInput7A_iface.lpVtbl = &dinput7_a_vtbl; This->IDirectInput7A_iface.lpVtbl = &dinput7_a_vtbl;
This->IDirectInput7W_iface.lpVtbl = &ddi7wvt; This->IDirectInput7W_iface.lpVtbl = &dinput7_vtbl;
This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl;
This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; This->IDirectInput8W_iface.lpVtbl = &ddi8wvt;
This->IDirectInputJoyConfig8_iface.lpVtbl = &joy_config_vtbl; This->IDirectInputJoyConfig8_iface.lpVtbl = &joy_config_vtbl;
@ -321,12 +321,12 @@ __ASM_GLOBAL_FUNC( enum_callback_wrapper,
/****************************************************************************** /******************************************************************************
* IDirectInputW_EnumDevices * IDirectInputW_EnumDevices
*/ */
static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, static HRESULT WINAPI dinput7_EnumDevices( IDirectInput7W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback,
void *context, DWORD flags ) void *context, DWORD flags )
{ {
IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags ); TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x.\n", iface, type, callback, context, flags );
if (!callback) return DIERR_INVALIDPARAM; if (!callback) return DIERR_INVALIDPARAM;
@ -337,73 +337,70 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWOR
return IDirectInput8_EnumDevices( &impl->IDirectInput8W_iface, type, callback, context, flags ); return IDirectInput8_EnumDevices( &impl->IDirectInput8W_iface, type, callback, context, flags );
} }
static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) static ULONG WINAPI dinput7_AddRef( IDirectInput7W *iface )
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
ULONG ref = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p increasing refcount to %u.\n", iface, ref );
TRACE( "(%p) ref %d\n", This, ref );
return ref; return ref;
} }
static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) static ULONG WINAPI dinput7_Release( IDirectInput7W *iface )
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
ULONG ref = InterlockedDecrement( &This->ref ); ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "(%p) ref %d\n", This, ref ); TRACE( "iface %p decreasing refcount to %u.\n", iface, ref );
if (ref == 0) if (ref == 0)
{ {
uninitialize_directinput_instance( This ); uninitialize_directinput_instance( impl );
free( This ); free( impl );
} }
return ref; return ref;
} }
static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, REFIID riid, LPVOID *ppobj ) static HRESULT WINAPI dinput7_QueryInterface( IDirectInput7W *iface, REFIID iid, void **out )
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
TRACE( "(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
if (!riid || !ppobj) if (!iid || !out) return E_POINTER;
return E_POINTER;
*ppobj = NULL; *out = NULL;
#if DIRECTINPUT_VERSION == 0x0700 #if DIRECTINPUT_VERSION == 0x0700
if (IsEqualGUID( &IID_IDirectInputA, riid ) || if (IsEqualGUID( &IID_IDirectInputA, iid ) ||
IsEqualGUID( &IID_IDirectInput2A, riid ) || IsEqualGUID( &IID_IDirectInput2A, iid ) ||
IsEqualGUID( &IID_IDirectInput7A, riid )) IsEqualGUID( &IID_IDirectInput7A, iid ))
*ppobj = &This->IDirectInput7A_iface; *out = &impl->IDirectInput7A_iface;
else if (IsEqualGUID( &IID_IUnknown, riid ) || else if (IsEqualGUID( &IID_IUnknown, iid ) ||
IsEqualGUID( &IID_IDirectInputW, riid ) || IsEqualGUID( &IID_IDirectInputW, iid ) ||
IsEqualGUID( &IID_IDirectInput2W, riid ) || IsEqualGUID( &IID_IDirectInput2W, iid ) ||
IsEqualGUID( &IID_IDirectInput7W, riid )) IsEqualGUID( &IID_IDirectInput7W, iid ))
*ppobj = &This->IDirectInput7W_iface; *out = &impl->IDirectInput7W_iface;
#else #else
if (IsEqualGUID( &IID_IDirectInput8A, riid )) if (IsEqualGUID( &IID_IDirectInput8A, iid ))
*ppobj = &This->IDirectInput8A_iface; *out = &impl->IDirectInput8A_iface;
else if (IsEqualGUID( &IID_IUnknown, iid ) ||
else if (IsEqualGUID( &IID_IUnknown, riid ) || IsEqualGUID( &IID_IDirectInput8W, iid ))
IsEqualGUID( &IID_IDirectInput8W, riid )) *out = &impl->IDirectInput8W_iface;
*ppobj = &This->IDirectInput8W_iface;
#endif #endif
if (IsEqualGUID( &IID_IDirectInputJoyConfig8, riid )) if (IsEqualGUID( &IID_IDirectInputJoyConfig8, iid ))
*ppobj = &This->IDirectInputJoyConfig8_iface; *out = &impl->IDirectInputJoyConfig8_iface;
if(*ppobj) if (*out)
{ {
IUnknown_AddRef( (IUnknown*)*ppobj ); IUnknown_AddRef( (IUnknown *)*out );
return DI_OK; return DI_OK;
} }
WARN( "Unsupported interface: %s\n", debugstr_guid(riid)); WARN( "Unsupported interface: %s\n", debugstr_guid( iid ) );
return E_NOINTERFACE; return E_NOINTERFACE;
} }
@ -453,32 +450,31 @@ static void unregister_di_em_win_class(void)
WARN( "Unable to unregister message window class\n" ); WARN( "Unable to unregister message window class\n" );
} }
static HRESULT initialize_directinput_instance(IDirectInputImpl *This, DWORD dwVersion) static HRESULT initialize_directinput_instance( IDirectInputImpl *impl, DWORD version )
{ {
if (!This->initialized) if (!impl->initialized)
{ {
This->dwVersion = dwVersion; impl->dwVersion = version;
This->evsequence = 1; impl->evsequence = 1;
list_init( &This->device_players ); list_init( &impl->device_players );
This->initialized = TRUE; impl->initialized = TRUE;
} }
return DI_OK; return DI_OK;
} }
static void uninitialize_directinput_instance(IDirectInputImpl *This) static void uninitialize_directinput_instance( IDirectInputImpl *impl )
{ {
if (This->initialized) if (impl->initialized)
{ {
struct DevicePlayer *device_player, *device_player2; struct DevicePlayer *device_player, *device_player2;
LIST_FOR_EACH_ENTRY_SAFE( device_player, device_player2, LIST_FOR_EACH_ENTRY_SAFE ( device_player, device_player2, &impl->device_players, struct DevicePlayer, entry )
&This->device_players, struct DevicePlayer, entry )
free( device_player ); free( device_player );
This->initialized = FALSE; impl->initialized = FALSE;
} }
} }
@ -493,11 +489,11 @@ enum directinput_versions
DIRECTINPUT_VERSION_700 = 0x0700, DIRECTINPUT_VERSION_700 = 0x0700,
}; };
static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINSTANCE hinst, DWORD version ) static HRESULT WINAPI dinput7_Initialize( IDirectInput7W *iface, HINSTANCE hinst, DWORD version )
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
TRACE("(%p)->(%p, 0x%04x)\n", This, hinst, version); TRACE( "iface %p, hinst %p, version %#x.\n", iface, hinst, version );
if (!hinst) if (!hinst)
return DIERR_INVALIDPARAM; return DIERR_INVALIDPARAM;
@ -511,22 +507,21 @@ static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINST
version != DIRECTINPUT_VERSION_700 && version != DIRECTINPUT_VERSION) version != DIRECTINPUT_VERSION_700 && version != DIRECTINPUT_VERSION)
return DIERR_BETADIRECTINPUTVERSION; return DIERR_BETADIRECTINPUTVERSION;
return initialize_directinput_instance(This, version); return initialize_directinput_instance( impl, version );
} }
static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, REFGUID rguid ) static HRESULT WINAPI dinput7_GetDeviceStatus( IDirectInput7W *iface, const GUID *guid )
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
HRESULT hr; HRESULT hr;
IDirectInputDeviceW *device; IDirectInputDeviceW *device;
TRACE( "(%p)->(%s)\n", This, debugstr_guid(rguid) ); TRACE( "iface %p, guid %s.\n", iface, debugstr_guid( guid ) );
if (!rguid) return E_POINTER; if (!guid) return E_POINTER;
if (!This->initialized) if (!impl->initialized) return DIERR_NOTINITIALIZED;
return DIERR_NOTINITIALIZED;
hr = IDirectInput_CreateDevice( iface, rguid, &device, NULL ); hr = IDirectInput_CreateDevice( iface, guid, &device, NULL );
if (hr != DI_OK) return DI_NOTATTACHED; if (hr != DI_OK) return DI_NOTATTACHED;
IUnknown_Release( device ); IUnknown_Release( device );
@ -534,23 +529,18 @@ static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface,
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, HWND hwndOwner, DWORD dwFlags ) static HRESULT WINAPI dinput7_RunControlPanel( IDirectInput7W *iface, HWND owner, DWORD flags )
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
WCHAR control_exe[] = {L"control.exe"}; WCHAR control_exe[] = {L"control.exe"};
STARTUPINFOW si = {0}; STARTUPINFOW si = {0};
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
TRACE( "(%p)->(%p, %08x)\n", This, hwndOwner, dwFlags ); TRACE( "iface %p, owner %p, flags %#x.\n", iface, owner, flags );
if (hwndOwner && !IsWindow(hwndOwner)) if (owner && !IsWindow( owner )) return E_HANDLE;
return E_HANDLE; if (flags) return DIERR_INVALIDPARAM;
if (!impl->initialized) return DIERR_NOTINITIALIZED;
if (dwFlags)
return DIERR_INVALIDPARAM;
if (!This->initialized)
return DIERR_NOTINITIALIZED;
if (!CreateProcessW( NULL, control_exe, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi )) if (!CreateProcessW( NULL, control_exe, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi ))
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
@ -558,24 +548,21 @@ static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface,
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid, static HRESULT WINAPI dinput7_FindDevice( IDirectInput7W *iface, const GUID *guid, const WCHAR *name, GUID *instance_guid )
LPCWSTR pszName, LPGUID pguidInstance)
{ {
IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); FIXME( "iface %p, guid %s, name %s, instance_guid %s stub!\n", iface, debugstr_guid( guid ),
debugstr_w(name), debugstr_guid( instance_guid ) );
FIXME( "(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance );
return DI_OK; return DI_OK;
} }
static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, const GUID *guid, static HRESULT WINAPI dinput7_CreateDeviceEx( IDirectInput7W *iface, const GUID *guid,
const GUID *iid, void **out, IUnknown *outer ) REFIID iid, void **out, IUnknown *outer )
{ {
IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
IDirectInputDevice8W *device; IDirectInputDevice8W *device;
HRESULT hr; HRESULT hr;
TRACE( "iface %p, guid %s, iid %s, out %p, outer %p\n", iface, debugstr_guid( guid ), TRACE( "iface %p, guid %s, iid %s, out %p, outer %p.\n", iface, debugstr_guid( guid ),
debugstr_guid( iid ), out, outer ); debugstr_guid( iid ), out, outer );
if (!out) return E_POINTER; if (!out) return E_POINTER;
@ -594,10 +581,10 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface,
return hr; return hr;
} }
static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, static HRESULT WINAPI dinput7_CreateDevice( IDirectInput7W *iface, const GUID *guid,
LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) IDirectInputDeviceW **out, IUnknown *outer )
{ {
return IDirectInput7_CreateDeviceEx( iface, rguid, &IID_IDirectInputDeviceW, (LPVOID *)pdev, punk ); return IDirectInput7_CreateDeviceEx( iface, guid, &IID_IDirectInputDeviceW, (void **)out, outer );
} }
/******************************************************************************* /*******************************************************************************
@ -1042,17 +1029,18 @@ static HRESULT WINAPI joy_config_OpenAppStatusKey( IDirectInputJoyConfig8 *iface
return E_NOTIMPL; return E_NOTIMPL;
} }
static const IDirectInput7WVtbl ddi7wvt = { static const IDirectInput7WVtbl dinput7_vtbl =
IDirectInputWImpl_QueryInterface, {
IDirectInputWImpl_AddRef, dinput7_QueryInterface,
IDirectInputWImpl_Release, dinput7_AddRef,
IDirectInputWImpl_CreateDevice, dinput7_Release,
IDirectInputWImpl_EnumDevices, dinput7_CreateDevice,
IDirectInputWImpl_GetDeviceStatus, dinput7_EnumDevices,
IDirectInputWImpl_RunControlPanel, dinput7_GetDeviceStatus,
IDirectInputWImpl_Initialize, dinput7_RunControlPanel,
IDirectInput2WImpl_FindDevice, dinput7_Initialize,
IDirectInput7WImpl_CreateDeviceEx dinput7_FindDevice,
dinput7_CreateDeviceEx,
}; };
static const IDirectInput8WVtbl ddi8wvt = { static const IDirectInput8WVtbl ddi8wvt = {