Bruno Jesus : dinput: Simplify cartesian and fix polar direction calculations.
Alexandre Julliard
julliard at winehq.org
Thu Aug 25 10:39:36 CDT 2016
Module: wine
Branch: master
Commit: 79b5883fce72e72b8a41c7375ef6fdfc9e473677
URL: http://source.winehq.org/git/wine.git/?a=commit;h=79b5883fce72e72b8a41c7375ef6fdfc9e473677
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Wed Aug 24 22:55:58 2016 -0300
dinput: Simplify cartesian and fix polar direction calculations.
Based on formulas by Elias Vanderstuyft.
Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/effect_linuxinput.c | 43 +++++++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index 1b60d47..b4e7b06 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -519,23 +519,32 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
/* one-axis effects must use cartesian coords */
return DIERR_INVALIDPARAM;
}
- } else { /* two axes */
- if (peff->dwFlags & DIEFF_CARTESIAN) {
- LONG x, y;
- if (This->first_axis_is_x) {
- x = peff->rglDirection[0];
- y = peff->rglDirection[1];
- } else {
- x = peff->rglDirection[1];
- y = peff->rglDirection[0];
- }
- This->effect.direction = (int)((3 * M_PI / 2 - atan2(y, x)) * -0x7FFF / M_PI);
- } else {
- /* Polar and spherical are the same for 2 axes */
- /* Precision is important here, so we do double math with exact constants */
- This->effect.direction = (int)(((double)peff->rglDirection[0] - 90) / 35999) * 0x7FFF;
- }
- }
+ }
+ /* two axes */
+ else
+ {
+ if (peff->dwFlags & DIEFF_CARTESIAN)
+ {
+ LONG x, y;
+ if (This->first_axis_is_x)
+ {
+ x = peff->rglDirection[0];
+ y = peff->rglDirection[1];
+ }
+ else
+ {
+ x = peff->rglDirection[1];
+ y = peff->rglDirection[0];
+ }
+ This->effect.direction = (unsigned int)((M_PI / 2 + atan2(y, x)) * 0x8000 / M_PI);
+ }
+ else
+ {
+ /* Polar and spherical are the same for 2 axes */
+ /* Precision is important here, so we do double math with exact constants */
+ This->effect.direction = (unsigned int)(((double)peff->rglDirection[0] / 18000) * 0x8000);
+ }
+ }
}
if (dwFlags & DIEP_DURATION)
More information about the wine-cvs
mailing list