Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControllerInterface/Wiimote: Provide fallback values for extensions with bad calibration. #8936

Merged

Conversation

jordan-woyak
Copy link
Member

@jordan-woyak jordan-woyak commented Jul 5, 2020

Some Nunchuks and Classic Controllers have bad calibration data.
This was causing unusable inputs in ControllerInterface Wii Remotes (aka Hybrid Wiimote 2.0).

This PR adds fallback values to make things mostly usable if the calibration checksum is bad or values are not sane.
The sanity check is just that "min" and "max" values are on opposite sides of the "zero" value.

This fixes:
https://bugs.dolphin-emu.org/issues/12088
https://bugs.dolphin-emu.org/issues/12027

Copy link
Contributor

@iwubcode iwubcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't speak to the low level emulation logic but the code itself seems fine. Never would have guessed it was bad calibration data as I tested this capability a while back with official Nintendo controllers.

Anyway, I tested on master to reproduce the problems with a Nunchuk and confirmed this PR fixes the issue. So... LGTM!

@CR96
Copy link

CR96 commented Jul 5, 2020

Just tested this locally against Build 12259 with Super Mario Galaxy, my Nunchuk works with Hybrid Wiimote now!

(I'm musicalmitten from the linked bug tracker issue)

Copy link
Member

@lioncash lioncash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than one minor comment.

}
else
{
for (size_t i = 0; i != std::size(zero.data); ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can likely be a std::all_of

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm indexing two arrays. I don't think it can be a clean std::all_of but I'll change it to an std::equal.

@jordan-woyak jordan-woyak force-pushed the wiimote-extension-calibration-fix branch from ed65746 to acdbbe4 Compare July 8, 2020 18:08
@jordan-woyak jordan-woyak force-pushed the wiimote-extension-calibration-fix branch from acdbbe4 to 5299e90 Compare July 12, 2020 00:59
@lioncash lioncash merged commit 4d36f6a into dolphin-emu:master Jul 12, 2020
10 checks passed
@jordan-woyak jordan-woyak deleted the wiimote-extension-calibration-fix branch July 12, 2020 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants