dinput: Implement device property DIPROP_USERNAME.
Signed-off-by: Bernhard Übelacker <bernhardu@vr-web.de> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
455e6c64ae
commit
fbc85ddc28
|
@ -783,6 +783,7 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L
|
|||
DIOBJECTDATAFORMAT *obj_df = NULL;
|
||||
DIPROPDWORD dp;
|
||||
DIPROPRANGE dpr;
|
||||
DIPROPSTRING dps;
|
||||
WCHAR username[MAX_PATH];
|
||||
DWORD username_size = MAX_PATH;
|
||||
int i, action = 0, num_actions = 0;
|
||||
|
@ -863,6 +864,16 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L
|
|||
else
|
||||
lstrcpynW(username, lpszUserName, MAX_PATH);
|
||||
|
||||
dps.diph.dwSize = sizeof(dps);
|
||||
dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dps.diph.dwObj = 0;
|
||||
dps.diph.dwHow = DIPH_DEVICE;
|
||||
if (dwFlags & DIDSAM_NOUSER)
|
||||
dps.wsz[0] = '\0';
|
||||
else
|
||||
lstrcpynW(dps.wsz, username, sizeof(dps.wsz)/sizeof(WCHAR));
|
||||
IDirectInputDevice8_SetProperty(iface, DIPROP_USERNAME, &dps.diph);
|
||||
|
||||
/* Save the settings to disk */
|
||||
save_mapping_settings(iface, lpdiaf, username);
|
||||
|
||||
|
@ -1251,6 +1262,15 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface,
|
|||
TRACE("buffersize = %d\n", pd->dwData);
|
||||
break;
|
||||
}
|
||||
case (DWORD_PTR) DIPROP_USERNAME:
|
||||
{
|
||||
LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
|
||||
|
||||
if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
|
||||
|
||||
lstrcpynW(ps->wsz, This->username, sizeof(ps->wsz)/sizeof(WCHAR));
|
||||
break;
|
||||
}
|
||||
case (DWORD_PTR) DIPROP_VIDPID:
|
||||
FIXME("DIPROP_VIDPID not implemented\n");
|
||||
return DIERR_UNSUPPORTED;
|
||||
|
@ -1324,6 +1344,15 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(
|
|||
LeaveCriticalSection(&This->crit);
|
||||
break;
|
||||
}
|
||||
case (DWORD_PTR) DIPROP_USERNAME:
|
||||
{
|
||||
LPCDIPROPSTRING ps = (LPCDIPROPSTRING)pdiph;
|
||||
|
||||
if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
|
||||
|
||||
lstrcpynW(This->username, ps->wsz, sizeof(This->username)/sizeof(WCHAR));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WARN("Unknown property %s\n", debugstr_guid(rguid));
|
||||
return DIERR_UNSUPPORTED;
|
||||
|
|
|
@ -81,6 +81,7 @@ struct IDirectInputDeviceImpl
|
|||
/* Action mapping */
|
||||
int num_actions; /* number of actions mapped */
|
||||
ActionMap *action_map; /* array of mappings */
|
||||
WCHAR username[MAX_PATH];
|
||||
};
|
||||
|
||||
extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -223,8 +223,8 @@ static BOOL CALLBACK enumeration_callback(const DIDEVICEINSTANCEA *lpddi, IDirec
|
|||
dps.wsz[0] = '\0';
|
||||
|
||||
hr = IDirectInputDevice_GetProperty(lpdid, DIPROP_USERNAME, &dps.diph);
|
||||
todo_wine ok (SUCCEEDED(hr), "GetProperty failed hr=%08x\n", hr);
|
||||
todo_wine ok (!lstrcmpW(usernameW, dps.wsz), "Username not set correctly expected=%s, got=%s\n", wine_dbgstr_wn(usernameW, -1), wine_dbgstr_wn(dps.wsz, -1));
|
||||
ok (SUCCEEDED(hr), "GetProperty failed hr=%08x\n", hr);
|
||||
ok (!lstrcmpW(usernameW, dps.wsz), "Username not set correctly expected=%s, got=%s\n", wine_dbgstr_w(usernameW), wine_dbgstr_w(dps.wsz));
|
||||
|
||||
/* Test buffer size */
|
||||
memset(&dp, 0, sizeof(dp));
|
||||
|
@ -275,6 +275,7 @@ static void test_action_mapping(void)
|
|||
HINSTANCE hinst = GetModuleHandleA(NULL);
|
||||
IDirectInput8A *pDI = NULL;
|
||||
DIACTIONFORMATA af;
|
||||
DIPROPSTRING dps;
|
||||
struct enum_data data = {pDI, &af, NULL, NULL, NULL, 0};
|
||||
HWND hwnd;
|
||||
|
||||
|
@ -342,6 +343,30 @@ static void test_action_mapping(void)
|
|||
|
||||
af.dwDataSize = 4 * sizeof(actionMapping) / sizeof(actionMapping[0]);
|
||||
af.dwNumActions = sizeof(actionMapping) / sizeof(actionMapping[0]);
|
||||
|
||||
/* test DIDSAM_NOUSER */
|
||||
dps.diph.dwSize = sizeof(dps);
|
||||
dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dps.diph.dwObj = 0;
|
||||
dps.diph.dwHow = DIPH_DEVICE;
|
||||
dps.wsz[0] = '\0';
|
||||
|
||||
hr = IDirectInputDevice_GetProperty(data.keyboard, DIPROP_USERNAME, &dps.diph);
|
||||
ok (SUCCEEDED(hr), "GetProperty failed hr=%08x\n", hr);
|
||||
ok (dps.wsz[0] != 0, "Expected any username, got=%s\n", wine_dbgstr_w(dps.wsz));
|
||||
|
||||
hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, DIDSAM_NOUSER);
|
||||
ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
|
||||
|
||||
dps.diph.dwSize = sizeof(dps);
|
||||
dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dps.diph.dwObj = 0;
|
||||
dps.diph.dwHow = DIPH_DEVICE;
|
||||
dps.wsz[0] = '\0';
|
||||
|
||||
hr = IDirectInputDevice_GetProperty(data.keyboard, DIPROP_USERNAME, &dps.diph);
|
||||
ok (SUCCEEDED(hr), "GetProperty failed hr=%08x\n", hr);
|
||||
ok (dps.wsz[0] == 0, "Expected empty username, got=%s\n", wine_dbgstr_w(dps.wsz));
|
||||
}
|
||||
|
||||
if (data.mouse != NULL)
|
||||
|
|
Loading…
Reference in New Issue