From 3d90cc93c56571a6c1d7d25054094106595e7c03 Mon Sep 17 00:00:00 2001 From: Jetro Jormalainen Date: Tue, 30 Apr 2019 09:20:20 +1000 Subject: [PATCH] dinput: Load users Joystick mappings. --- dlls/dinput/device.c | 2 +- dlls/dinput/device_private.h | 2 ++ dlls/dinput/joystick.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index ade7947..648a4cc 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -714,7 +714,7 @@ static HRESULT save_mapping_settings(IDirectInputDevice8W *iface, LPDIACTIONFORM return DI_OK; } -static BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username) +BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username) { HKEY hkey; WCHAR *guid_str; diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index d9e2997..af8d99d 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -123,6 +123,8 @@ extern const char *_dump_dinput_GUID(const GUID *guid) DECLSPEC_HIDDEN; extern LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type) DECLSPEC_HIDDEN; +extern BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username) DECLSPEC_HIDDEN; + extern HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN; extern HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index 20d9ee4..62b57bc 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -28,6 +28,7 @@ #include +#include "device_private.h" #include "joystick_private.h" #include "wine/debug.h" #include "winreg.h" @@ -792,9 +793,26 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface); unsigned int i, j; BOOL has_actions = FALSE; + WCHAR username[MAX_PATH]; + DWORD username_size = MAX_PATH; + BOOL load_success = FALSE; FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags); + /* Unless asked the contrary by these flags, try to load a previous mapping */ + if (!(dwFlags & DIDBAM_HWDEFAULTS)) + { + /* Retrieve logged user name if necessary */ + if (lpszUserName == NULL) + GetUserNameW(username, &username_size); + else + lstrcpynW(username, lpszUserName, MAX_PATH); + + load_success = load_mapping_settings((IDirectInputDeviceImpl *) This, lpdiaf, username); + } + + if (load_success) return DI_OK; + for (i=0; i < lpdiaf->dwNumActions; i++) { DWORD inst = (0x000000ff & (lpdiaf->rgoAction[i].dwSemantic)) - 1; -- 1.9.1