[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 committed by twinaphex
parent 1e3d094860
commit a8645fb051
2 changed files with 20 additions and 2 deletions

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX input support * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * 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 max = js->max.x;
int center = js->center.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 */ /* value returned could be above calibration limits */
if (pos > max) return 127; if (pos > max) return 127;
if (pos < min) return -128; if (pos < min) return -128;
@ -572,6 +581,15 @@ static int wpad_StickY(WPADData *data, u8 right)
int max = js->max.y; int max = js->max.y;
int center = js->center.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 */ /* value returned could be above calibration limits */
if (pos > max) return 127; if (pos > max) return 127;
if (pos < min) return -128; if (pos < min) return -128;

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX input support * 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 * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met: