Ivo Ivanov : dinput: Fix single-axis effects direction values.
Alexandre Julliard
julliard at winehq.org
Fri Nov 19 15:45:31 CST 2021
Module: wine
Branch: master
Commit: ddd143b0e9a77419b2a3735f78f775daa356ba71
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ddd143b0e9a77419b2a3735f78f775daa356ba71
Author: Ivo Ivanov <logos128 at gmail.com>
Date: Fri Nov 19 09:39:41 2021 +0100
dinput: Fix single-axis effects direction values.
What the tests show is actually that the direction should be set only
if the corresponding axis is in the axis list.
Signed-off-by: Ivo Ivanov <logos128 at gmail.com>
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_hid.c | 10 +++++-----
dlls/dinput8/tests/hid.c | 48 +++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index fb83d173bda..0910c870762 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -1631,7 +1631,7 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap
{
SET_REPORT_ID( effect_update );
caps->physical_min = 0;
- caps->physical_max = 36000 - 36000 / (caps->logical_max - caps->logical_min);
+ caps->physical_max = 35900;
if (effect_update->direction_count >= 6) FIXME( "more than 6 PID directions detected\n" );
else effect_update->direction_caps[effect_update->direction_count] = caps;
effect_update->direction_count++;
@@ -1650,7 +1650,7 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap
if (instance->wUsage == PID_USAGE_PHASE)
{
caps->physical_min = 0;
- caps->physical_max = 36000 - 36000 / (caps->logical_max - caps->logical_min);
+ caps->physical_max = 35900;
set_periodic->phase_caps = caps;
}
if (instance->wUsage == PID_USAGE_OFFSET)
@@ -2078,11 +2078,12 @@ static void convert_directions_to_spherical( const DIEFFECT *in, DIEFFECT *out )
out->cAxes = in->cAxes;
break;
case DIEFF_SPHERICAL:
- for (i = 0; i < in->cAxes; ++i)
+ for (i = 0; i < in->cAxes - 1; ++i)
{
out->rglDirection[i] = in->rglDirection[i] % 36000;
if (out->rglDirection[i] < 0) out->rglDirection[i] += 36000;
}
+ out->rglDirection[i] = 0;
out->cAxes = in->cAxes;
break;
}
@@ -2773,8 +2774,7 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface )
spherical.rglDirection = directions;
convert_directions_to_spherical( &impl->params, &spherical );
- if (!effect_update->direction_count) WARN( "no PID effect direction caps found\n" );
- else for (i = 0; i < spherical.cAxes - 1; ++i)
+ for (i = 0; i < min( effect_update->direction_count, spherical.cAxes ); ++i)
{
tmp = directions[i] + (i == 0 ? 9000 : 0);
caps = effect_update->direction_caps[effect_update->direction_count - i - 1];
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 9e21ccdb713..5d7416b0e4c 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -6461,10 +6461,27 @@ 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,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x00,0x00},
+ .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x3f,0x00},
},
};
struct hid_expect expect_create_2[] =
+ {
+ /* set condition */
+ {
+ .code = IOCTL_HID_WRITE_REPORT,
+ .report_id = 7,
+ .report_len = 8,
+ .report_buf = {0x07,0x00,0x4c,0x3f,0xcc,0x4c,0x33,0x19},
+ },
+ /* update effect */
+ {
+ .code = IOCTL_HID_WRITE_REPORT,
+ .report_id = 3,
+ .report_len = 11,
+ .report_buf = {0x03,0x01,0x03,0x08,0x01,0x00,version >= 0x700 ? 0x06 : 0x00,0x00,0x01,0x55,0xf1},
+ },
+ };
+ struct hid_expect expect_create_3[] =
{
/* set condition */
{
@@ -6488,10 +6505,11 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW
.report_len = 4,
.report_buf = {0x02, 0x01, 0x03, 0x00},
};
- static const DWORD expect_axes[3] = {
+ static const DWORD expect_axes[3] =
+ {
+ DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 0 ) | DIDFT_FFACTUATOR,
DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 2 ) | DIDFT_FFACTUATOR,
DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 1 ) | DIDFT_FFACTUATOR,
- DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 0 ) | DIDFT_FFACTUATOR,
};
static const LONG expect_directions[3] = {
+3000,
@@ -6642,6 +6660,10 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW
desc = expect_desc;
desc.cAxes = 3;
+ desc.rglDirection = directions;
+ desc.rglDirection[0] = +3000;
+ desc.rglDirection[1] = -2000;
+ desc.rglDirection[2] = +1000;
desc.cbTypeSpecificParams = 1 * sizeof(DICONDITION);
desc.lpvTypeSpecificParams = (void *)&expect_condition[1];
set_hid_expect( file, expect_create_2, sizeof(expect_create_2) );
@@ -6653,6 +6675,26 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW
ref = IDirectInputEffect_Release( effect );
ok( ref == 0, "Release returned %d\n", ref );
set_hid_expect( file, NULL, 0 );
+
+ desc = expect_desc;
+ desc.cAxes = 2;
+ desc.rgdwAxes = axes;
+ desc.rgdwAxes[0] = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 1 ) | DIDFT_FFACTUATOR;
+ desc.rgdwAxes[1] = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 2 ) | DIDFT_FFACTUATOR;
+ desc.rglDirection = directions;
+ desc.rglDirection[0] = +3000;
+ desc.rglDirection[1] = -2000;
+ desc.cbTypeSpecificParams = 1 * sizeof(DICONDITION);
+ desc.lpvTypeSpecificParams = (void *)&expect_condition[1];
+ set_hid_expect( file, expect_create_3, sizeof(expect_create_3) );
+ hr = IDirectInputDevice8_CreateEffect( device, &GUID_Spring, &desc, &effect, NULL );
+ ok( hr == DI_OK, "CreateEffect returned %#x\n", hr );
+ set_hid_expect( file, NULL, 0 );
+
+ set_hid_expect( file, &expect_destroy, sizeof(expect_destroy) );
+ ref = IDirectInputEffect_Release( effect );
+ ok( ref == 0, "Release returned %d\n", ref );
+ set_hid_expect( file, NULL, 0 );
}
static void test_force_feedback_joystick( DWORD version )
More information about the wine-cvs
mailing list