Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 29 +++++++++++++++++++++++++ dlls/dinput/device_private.h | 2 ++ dlls/dinput/joystick.c | 33 ----------------------------- dlls/dinput/joystick_linux.c | 2 +- dlls/dinput/joystick_linuxinput.c | 2 +- dlls/dinput/joystick_osx.c | 2 +- dlls/dinput/joystick_private.h | 1 - dlls/dinput/keyboard.c | 35 +------------------------------ dlls/dinput/mouse.c | 35 +------------------------------ 9 files changed, 36 insertions(+), 105 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index cc29bf8f6a4..77b535746a2 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -521,6 +521,35 @@ HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap( IDirectInputDevice8A *if return hr; }
+HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap( IDirectInputDevice8A *iface_a, DIACTIONFORMATA *format_a, + const char *username_a, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + DIACTIONFORMATW format_w = {sizeof(format_w), sizeof(DIACTIONW)}; + HRESULT hr; + WCHAR *username_w; + + if (!format_a) return E_POINTER; + if (format_a->dwSize != sizeof(DIACTIONFORMATA)) return DIERR_INVALIDPARAM; + if (format_a->dwActionSize != sizeof(DIACTIONA)) return DIERR_INVALIDPARAM; + if (FAILED(hr = string_atow( username_a, &username_w ))) return hr; + + format_w.dwNumActions = format_a->dwNumActions; + format_w.rgoAction = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, format_a->dwNumActions * sizeof(DIACTIONW) ); + if (!format_w.rgoAction) hr = DIERR_OUTOFMEMORY; + else + { + diactionformat_atow( format_a, &format_w ); + hr = IDirectInputDevice8_SetActionMap( iface_w, &format_w, username_w, flags ); + diactionformat_wtoa( &format_w, format_a ); + HeapFree( GetProcessHeap(), 0, format_w.rgoAction ); + } + + HeapFree( GetProcessHeap(), 0, username_w ); + return hr; +} + HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo( IDirectInputDevice8A *iface_a, DIDEVICEIMAGEINFOHEADERA *header_a ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 1e5a2e1b836..e9168712fd9 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -250,6 +250,8 @@ extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVIC DWORD dwFlags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap( LPDIRECTINPUTDEVICE8A iface, DIACTIONFORMATA *format, const char *username, DWORD flags ) DECLSPEC_HIDDEN; +extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap( LPDIRECTINPUTDEVICE8A iface, DIACTIONFORMATA *format, + const char *username, DWORD flags ) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface, diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index 708bee44857..a68c4df20e6 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -60,10 +60,6 @@ const GUID DInput_PIDVID_Product_GUID = { /* device_pidvid-0000-0000-0000-504944 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44} };
-static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) -{ - return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), JoystickGenericImpl, base); -} static inline JoystickGenericImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface) { return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), JoystickGenericImpl, base); @@ -785,35 +781,6 @@ HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, This->base.data_format.wine_df); }
-HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, - LPDIACTIONFORMATA lpdiaf, - LPCSTR lpszUserName, - DWORD dwFlags) -{ - JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); - DIACTIONFORMATW diafW; - HRESULT hr; - WCHAR *lpszUserNameW = NULL; - int username_size; - - diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions); - _copy_diactionformatAtoW(&diafW, lpdiaf); - - if (lpszUserName != NULL) - { - username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0); - lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size); - MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size); - } - - hr = JoystickWGenericImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags); - - HeapFree(GetProcessHeap(), 0, diafW.rgoAction); - HeapFree(GetProcessHeap(), 0, lpszUserNameW); - - return hr; -} - /* * This maps the read value (from the input event) to a value in the * 'wanted' range. diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index e0102ec1f4e..a33b16454b0 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -910,7 +910,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, IDirectInputDevice8AImpl_BuildActionMap, - JoystickAGenericImpl_SetActionMap, + IDirectInputDevice8AImpl_SetActionMap, IDirectInputDevice8AImpl_GetImageInfo };
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 0ef18de968e..2e2c8a87261 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -1340,7 +1340,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, IDirectInputDevice8AImpl_BuildActionMap, - JoystickAGenericImpl_SetActionMap, + IDirectInputDevice8AImpl_SetActionMap, IDirectInputDevice8AImpl_GetImageInfo };
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 56886a6904d..e2212557180 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1601,7 +1601,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, IDirectInputDevice8AImpl_BuildActionMap, - JoystickAGenericImpl_SetActionMap, + IDirectInputDevice8AImpl_SetActionMap, IDirectInputDevice8AImpl_GetImageInfo };
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index d4dabcb5dbd..78d5d721808 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -79,7 +79,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface,
HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
-HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN; HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
DWORD typeFromGUID(REFGUID guid) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 5143eb4752c..9d4ceda3edc 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -51,10 +51,6 @@ struct SysKeyboardImpl DWORD subtype; };
-static inline SysKeyboardImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) -{ - return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysKeyboardImpl, base); -} static inline SysKeyboardImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface) { return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysKeyboardImpl, base); @@ -565,35 +561,6 @@ static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIKeyboard); }
-static HRESULT WINAPI SysKeyboardAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, - LPDIACTIONFORMATA lpdiaf, - LPCSTR lpszUserName, - DWORD dwFlags) -{ - SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface); - DIACTIONFORMATW diafW; - HRESULT hr; - WCHAR *lpszUserNameW = NULL; - int username_size; - - diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions); - _copy_diactionformatAtoW(&diafW, lpdiaf); - - if (lpszUserName != NULL) - { - username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0); - lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size); - MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size); - } - - hr = SysKeyboardWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags); - - HeapFree(GetProcessHeap(), 0, diafW.rgoAction); - HeapFree(GetProcessHeap(), 0, lpszUserNameW); - - return hr; -} - static const IDirectInputDevice8AVtbl SysKeyboardAvt = { IDirectInputDevice2AImpl_QueryInterface, @@ -626,7 +593,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, IDirectInputDevice8AImpl_BuildActionMap, - SysKeyboardAImpl_SetActionMap, + IDirectInputDevice8AImpl_SetActionMap, IDirectInputDevice8AImpl_GetImageInfo };
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 62bc6b1f006..e5bd697a0ea 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -78,10 +78,6 @@ struct SysMouseImpl WARP_MOUSE warp_override; };
-static inline SysMouseImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface) -{ - return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysMouseImpl, base); -} static inline SysMouseImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface) { return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysMouseImpl, base); @@ -818,35 +814,6 @@ static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIMouse2); }
-static HRESULT WINAPI SysMouseAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, - LPDIACTIONFORMATA lpdiaf, - LPCSTR lpszUserName, - DWORD dwFlags) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); - DIACTIONFORMATW diafW; - HRESULT hr; - WCHAR *lpszUserNameW = NULL; - int username_size; - - diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions); - _copy_diactionformatAtoW(&diafW, lpdiaf); - - if (lpszUserName != NULL) - { - username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0); - lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size); - MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size); - } - - hr = SysMouseWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags); - - HeapFree(GetProcessHeap(), 0, diafW.rgoAction); - HeapFree(GetProcessHeap(), 0, lpszUserNameW); - - return hr; -} - static const IDirectInputDevice8AVtbl SysMouseAvt = { IDirectInputDevice2AImpl_QueryInterface, @@ -879,7 +846,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt = IDirectInputDevice7AImpl_EnumEffectsInFile, IDirectInputDevice7AImpl_WriteEffectToFile, IDirectInputDevice8AImpl_BuildActionMap, - SysMouseAImpl_SetActionMap, + IDirectInputDevice8AImpl_SetActionMap, IDirectInputDevice8AImpl_GetImageInfo };