[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53617] trunk/blender/source/gameengine/ GameLogic/Joystick/SCA_Joystick.cpp: BGE: Fix for [#33053] "2. 6x Joystick Sensor Event: Axis fails to fire at full tilt" reported by Auuman Anubis (auuman_anubis).

Mitchell Stokes mogurijin at gmail.com
Mon Jan 7 00:11:13 CET 2013


Revision: 53617
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53617
Author:   moguri
Date:     2013-01-06 23:11:12 +0000 (Sun, 06 Jan 2013)
Log Message:
-----------
BGE: Fix for [#33053] "2.6x Joystick Sensor Event: Axis fails to fire at full tilt" reported by Auuman Anubis (auuman_anubis).

The problem was that SCA_Joystick::pAxisTest() was using shorts, and tried to store abs(MIN_SHRT) in a short. However, on most systems MIN_SHRT == -32768 and MAX_SHRT == 32767. This means that abs(MIN_SHRT) > MAX_SHRT, and thus the short would overflow.

Modified Paths:
--------------
    trunk/blender/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp

Modified: trunk/blender/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp	2013-01-06 21:23:34 UTC (rev 53616)
+++ trunk/blender/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp	2013-01-06 23:11:12 UTC (rev 53617)
@@ -307,8 +307,11 @@
 int SCA_Joystick::pAxisTest(int axisnum)
 {
 #ifdef WITH_SDL
-	short i1 = m_axis_array[(axisnum * 2)];
-	short i2 = m_axis_array[(axisnum * 2) + 1];
+	/* Use ints instead of shorts here to avoid problems when we get -32768.
+	 * When we take the negative of that later, we should get 32768, which is greater
+	 * than what a short can hold. In other words, abs(MIN_SHORT) > MAX_SHRT. */
+	int i1 = m_axis_array[(axisnum * 2)];
+	int i2 = m_axis_array[(axisnum * 2) + 1];
 	
 	/* long winded way to do:
 	 * return max_ff(absf(i1), absf(i2))




More information about the Bf-blender-cvs mailing list