Commit e749c1266f86f0b1ae6e2ff82a081518cc2c55fc

Sam Lantinga 2020-11-12T07:53:01

Fixed overflow in trigger rumble calculation

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 5941993..676af8b 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -117,7 +117,7 @@ UpdateWindowTitle()
 static Uint16 ConvertAxisToRumble(Sint16 axis)
 {
     /* Only start rumbling if the axis is past the halfway point */
-    const int half_axis = (SDL_JOYSTICK_AXIS_MAX / 2);
+    const Sint16 half_axis = (Sint16)SDL_ceil(SDL_JOYSTICK_AXIS_MAX / 2.0f);
     if (axis > half_axis) {
         return (Uint16)(axis - half_axis) * 4;
     } else {