Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 122 ++++++++++++++++++++++++++++++++++ dlls/dinput/dinput_main.c | 124 +---------------------------------- dlls/dinput/dinput_private.h | 1 + 3 files changed, 124 insertions(+), 123 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index f60aa8c729d..431b812aeb2 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -49,6 +49,21 @@ static inline IDirectInputDevice8A *IDirectInputDevice8A_from_IDirectInputDevice return &CONTAINING_RECORD( iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface )->IDirectInputDevice8A_iface; }
+static inline IDirectInputDeviceA *IDirectInputDeviceA_from_IDirectInputDeviceW( IDirectInputDeviceW *iface ) +{ + return (IDirectInputDeviceA *)IDirectInputDevice8A_from_IDirectInputDevice8W( (IDirectInputDevice8W *)iface ); +} + +static IDirectInputImpl *impl_from_IDirectInput7A( IDirectInput7A *iface ) +{ + return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7A_iface ); +} + +static IDirectInput7W *IDirectInput7W_from_impl( IDirectInputImpl *impl ) +{ + return &impl->IDirectInput7W_iface; +} + static IDirectInputImpl *impl_from_IDirectInput8A( IDirectInput8A *iface ) { return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8A_iface ); @@ -852,3 +867,110 @@ const IDirectInput8AVtbl dinput8_a_vtbl = dinput8_a_EnumDevicesBySemantics, dinput8_a_ConfigureDevices, }; + +static HRESULT WINAPI dinput7_a_QueryInterface( IDirectInput7A *iface_a, REFIID iid, void **out ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_QueryInterface( iface_w, iid, out ); +} + +static ULONG WINAPI dinput7_a_AddRef( IDirectInput7A *iface_a ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_AddRef( iface_w ); +} + +static ULONG WINAPI dinput7_a_Release( IDirectInput7A *iface_a ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_Release( iface_w ); +} + +static HRESULT WINAPI dinput7_a_CreateDevice( IDirectInput7A *iface_a, REFGUID guid, IDirectInputDeviceA **out_a, IUnknown *outer ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + IDirectInputDeviceW *out_w; + HRESULT hr; + + if (!out_a) return E_POINTER; + + hr = IDirectInput7_CreateDevice( iface_w, guid, &out_w, outer ); + *out_a = IDirectInputDeviceA_from_IDirectInputDeviceW( out_w ); + return hr; +} + +static HRESULT WINAPI dinput7_a_EnumDevices( IDirectInput7A *iface_a, DWORD type, LPDIENUMDEVICESCALLBACKA callback, + void *ref, DWORD flags ) +{ + struct enum_devices_wtoa_params params = {callback, ref}; + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + + if (!callback) return DIERR_INVALIDPARAM; + + return IDirectInput7_EnumDevices( iface_w, type, enum_devices_wtoa_callback, ¶ms, flags ); +} + +static HRESULT WINAPI dinput7_a_GetDeviceStatus( IDirectInput7A *iface_a, REFGUID instance_guid ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_GetDeviceStatus( iface_w, instance_guid ); +} + +static HRESULT WINAPI dinput7_a_RunControlPanel( IDirectInput7A *iface_a, HWND owner, DWORD flags ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_RunControlPanel( iface_w, owner, flags ); +} + +static HRESULT WINAPI dinput7_a_Initialize( IDirectInput7A *iface_a, HINSTANCE instance, DWORD version ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_Initialize( iface_w, instance, version ); +} + +static HRESULT WINAPI dinput7_a_FindDevice( IDirectInput7A *iface_a, REFGUID guid, const char *name_a, GUID *instance_guid ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + HRESULT hr; + WCHAR *name_w; + + if (FAILED(hr = string_atow( name_a, &name_w ))) return hr; + + hr = IDirectInput7_FindDevice( iface_w, guid, name_w, instance_guid ); + HeapFree( GetProcessHeap(), 0, name_w ); + return hr; +} + +static HRESULT WINAPI dinput7_a_CreateDeviceEx( IDirectInput7A *iface_a, REFGUID guid, REFIID iid, void **out, IUnknown *outer ) +{ + IDirectInputImpl *impl = impl_from_IDirectInput7A( iface_a ); + IDirectInput7W *iface_w = IDirectInput7W_from_impl( impl ); + return IDirectInput7_CreateDeviceEx( iface_w, guid, iid, out, outer ); +} + +const IDirectInput7AVtbl dinput7_a_vtbl = +{ + /*** IUnknown methods ***/ + dinput7_a_QueryInterface, + dinput7_a_AddRef, + dinput7_a_Release, + /*** IDirectInputA methods ***/ + dinput7_a_CreateDevice, + dinput7_a_EnumDevices, + dinput7_a_GetDeviceStatus, + dinput7_a_RunControlPanel, + dinput7_a_Initialize, + /*** IDirectInput2A methods ***/ + dinput7_a_FindDevice, + /*** IDirectInput7A methods ***/ + dinput7_a_CreateDeviceEx, +}; diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 1591779544a..85de9f79b81 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -55,16 +55,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
-static const IDirectInput7AVtbl ddi7avt; static const IDirectInput7WVtbl ddi7wvt; static const IDirectInput8WVtbl ddi8wvt; static const IDirectInputJoyConfig8Vtbl JoyConfig8vt;
-static inline IDirectInputImpl *impl_from_IDirectInput7A( IDirectInput7A *iface ) -{ - return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7A_iface ); -} - static inline IDirectInputImpl *impl_from_IDirectInput7W( IDirectInput7W *iface ) { return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7W_iface ); @@ -136,7 +130,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp if (!This) return E_OUTOFMEMORY;
- This->IDirectInput7A_iface.lpVtbl = &ddi7avt; + This->IDirectInput7A_iface.lpVtbl = &dinput7_a_vtbl; This->IDirectInput7W_iface.lpVtbl = &ddi7wvt; This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; @@ -361,47 +355,6 @@ __ASM_GLOBAL_FUNC( enum_callback_wrapper, #define enum_callback_wrapper(callback, instance, ref) (callback)((instance), (ref)) #endif
-/****************************************************************************** - * IDirectInputA_EnumDevices - */ -static HRESULT WINAPI IDirectInputAImpl_EnumDevices( - LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, - LPVOID pvRef, DWORD dwFlags) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A(iface); - DIDEVICEINSTANCEA devInstance; - unsigned int i; - int j; - HRESULT r; - - TRACE("(this=%p,0x%04x '%s',%p,%p,0x%04x)\n", - This, dwDevType, _dump_DIDEVTYPE_value(dwDevType, This->dwVersion), - lpCallback, pvRef, dwFlags); - _dump_EnumDevices_dwFlags(dwFlags); - - if (!lpCallback || - dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) || - (dwDevType > DI8DEVCLASS_GAMECTRL && dwDevType < DI8DEVTYPE_DEVICE) || dwDevType > DI8DEVTYPE_SUPPLEMENTAL) - return DIERR_INVALIDPARAM; - - if (!This->initialized) - return DIERR_NOTINITIALIZED; - - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { - if (!dinput_devices[i]->enum_deviceA) continue; - - TRACE(" Checking device %u ('%s')\n", i, dinput_devices[i]->name); - for (j = 0, r = S_OK; SUCCEEDED(r); j++) { - devInstance.dwSize = sizeof(devInstance); - r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->dwVersion, j); - if (r == S_OK) - if (enum_callback_wrapper(lpCallback, &devInstance, pvRef) == DIENUM_STOP) - return S_OK; - } - } - - return S_OK; -} /****************************************************************************** * IDirectInputW_EnumDevices */ @@ -452,12 +405,6 @@ static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) return ref; }
-static ULONG WINAPI IDirectInputAImpl_AddRef( IDirectInput7A *iface ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_AddRef( &This->IDirectInput7W_iface ); -} - static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -474,12 +421,6 @@ static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) return ref; }
-static ULONG WINAPI IDirectInputAImpl_Release( IDirectInput7A *iface ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_Release( &This->IDirectInput7W_iface ); -} - static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, REFIID riid, LPVOID *ppobj ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -525,12 +466,6 @@ static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, R return E_NOINTERFACE; }
-static HRESULT WINAPI IDirectInputAImpl_QueryInterface( IDirectInput7A *iface, REFIID riid, LPVOID *ppobj ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); -} - static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { IDirectInputDeviceImpl *dev; @@ -655,12 +590,6 @@ static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINST return initialize_directinput_instance(This, version); }
-static HRESULT WINAPI IDirectInputAImpl_Initialize( IDirectInput7A *iface, HINSTANCE hinst, DWORD version ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_Initialize( &This->IDirectInput7W_iface, hinst, version ); -} - static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, REFGUID rguid ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -681,12 +610,6 @@ static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, return DI_OK; }
-static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus( IDirectInput7A *iface, REFGUID rguid ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_GetDeviceStatus( &This->IDirectInput7W_iface, rguid ); -} - static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, HWND hwndOwner, DWORD dwFlags ) { IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); @@ -711,22 +634,6 @@ static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, return DI_OK; }
-static HRESULT WINAPI IDirectInputAImpl_RunControlPanel( IDirectInput7A *iface, HWND hwndOwner, DWORD dwFlags ) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - return IDirectInput_RunControlPanel( &This->IDirectInput7W_iface, hwndOwner, dwFlags ); -} - -static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid, - LPCSTR pszName, LPGUID pguidInstance) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - - FIXME( "(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance ); - - return DI_OK; -} - static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) { @@ -764,16 +671,6 @@ static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, return DIERR_DEVICENOTREG; }
-static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid, - REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter) -{ - IDirectInputImpl *This = impl_from_IDirectInput7A( iface ); - - TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter); - - return create_device(This, rguid, riid, pvOut, FALSE); -} - static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid, REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter) { @@ -784,12 +681,6 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R return create_device(This, rguid, riid, pvOut, TRUE); }
-static HRESULT WINAPI IDirectInputAImpl_CreateDevice(LPDIRECTINPUT7A iface, REFGUID rguid, - LPDIRECTINPUTDEVICEA* pdev, LPUNKNOWN punk) -{ - return IDirectInput7_CreateDeviceEx( iface, rguid, NULL, (LPVOID *)pdev, punk ); -} - static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) { @@ -1175,19 +1066,6 @@ static HRESULT WINAPI JoyConfig8Impl_OpenAppStatusKey(IDirectInputJoyConfig8 *if return E_NOTIMPL; }
-static const IDirectInput7AVtbl ddi7avt = { - IDirectInputAImpl_QueryInterface, - IDirectInputAImpl_AddRef, - IDirectInputAImpl_Release, - IDirectInputAImpl_CreateDevice, - IDirectInputAImpl_EnumDevices, - IDirectInputAImpl_GetDeviceStatus, - IDirectInputAImpl_RunControlPanel, - IDirectInputAImpl_Initialize, - IDirectInput2AImpl_FindDevice, - IDirectInput7AImpl_CreateDeviceEx -}; - static const IDirectInput7WVtbl ddi7wvt = { IDirectInputWImpl_QueryInterface, IDirectInputWImpl_AddRef, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index a8087195f96..256c30d3dc0 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -49,6 +49,7 @@ struct IDirectInputImpl struct list device_players; /* device instance guid to player name */ };
+extern const IDirectInput7AVtbl dinput7_a_vtbl DECLSPEC_HIDDEN; extern const IDirectInput8AVtbl dinput8_a_vtbl DECLSPEC_HIDDEN;
/* Function called by all devices that Wine supports */