https://bugs.winehq.org/show_bug.cgi?id=46999
Bug ID: 46999 Summary: Controller with invalid HID range value causes division by zero error Product: Wine Version: 4.5 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: xinput Assignee: wine-bugs@winehq.org Reporter: gerbilsoft@gerbilsoft.com Distribution: ---
I have an 8bitdo M30 controller, which is similar in design to a Sega Mega Drive 6-button gamepad. Attempting to play the game Sonic 3 AIR with the controller connected resulted in a division by zero error. I finally narrowed it down to a crash in xinput1_3/hid.c, scale_short().
It seems that, since the controller doesn't have analog sticks, it reports a range of 0. scale_short() doesn't expect this, so it ends up dividing by zero.
Workaround: If range is 0, return 0.