[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20207] trunk/blender/source/gameengine/ GameLogic/Joystick/SCA_Joystick.cpp: [#18749] BGE: Crash on joysticksensor. getAxisValue()
Campbell Barton
ideasman42 at gmail.com
Thu May 14 23:06:49 CEST 2009
Revision: 20207
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20207
Author: campbellbarton
Date: 2009-05-14 23:06:48 +0200 (Thu, 14 May 2009)
Log Message:
-----------
[#18749] BGE: Crash on joysticksensor.getAxisValue()
negative index would be used when the joystick was not found, crashing python api, initialize these as 0 now.
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 2009-05-14 19:41:45 UTC (rev 20206)
+++ trunk/blender/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp 2009-05-14 21:06:48 UTC (rev 20207)
@@ -220,12 +220,17 @@
bool SCA_Joystick::CreateJoystickDevice(void)
{
#ifdef DISABLE_SDL
+ m_isinit = true;
+ m_axismax = m_buttonmax = m_hatmax = 0;
return false;
#else
if(m_isinit == false){
if (m_joyindex>=SDL_NumJoysticks()) {
// don't print a message, because this is done anyway
//echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
+
+ // Need this so python args can return empty lists
+ m_axismax = m_buttonmax = m_hatmax = 0;
return false;
}
@@ -237,12 +242,14 @@
/* must run after being initialized */
m_axismax = SDL_JoystickNumAxes(m_private->m_joystick);
- if (m_axismax > JOYAXIS_MAX) m_axismax= JOYAXIS_MAX; /* very unlikely */
-
m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick);
m_hatmax = SDL_JoystickNumHats(m_private->m_joystick);
+ if (m_axismax > JOYAXIS_MAX) m_axismax= JOYAXIS_MAX; /* very unlikely */
+ else if (m_axismax < 0) m_axismax = 0;
+ if(m_buttonmax<0) m_buttonmax= 0;
+ if(m_hatmax<0) m_buttonmax= 0;
}
return true;
#endif
More information about the Bf-blender-cvs
mailing list