mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
dinput-joy-mappings: Restore tests to patch 1.
The patch set is disabled now. We want to make sure that these tests are ported when it's rewritten.
This commit is contained in:
parent
68cc39d3ba
commit
09634de79c
@ -1,17 +1,18 @@
|
||||
From 01097ee44ab6835a4c139261c188ae6535bfb311 Mon Sep 17 00:00:00 2001
|
||||
From e7104770d4b57539d5b64a67212504910692e920 Mon Sep 17 00:00:00 2001
|
||||
From: Jetro Jormalainen <jje-wine@jv.jetro.fi>
|
||||
Date: Tue, 30 Apr 2019 09:20:54 +1000
|
||||
Subject: [PATCH] dinput: Allow empty Joystick mappings.
|
||||
|
||||
---
|
||||
dlls/dinput/device.c | 77 ++++++++++++++++++++++++++++++++++++--------
|
||||
1 file changed, 63 insertions(+), 14 deletions(-)
|
||||
dlls/dinput/device.c | 77 ++++++++++++++++++++++++++++++-------
|
||||
dlls/dinput/tests/device8.c | 50 ++++++++++++++++++++++++
|
||||
2 files changed, 113 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
|
||||
index c001d1ef29a..d1ff222a653 100644
|
||||
index 6cc190ee7fb..2fd9329aa68 100644
|
||||
--- a/dlls/dinput/device.c
|
||||
+++ b/dlls/dinput/device.c
|
||||
@@ -341,12 +341,26 @@ static DWORD semantic_to_obj_id( struct dinput_device *This, DWORD dwSemantic )
|
||||
@@ -364,12 +364,26 @@ static DWORD semantic_to_obj_id( struct dinput_device *This, DWORD dwSemantic )
|
||||
return type | (0x0000ff00 & (instance << 8));
|
||||
}
|
||||
|
||||
@ -39,7 +40,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
{
|
||||
static const WCHAR *subkey = L"Software\\Wine\\DirectInput\\Mappings\\%s\\%s\\%s";
|
||||
HKEY hkey;
|
||||
@@ -357,8 +371,11 @@ static HKEY get_mapping_key(const WCHAR *device, const WCHAR *username, const WC
|
||||
@@ -380,8 +394,11 @@ static HKEY get_mapping_key(const WCHAR *device, const WCHAR *username, const WC
|
||||
swprintf( keyname, len, subkey, username, device, guid );
|
||||
|
||||
/* The key used is HKCU\Software\Wine\DirectInput\Mappings\[username]\[device]\[mapping_guid] */
|
||||
@ -53,7 +54,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
|
||||
free( keyname );
|
||||
|
||||
@@ -378,7 +395,9 @@ static HRESULT save_mapping_settings(IDirectInputDevice8W *iface, LPDIACTIONFORM
|
||||
@@ -401,7 +418,9 @@ static HRESULT save_mapping_settings(IDirectInputDevice8W *iface, LPDIACTIONFORM
|
||||
if (StringFromCLSID(&lpdiaf->guidActionMap, &guid_str) != S_OK)
|
||||
return DI_SETTINGSNOTSAVED;
|
||||
|
||||
@ -64,7 +65,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
|
||||
if (!hkey)
|
||||
{
|
||||
@@ -413,7 +432,7 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW
|
||||
@@ -436,7 +455,7 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW
|
||||
HKEY hkey;
|
||||
WCHAR *guid_str;
|
||||
DIDEVICEINSTANCEW didev;
|
||||
@ -73,7 +74,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
|
||||
didev.dwSize = sizeof(didev);
|
||||
IDirectInputDevice8_GetDeviceInfo(&This->IDirectInputDevice8W_iface, &didev);
|
||||
@@ -421,7 +440,7 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW
|
||||
@@ -444,7 +463,7 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW
|
||||
if (StringFromCLSID(&lpdiaf->guidActionMap, &guid_str) != S_OK)
|
||||
return FALSE;
|
||||
|
||||
@ -82,7 +83,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
|
||||
if (!hkey)
|
||||
{
|
||||
@@ -441,15 +460,20 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW
|
||||
@@ -464,15 +483,20 @@ static BOOL load_mapping_settings( struct dinput_device *This, LPDIACTIONFORMATW
|
||||
{
|
||||
lpdiaf->rgoAction[i].dwObjID = id;
|
||||
lpdiaf->rgoAction[i].guidInstance = didev.guidInstance;
|
||||
@ -106,7 +107,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
}
|
||||
|
||||
static BOOL set_app_data( struct dinput_device *dev, int offset, UINT_PTR app_data )
|
||||
@@ -1896,13 +1920,18 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface,
|
||||
@@ -1935,13 +1959,18 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface,
|
||||
load_success = load_mapping_settings( impl, format, username_buf );
|
||||
}
|
||||
|
||||
@ -129,7 +130,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
genre = format->rgoAction[i].dwSemantic & DIGENRE_ANY;
|
||||
if (devMask == genre || (devMask == DIGENRE_ANY && genre != DIMOUSE_MASK && genre != DIKEYBOARD_MASK))
|
||||
{
|
||||
@@ -1934,6 +1963,14 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface,
|
||||
@@ -1973,6 +2002,14 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface,
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +145,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
if (!has_actions) return DI_NOEFFECT;
|
||||
if (flags & (DIDBAM_DEFAULT|DIDBAM_PRESERVE|DIDBAM_INITIALIZE|DIDBAM_HWDEFAULTS))
|
||||
FIXME( "Unimplemented flags %#lx\n", flags );
|
||||
@@ -1951,6 +1988,7 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
|
||||
@@ -1990,6 +2027,7 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
|
||||
DIPROPSTRING dps;
|
||||
WCHAR username_buf[MAX_PATH];
|
||||
DWORD username_len = MAX_PATH;
|
||||
@ -152,7 +153,7 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
int i, action = 0, num_actions = 0;
|
||||
unsigned int offset = 0;
|
||||
const DIDATAFORMAT *df;
|
||||
@@ -1983,12 +2021,23 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
|
||||
@@ -2022,12 +2060,23 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
|
||||
data_format.dwFlags = DIDF_RELAXIS;
|
||||
data_format.dwDataSize = format->dwDataSize;
|
||||
|
||||
@ -177,6 +178,81 @@ index c001d1ef29a..d1ff222a653 100644
|
||||
|
||||
/* Construct the dataformat and actionmap */
|
||||
obj_df = malloc( sizeof(DIOBJECTDATAFORMAT) * num_actions );
|
||||
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
|
||||
index 2586736cb1d..e2be36ad7d3 100644
|
||||
--- a/dlls/dinput/tests/device8.c
|
||||
+++ b/dlls/dinput/tests/device8.c
|
||||
@@ -48,6 +48,8 @@ struct enum_data {
|
||||
/* Dummy GUID */
|
||||
static const GUID ACTION_MAPPING_GUID = { 0x1, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } };
|
||||
|
||||
+static const GUID NULL_GUID = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
+
|
||||
enum {
|
||||
DITEST_AXIS,
|
||||
DITEST_BUTTON,
|
||||
@@ -472,6 +474,17 @@ static void test_action_mapping(void)
|
||||
hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, 0);
|
||||
ok (hr == DI_NOEFFECT, "SetActionMap should have no effect with no actions to map hr=%#lx\n", hr);
|
||||
|
||||
+ /* Test that after changing actionformat SetActionMap has effect and that second
|
||||
+ * SetActionMap call with same empty actionformat has no effect */
|
||||
+ af.dwDataSize = 4 * 1;
|
||||
+ af.dwNumActions = 1;
|
||||
+
|
||||
+ hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, 0);
|
||||
+ ok (hr != DI_NOEFFECT, "SetActionMap should have effect as actionformat has changed hr=%08x\n", hr);
|
||||
+
|
||||
+ hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, 0);
|
||||
+ ok (hr == DI_NOEFFECT, "SetActionMap should have no effect with no actions to map hr=%08x\n", hr);
|
||||
+
|
||||
af.dwDataSize = 4 * ARRAY_SIZE(actionMapping);
|
||||
af.dwNumActions = ARRAY_SIZE(actionMapping);
|
||||
|
||||
@@ -663,6 +676,43 @@ static void test_save_settings(void)
|
||||
"Mapped incorrectly expected: 0x%#lx got: 0x%#lx\n", other_results[1], af.rgoAction[1].dwObjID);
|
||||
ok (IsEqualGUID(&GUID_SysKeyboard, &af.rgoAction[1].guidInstance), "Action should be mapped to keyboard\n");
|
||||
|
||||
+ /* Save and load empty mapping */
|
||||
+ af.rgoAction[0].dwObjID = 0;
|
||||
+ af.rgoAction[0].dwHow = 0;
|
||||
+ memset(&af.rgoAction[0].guidInstance, 0, sizeof(GUID));
|
||||
+ af.rgoAction[1].dwObjID = 0;
|
||||
+ af.rgoAction[1].dwHow = 0;
|
||||
+ memset(&af.rgoAction[1].guidInstance, 0, sizeof(GUID));
|
||||
+
|
||||
+ hr = IDirectInputDevice8_SetActionMap(pKey, &af, NULL, DIDSAM_FORCESAVE);
|
||||
+ ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
|
||||
+
|
||||
+ if (hr == DI_SETTINGSNOTSAVED)
|
||||
+ {
|
||||
+ skip ("Can't test saving settings if SetActionMap returns DI_SETTINGSNOTSAVED\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ af.rgoAction[0].dwObjID = other_results[0];
|
||||
+ af.rgoAction[0].dwHow = DIAH_USERCONFIG;
|
||||
+ af.rgoAction[0].guidInstance = GUID_SysKeyboard;
|
||||
+ af.rgoAction[1].dwObjID = other_results[1];
|
||||
+ af.rgoAction[1].dwHow = DIAH_USERCONFIG;
|
||||
+ af.rgoAction[1].guidInstance = GUID_SysKeyboard;
|
||||
+
|
||||
+ hr = IDirectInputDevice8_BuildActionMap(pKey, &af, NULL, 0);
|
||||
+ ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
|
||||
+
|
||||
+ ok (other_results[0] == af.rgoAction[0].dwObjID,
|
||||
+ "Mapped incorrectly expected: 0x%08x got: 0x%08x\n", other_results[0], af.rgoAction[0].dwObjID);
|
||||
+ ok (af.rgoAction[0].dwHow == DIAH_UNMAPPED, "dwHow should have been DIAH_UNMAPPED\n");
|
||||
+ ok (IsEqualGUID(&NULL_GUID, &af.rgoAction[0].guidInstance), "Action should not be mapped\n");
|
||||
+
|
||||
+ ok (other_results[1] == af.rgoAction[1].dwObjID,
|
||||
+ "Mapped incorrectly expected: 0x%08x got: 0x%08x\n", other_results[1], af.rgoAction[1].dwObjID);
|
||||
+ ok (af.rgoAction[1].dwHow == DIAH_UNMAPPED, "dwHow should have been DIAH_UNMAPPED\n");
|
||||
+ ok (IsEqualGUID(&NULL_GUID, &af.rgoAction[1].guidInstance), "Action should not be mapped\n");
|
||||
+
|
||||
IDirectInputDevice_Release(pKey);
|
||||
IDirectInput_Release(pDI);
|
||||
}
|
||||
--
|
||||
2.39.2
|
||||
2.34.1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user