dinput: Fix effect direction conversion from DIEFF_CARTESIAN coordinates.
This commit is contained in:
parent
209820c428
commit
7e7970830f
|
@ -55,6 +55,7 @@ struct LinuxInputEffectImpl
|
||||||
|
|
||||||
struct ff_effect effect; /* Effect data */
|
struct ff_effect effect; /* Effect data */
|
||||||
int gain; /* Effect gain */
|
int gain; /* Effect gain */
|
||||||
|
int first_axis_is_x;
|
||||||
int* fd; /* Parent device */
|
int* fd; /* Parent device */
|
||||||
struct list *entry; /* Entry into the parent's list of effects */
|
struct list *entry; /* Entry into the parent's list of effects */
|
||||||
};
|
};
|
||||||
|
@ -548,6 +549,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
|
||||||
return DIERR_INVALIDPARAM;
|
return DIERR_INVALIDPARAM;
|
||||||
else if (peff->cAxes < 1)
|
else if (peff->cAxes < 1)
|
||||||
return DIERR_INCOMPLETEEFFECT;
|
return DIERR_INCOMPLETEEFFECT;
|
||||||
|
This->first_axis_is_x = peff->rgdwAxes[0] == DIJOFS_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* some of this may look funky, but it's 'cause the linux driver and directx have
|
/* some of this may look funky, but it's 'cause the linux driver and directx have
|
||||||
|
@ -572,15 +574,15 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
|
||||||
}
|
}
|
||||||
} else { /* two axes */
|
} else { /* two axes */
|
||||||
if (peff->dwFlags & DIEFF_CARTESIAN) {
|
if (peff->dwFlags & DIEFF_CARTESIAN) {
|
||||||
/* avoid divide-by-zero */
|
LONG x, y;
|
||||||
if (peff->rglDirection[1] == 0) {
|
if (This->first_axis_is_x) {
|
||||||
if (peff->rglDirection[0] >= 0)
|
x = peff->rglDirection[0];
|
||||||
This->effect.direction = 0x4000;
|
y = peff->rglDirection[1];
|
||||||
else if (peff->rglDirection[0] < 0)
|
|
||||||
This->effect.direction = 0xC000;
|
|
||||||
} else {
|
} else {
|
||||||
This->effect.direction = (int)(atan(peff->rglDirection[0] / peff->rglDirection[1]) * 0x7FFF / (3 * M_PI));
|
x = peff->rglDirection[1];
|
||||||
|
y = peff->rglDirection[0];
|
||||||
}
|
}
|
||||||
|
This->effect.direction = (int)((3 * M_PI / 2 - atan2(y, x)) * -0x7FFF / M_PI);
|
||||||
} else {
|
} else {
|
||||||
/* Polar and spherical are the same for 2 axes */
|
/* Polar and spherical are the same for 2 axes */
|
||||||
/* Precision is important here, so we do double math with exact constants */
|
/* Precision is important here, so we do double math with exact constants */
|
||||||
|
|
Loading…
Reference in New Issue