mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
dinput8/tests: Added tests for saving and retrieving settings with SetActionMap.
This commit is contained in:
parent
4e2959ab9b
commit
77cab1ce98
@ -132,7 +132,7 @@ static void test_build_action_map(
|
||||
ddi.dwSize = sizeof(ddi);
|
||||
IDirectInputDevice_GetDeviceInfo(lpdid, &ddi);
|
||||
|
||||
hr = IDirectInputDevice8_BuildActionMap(lpdid, lpdiaf, NULL, DIDBAM_INITIALIZE);
|
||||
hr = IDirectInputDevice8_BuildActionMap(lpdid, lpdiaf, NULL, DIDBAM_HWDEFAULTS);
|
||||
ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
|
||||
|
||||
actions = lpdiaf->rgoAction;
|
||||
@ -195,8 +195,8 @@ static BOOL CALLBACK enumeration_callback(
|
||||
}
|
||||
|
||||
/* Building and setting an action map */
|
||||
/* It should not use any pre-stored mappings so we use DIDBAM_INITIALIZE */
|
||||
hr = IDirectInputDevice8_BuildActionMap(lpdid, data->lpdiaf, NULL, DIDBAM_INITIALIZE);
|
||||
/* It should not use any pre-stored mappings so we use DIDBAM_HWDEFAULTS */
|
||||
hr = IDirectInputDevice8_BuildActionMap(lpdid, data->lpdiaf, NULL, DIDBAM_HWDEFAULTS);
|
||||
ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
|
||||
|
||||
/* Device has no data format and thus can't be acquired */
|
||||
@ -322,7 +322,7 @@ static void test_action_mapping(void)
|
||||
af.dwDataSize = 4 * DITEST_KEYBOARDSPACE;
|
||||
af.dwNumActions = DITEST_KEYBOARDSPACE;
|
||||
|
||||
hr = IDirectInputDevice8_BuildActionMap(data.keyboard, data.lpdiaf, NULL, DIDBAM_INITIALIZE);
|
||||
hr = IDirectInputDevice8_BuildActionMap(data.keyboard, data.lpdiaf, NULL, DIDBAM_HWDEFAULTS);
|
||||
ok (hr == DI_NOEFFECT, "BuildActionMap should have no effect with no actions hr=%08x\n", hr);
|
||||
|
||||
hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, 0);
|
||||
@ -342,11 +342,137 @@ static void test_action_mapping(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void test_save_settings(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
HINSTANCE hinst = GetModuleHandle(NULL);
|
||||
LPDIRECTINPUT8 pDI = NULL;
|
||||
DIACTIONFORMAT af;
|
||||
IDirectInputDevice8A *pKey;
|
||||
|
||||
static const GUID mapping_guid = { 0xcafecafe, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } };
|
||||
static DIACTION actions[] = {
|
||||
{ 0, DIKEYBOARD_A , 0, { "Blam" } },
|
||||
{ 1, DIKEYBOARD_B , 0, { "Kapow"} }
|
||||
};
|
||||
static const DWORD results[] = {
|
||||
DIDFT_MAKEINSTANCE(DIK_A) | DIDFT_PSHBUTTON,
|
||||
DIDFT_MAKEINSTANCE(DIK_B) | DIDFT_PSHBUTTON
|
||||
};
|
||||
static const DWORD other_results[] = {
|
||||
DIDFT_MAKEINSTANCE(DIK_C) | DIDFT_PSHBUTTON,
|
||||
DIDFT_MAKEINSTANCE(DIK_D) | DIDFT_PSHBUTTON
|
||||
};
|
||||
|
||||
hr = CoCreateInstance(&CLSID_DirectInput8, 0, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (LPVOID*)&pDI);
|
||||
if (hr == DIERR_OLDDIRECTINPUTVERSION ||
|
||||
hr == DIERR_BETADIRECTINPUTVERSION ||
|
||||
hr == REGDB_E_CLASSNOTREG)
|
||||
{
|
||||
win_skip("ActionMapping requires dinput8\n");
|
||||
return;
|
||||
}
|
||||
ok (SUCCEEDED(hr), "DirectInput8 Create failed: hr=%08x\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION);
|
||||
if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION)
|
||||
{
|
||||
win_skip("ActionMapping requires dinput8\n");
|
||||
return;
|
||||
}
|
||||
ok (SUCCEEDED(hr), "DirectInput8 Initialize failed: hr=%08x\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &pKey, NULL);
|
||||
ok (SUCCEEDED(hr), "IDirectInput_Create device failed hr: 0x%08x\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
memset (&af, 0, sizeof(af));
|
||||
af.dwSize = sizeof(af);
|
||||
af.dwActionSize = sizeof(DIACTION);
|
||||
af.dwDataSize = 4 * sizeof(actions) / sizeof(actions[0]);
|
||||
af.dwNumActions = sizeof(actions) / sizeof(actions[0]);
|
||||
af.rgoAction = actions;
|
||||
af.guidActionMap = mapping_guid;
|
||||
af.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */
|
||||
af.dwBufferSize = 32;
|
||||
|
||||
/* Easy case. Ask for default mapping, save, ask for previous map and read it back */
|
||||
hr = IDirectInputDevice8_BuildActionMap(pKey, &af, NULL, DIDBAM_HWDEFAULTS);
|
||||
ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
|
||||
|
||||
ok (results[0] == af.rgoAction[0].dwObjID,
|
||||
"Mapped incorrectly expected: 0x%08x got: 0x%08x\n", results[0], af.rgoAction[0].dwObjID);
|
||||
|
||||
ok (results[1] == af.rgoAction[1].dwObjID,
|
||||
"Mapped incorrectly expected: 0x%08x got: 0x%08x\n", results[1], af.rgoAction[1].dwObjID);
|
||||
|
||||
hr = IDirectInputDevice8_SetActionMap(pKey, &af, NULL, DIDSAM_FORCESAVE);
|
||||
ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
|
||||
|
||||
if (hr == DI_SETTINGSNOTSAVED)
|
||||
{
|
||||
skip ("Cant test saving settings if SetActionMap returns DI_SETTINGSNOTSAVED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
af.rgoAction[0].dwObjID = 0;
|
||||
af.rgoAction[1].dwObjID = 0;
|
||||
memset(&af.rgoAction[0].guidInstance, 0, sizeof(GUID));
|
||||
memset(&af.rgoAction[1].guidInstance, 0, sizeof(GUID));
|
||||
|
||||
hr = IDirectInputDevice8_BuildActionMap(pKey, &af, NULL, 0);
|
||||
ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
|
||||
|
||||
ok (results[0] == af.rgoAction[0].dwObjID,
|
||||
"Mapped incorrectly expected: 0x%08x got: 0x%08x\n", results[0], af.rgoAction[0].dwObjID);
|
||||
ok (IsEqualGUID(&GUID_SysKeyboard, &af.rgoAction[0].guidInstance), "Action should be mapped to keyboard\n");
|
||||
|
||||
ok (results[1] == af.rgoAction[1].dwObjID,
|
||||
"Mapped incorrectly expected: 0x%08x got: 0x%08x\n", results[1], af.rgoAction[1].dwObjID);
|
||||
ok (IsEqualGUID(&GUID_SysKeyboard, &af.rgoAction[1].guidInstance), "Action should be mapped to keyboard\n");
|
||||
|
||||
/* Hard case. Customized mapping, save, ask for previous map and read it back */
|
||||
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_SetActionMap(pKey, &af, NULL, DIDSAM_FORCESAVE);
|
||||
ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
|
||||
|
||||
if (hr == DI_SETTINGSNOTSAVED)
|
||||
{
|
||||
skip ("Cant test saving settings if SetActionMap returns DI_SETTINGSNOTSAVED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
af.rgoAction[0].dwObjID = 0;
|
||||
af.rgoAction[1].dwObjID = 0;
|
||||
memset(&af.rgoAction[0].guidInstance, 0, sizeof(GUID));
|
||||
memset(&af.rgoAction[1].guidInstance, 0, sizeof(GUID));
|
||||
|
||||
hr = IDirectInputDevice8_BuildActionMap(pKey, &af, NULL, 0);
|
||||
ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr);
|
||||
|
||||
todo_wine ok (other_results[0] == af.rgoAction[0].dwObjID,
|
||||
"Mapped incorrectly expected: 0x%08x got: 0x%08x\n", other_results[0], af.rgoAction[0].dwObjID);
|
||||
todo_wine ok (IsEqualGUID(&GUID_SysKeyboard, &af.rgoAction[0].guidInstance), "Action should be mapped to keyboard\n");
|
||||
|
||||
todo_wine ok (other_results[1] == af.rgoAction[1].dwObjID,
|
||||
"Mapped incorrectly expected: 0x%08x got: 0x%08x\n", other_results[1], af.rgoAction[1].dwObjID);
|
||||
todo_wine ok (IsEqualGUID(&GUID_SysKeyboard, &af.rgoAction[1].guidInstance), "Action should be mapped to keyboard\n");
|
||||
}
|
||||
|
||||
START_TEST(device)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
|
||||
test_action_mapping();
|
||||
test_save_settings();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user