From: Tomasz Pakuła tomasz.pakula.oficjalny@gmail.com
--- dlls/dinput/tests/force_feedback.c | 139 ++++++++++++++++++++++++++--- 1 file changed, 129 insertions(+), 10 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index 13001e0948c..c8f509ea8ab 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -1533,7 +1533,7 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */ }
-static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DWORD version, DWORD dwAxes ) +static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DWORD version ) { struct hid_expect expect_create[] = { @@ -1556,7 +1556,7 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW .code = IOCTL_HID_WRITE_REPORT, .report_id = 3, .report_len = 11, - .report_buf = {0x03,0x01,0x03,1 << dwAxes,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0x00}, + .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0x00}, }, }; struct hid_expect expect_create_1[] = @@ -1573,7 +1573,7 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW .code = IOCTL_HID_WRITE_REPORT, .report_id = 3, .report_len = 11, - .report_buf = {0x03,0x01,0x03,1 << dwAxes,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00}, + .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00}, }, }; struct hid_expect expect_create_2[] = @@ -1590,7 +1590,7 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW .code = IOCTL_HID_WRITE_REPORT, .report_id = 3, .report_len = 11, - .report_buf = {0x03,0x01,0x03,1 << dwAxes,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0xf1}, + .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0xf1}, }, }; struct hid_expect expect_create_3[] = @@ -1607,7 +1607,7 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW .code = IOCTL_HID_WRITE_REPORT, .report_id = 3, .report_len = 11, - .report_buf = {0x03,0x01,0x03,1 << dwAxes,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0x00}, + .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0x00}, }, }; struct hid_expect expect_create_4[] = @@ -1624,7 +1624,7 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW .code = IOCTL_HID_WRITE_REPORT, .report_id = 3, .report_len = 11, - .report_buf = {0x03,0x01,0x03,1 << dwAxes,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00}, + .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00}, }, }; struct hid_expect expect_create_5[] = @@ -1641,7 +1641,7 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW .code = IOCTL_HID_WRITE_REPORT, .report_id = 3, .report_len = 11, - .report_buf = {0x03,0x01,0x03,1 << dwAxes,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00}, + .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00}, }, }; struct hid_expect expect_destroy = @@ -3638,7 +3638,7 @@ static BOOL test_force_feedback_joystick( DWORD version )
test_constantforce_effect( device, file, version ); test_periodic_effect( device, file, version ); - test_condition_effect( device, file, version , caps.dwAxes ); + test_condition_effect( device, file, version );
set_hid_expect( file, expect_reset, sizeof(expect_reset) ); hr = IDirectInputDevice8_Unacquire( device ); @@ -3659,7 +3659,126 @@ done: return device != NULL; }
-/* Test if we're getting effects in six ffb axis controllers */ +static void test_condition_effect_six_axes( IDirectInputDevice8W *device, HANDLE file, DWORD version ) +{ + struct hid_expect expect_create[] = + { + /* set condition */ + { + .code = IOCTL_HID_WRITE_REPORT, + .report_id = 7, + .report_len = 8, + .report_buf = {0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00}, + }, + /* set condition */ + { + .code = IOCTL_HID_WRITE_REPORT, + .report_id = 7, + .report_len = 8, + .report_buf = {0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00}, + }, + /* update effect */ + { + .code = IOCTL_HID_WRITE_REPORT, + .report_id = 3, + .report_len = 15, + .report_buf = {0x03,0x01,0x03,0x40,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00}, + }, + }; + static const DWORD expect_axes[2] = + { + DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 0 ) | DIDFT_FFACTUATOR, + DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 1 ) | DIDFT_FFACTUATOR, + }; + static const LONG expect_directions[2] = { + 0, + 0, + }; + static const DICONDITION expect_condition[2] = + { + { + .lOffset = 0, + .lPositiveCoefficient = 0, + .lNegativeCoefficient = 0, + .dwPositiveSaturation = 0, + .dwNegativeSaturation = 0, + .lDeadBand = 0, + }, + { + .lOffset = 0, + .lPositiveCoefficient = 0, + .lNegativeCoefficient = 0, + .dwPositiveSaturation = 0, + .dwNegativeSaturation = 0, + .lDeadBand = 0, + }, + }; + const DIEFFECT expect_desc = + { + .dwSize = version >= 0x700 ? sizeof(DIEFFECT_DX6) : sizeof(DIEFFECT_DX5), + .dwFlags = DIEFF_POLAR | DIEFF_OBJECTIDS, + .dwDuration = 1000, + .dwGain = 3000, + .dwTriggerButton = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( 0 ) | DIDFT_FFEFFECTTRIGGER, + .dwTriggerRepeatInterval = 0, + .cAxes = 2, + .rgdwAxes = (void *)expect_axes, + .rglDirection = (void *)expect_directions, + .cbTypeSpecificParams = sizeof(DICONDITION), + .lpvTypeSpecificParams = (void *)expect_condition, + .dwStartDelay = 0, + }; + struct check_created_effect_params check_params = {0}; + DIENVELOPE envelope = {.dwSize = sizeof(DIENVELOPE)}; + DICONDITION condition[2] = {{0}}; + IDirectInputEffect *effect; + LONG directions[2] = {0}; + DWORD axes[2] = {0}; + DIEFFECT desc = + { + .dwSize = version >= 0x700 ? sizeof(DIEFFECT_DX6) : sizeof(DIEFFECT_DX5), + .dwFlags = DIEFF_SPHERICAL | DIEFF_OBJECTIDS, + .cAxes = 2, + .rgdwAxes = axes, + .rglDirection = directions, + .lpEnvelope = &envelope, + .cbTypeSpecificParams = sizeof(DICONDITION), + .lpvTypeSpecificParams = condition, + }; + HRESULT hr; + ULONG ref; + GUID guid; + + set_hid_expect( file, NULL, 0 ); + set_hid_expect( file, expect_create, sizeof(expect_create) ); + hr = IDirectInputDevice8_CreateEffect( device, &GUID_Spring, &expect_desc, &effect, NULL ); + ok( hr == DI_OK, "CreateEffect returned %#lx\n", hr ); + set_hid_expect( file, NULL, 0 ); + + check_params.expect_effect = effect; + hr = IDirectInputDevice8_EnumCreatedEffectObjects( device, check_created_effect_objects, &check_params, 0 ); + ok( hr == DI_OK, "EnumCreatedEffectObjects returned %#lx\n", hr ); + ok( check_params.count == 1, "got count %lu, expected 1\n", check_params.count ); + + hr = IDirectInputEffect_GetEffectGuid( effect, &guid ); + ok( hr == DI_OK, "GetEffectGuid returned %#lx\n", hr ); + ok( IsEqualGUID( &guid, &GUID_Spring ), "got guid %s, expected %s\n", debugstr_guid( &guid ), + debugstr_guid( &GUID_Spring ) ); + + hr = IDirectInputEffect_GetParameters( effect, &desc, version >= 0x700 ? DIEP_ALLPARAMS : DIEP_ALLPARAMS_DX5 ); + ok( hr == DI_OK, "GetParameters returned %#lx\n", hr ); + check_member( desc, expect_desc, "%lu", cAxes ); + check_member( desc, expect_desc, "%#lx", rgdwAxes[0] ); + check_member( desc, expect_desc, "%#lx", rgdwAxes[1] ); + check_member( desc, expect_desc, "%ld", rglDirection[0] ); + check_member( desc, expect_desc, "%ld", rglDirection[1] ); + check_member( desc, expect_desc, "%lu", cbTypeSpecificParams ); + + ref = IDirectInputEffect_Release( effect ); + ok( ref == 0, "Release returned %ld\n", ref ); +} + +/* Test if we're getting just one axis in effects */ static BOOL test_force_feedback_six_axes( DWORD version ) { #include "psh_hid_macros.h" @@ -4163,7 +4282,7 @@ static BOOL test_force_feedback_six_axes( DWORD version ) hr = IDirectInputDevice8_Acquire( device ); ok( hr == DI_OK, "Acquire returned: %#lx\n", hr );
- test_condition_effect( device, file, version , caps.dwAxes ); + test_condition_effect_six_axes( device, file, version );
hr = IDirectInputDevice8_Unacquire( device ); ok( hr == DI_OK, "Unacquire returned: %#lx\n", hr );