Commit 64c1f477 authored by Lucas Fialho Zawacki's avatar Lucas Fialho Zawacki Committed by Alexandre Julliard

dinput: Proper conversion of username parameters for Set and BuildActionMap.

parent 7e3d51b7
......@@ -486,14 +486,24 @@ HRESULT WINAPI JoystickAGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
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);
hr = JoystickWGenericImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
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_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
_copy_diactionformatWtoA(lpdiaf, &diafW);
HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
HeapFree(GetProcessHeap(), 0, lpszUserNameW);
return hr;
}
......@@ -518,13 +528,23 @@ HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
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);
hr = JoystickWGenericImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
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;
}
......
......@@ -542,14 +542,24 @@ static HRESULT WINAPI SysKeyboardAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A ifac
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);
hr = SysKeyboardWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
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_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
_copy_diactionformatWtoA(lpdiaf, &diafW);
HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
HeapFree(GetProcessHeap(), 0, lpszUserNameW);
return hr;
}
......@@ -572,13 +582,23 @@ static HRESULT WINAPI SysKeyboardAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
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);
hr = SysKeyboardWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
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;
}
......
......@@ -791,14 +791,24 @@ static HRESULT WINAPI SysMouseAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
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);
hr = SysMouseWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
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_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
_copy_diactionformatWtoA(lpdiaf, &diafW);
HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
HeapFree(GetProcessHeap(), 0, lpszUserNameW);
return hr;
}
......@@ -821,13 +831,23 @@ static HRESULT WINAPI SysMouseAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
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);
hr = SysMouseWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
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;
}
......
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