Commit 0697d1ca authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Fix DIEFF_CARTESIAN to DIEFF_SPHERICAL conversion.

parent bd6d258e
......@@ -2019,13 +2019,19 @@ static BOOL get_parameters_object_ofs( struct hid_joystick *impl, struct hid_val
static void convert_directions_to_spherical( const DIEFFECT *in, DIEFFECT *out )
{
DWORD i, direction_flags = DIEFF_CARTESIAN | DIEFF_POLAR | DIEFF_SPHERICAL;
DWORD i, j, direction_flags = DIEFF_CARTESIAN | DIEFF_POLAR | DIEFF_SPHERICAL;
double tmp;
switch (in->dwFlags & direction_flags)
{
case DIEFF_CARTESIAN:
for (i = 1; i < in->cAxes; ++i)
out->rglDirection[i - 1] = atan2( in->rglDirection[i], in->rglDirection[0] );
{
tmp = in->rglDirection[0];
for (j = 1; j < i; ++j) tmp = sqrt( tmp * tmp + in->rglDirection[j] * in->rglDirection[j] );
tmp = atan2( in->rglDirection[i], tmp );
out->rglDirection[i - 1] = tmp * 18000 / M_PI;
}
out->rglDirection[in->cAxes - 1] = 0;
out->cAxes = in->cAxes;
break;
......
......@@ -6085,7 +6085,6 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO
}
else
{
todo_wine
ok( desc.rglDirection[0] == 6343, "got rglDirection[0] %d expected %d\n",
desc.rglDirection[0], 6343 );
if (i == 2)
......@@ -6097,7 +6096,6 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO
}
else
{
todo_wine
ok( desc.rglDirection[1] == 5330, "got rglDirection[1] %d expected %d\n",
desc.rglDirection[1], 5330 );
ok( desc.rglDirection[2] == 0, "got rglDirection[2] %d expected %d\n",
......@@ -6141,7 +6139,6 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file, DWO
{
ok( hr == DI_OK, "GetParameters returned %#x\n", hr );
ok( desc.cAxes == i, "got cAxes %u expected 2\n", desc.cAxes );
todo_wine
ok( desc.rglDirection[0] == 15343, "got rglDirection[0] %d expected %d\n",
desc.rglDirection[0], 15343 );
ok( desc.rglDirection[1] == 0, "got rglDirection[1] %d expected %d\n", desc.rglDirection[1], 0 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment