Fix analog stick axis overflow issue causing full positive axis input to invert on Xbox 360 controllers

This commit is contained in:
Cameron Gutman
2015-02-19 20:31:07 -05:00
parent 4c332d3199
commit b8213276dc

View File

@@ -53,7 +53,9 @@ public class EvdevAbsolute {
return reverse?Short.MAX_VALUE:Short.MIN_VALUE;
else {
value += value<avg?flat:-flat;
return (short) ((value-avg) * Short.MAX_VALUE / (reverse?flat-range:range-flat));
// Divide the value by the range before multiplying to avoid overflowing
return (short) (((value-avg) / (float)(reverse?flat-range:range-flat)) * 0x7FFE);
}
}