project-slippi / Ishiiruka

GNU General Public License v2.0
330 stars 142 forks source link

Fix rounding error when computing the emulated control stick values #356

Closed pdeblois closed 2 years ago

pdeblois commented 2 years ago

This PR fixes issue #344 : Modifier Control Stick key only works when turning to the right. This fixes the issue both for the Gray Stick and the C-Stick.

There was a rounding inconsistency when computing the emulated (Standard Controller) control sticks' values. If the stick was pushed all the way to the max of the axis and the modifier key was pressed, the resulting offset was +63 if the stick was pushed in the positive direction of the axis, but -64 if it was pushed in the negative direction of the axis.

This fix first computes the absolute offsets to get consistent (and "correct") rounding, then computes the final result using the sign of the offset.