[Wii] fixed back support for third-party Classic Controllers reporting invalid analog sticks calibration data

This commit is contained in:
ekeeke 2019-06-13 01:03:27 +02:00
parent 6466994353
commit 5b1271e477
3 changed files with 20 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 MiB

After

Width:  |  Height:  |  Size: 3.9 MiB

View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX input support
*
* Copyright Eke-Eke (2007-2018)
* Copyright Eke-Eke (2007-2019)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -523,6 +523,15 @@ static int wpad_StickX(WPADData *data, u8 right)
int max = js->max.x;
int center = js->center.x;
/* some 3rd party controllers return invalid analog sticks calibration data */
if ((min >= center) || (max <= center))
{
/* force default calibration settings */
min = js->min.x = 0;
max = js->max.x = right ? 32 : 64;
center = js->center.x = right ? 16 : 32;
}
/* value returned could be above calibration limits */
if (pos > max) return 127;
if (pos < min) return -128;
@ -572,6 +581,15 @@ static int wpad_StickY(WPADData *data, u8 right)
int max = js->max.y;
int center = js->center.y;
/* some 3rd party controllers return invalid analog sticks calibration data */
if ((min >= center) || (max <= center))
{
/* force default calibration settings */
min = js->min.y = 0;
max = js->max.y = right ? 32 : 64;
center = js->center.y = right ? 16 : 32;
}
/* value returned could be above calibration limits */
if (pos > max) return 127;
if (pos < min) return -128;

View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX input support
*
* Copyright Eke-Eke (2007-2018)
* Copyright Eke-Eke (2007-2019)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: