Revision: 16501
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16501
Author:   campbellbarton
Date:     2008-09-13 13:43:01 +0200 (Sat, 13 Sep 2008)

Log Message:
-----------
return dummy python values when no joystick is present

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

Modified: trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp    
2008-09-13 11:41:52 UTC (rev 16500)
+++ trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp    
2008-09-13 11:43:01 UTC (rev 16501)
@@ -402,7 +402,8 @@
        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 @@
 "\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 @@
 "\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 @@
 "\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 @@
 "\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 );
 }


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to