Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-05-15 01:06:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-15 01:06:48 +0400
commita20a2ebb9f5cb0854793464c805043acf81101ec (patch)
tree59a1975a853d4294bd3779e2a42149a34abdc707 /source/gameengine/GameLogic/Joystick
parent23251ba286dd6af4101e61371925b25e8ea00fec (diff)
[#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.
Diffstat (limited to 'source/gameengine/GameLogic/Joystick')
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index c300baa9bd4..c32ff303aea 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -220,12 +220,17 @@ int SCA_Joystick::GetNumberOfHats()
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 @@ bool SCA_Joystick::CreateJoystickDevice(void)
/* 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