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>2008-09-13 15:43:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-09-13 15:43:01 +0400
commitdfb5ebb12ea18bc8982777142c6e185cb389ad45 (patch)
tree07e22d4353c5fda67bef0a69643d3f22fc3c92c1 /source/gameengine/GameLogic
parenta9a8f74b805410c0ebb3c6fc59dcde6d726100e7 (diff)
return dummy python values when no joystick is present
Diffstat (limited to 'source/gameengine/GameLogic')
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 8ef33240592..3c08710c6ce 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -402,7 +402,8 @@ PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
if(joy)
return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
- return NULL;
+ else
+ return Py_BuildValue("[iiii]", 0, 0, 0, 0);
}
@@ -483,9 +484,8 @@ char SCA_JoystickSensor::NumberOfAxes_doc[] =
"\tReturns the number of axes .\n";
PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- if(joy)
- return PyInt_FromLong( joy->GetNumberOfAxes() );
- return false;
+ // when the joystick is null their is 0 exis still. dumb but scripters should use isConnected()
+ return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
}
@@ -494,9 +494,7 @@ char SCA_JoystickSensor::NumberOfButtons_doc[] =
"\tReturns the number of buttons .\n";
PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- if(joy)
- return PyInt_FromLong( joy->GetNumberOfButtons() );
- return false;
+ return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
}
@@ -505,9 +503,7 @@ char SCA_JoystickSensor::NumberOfHats_doc[] =
"\tReturns the number of hats .\n";
PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- if(joy)
- return PyInt_FromLong( joy->GetNumberOfHats() );
- return false;
+ return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
}
char SCA_JoystickSensor::Connected_doc[] =
@@ -515,7 +511,5 @@ char SCA_JoystickSensor::Connected_doc[] =
"\tReturns True if a joystick is connected at this joysticks index.\n";
PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- if(joy)
- return PyBool_FromLong( joy->Connected() );
- return false;
+ return PyBool_FromLong( joy ? joy->Connected() : 0 );
}