diff options
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 403fbfe6f4c..8ef33240592 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -108,6 +108,9 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) bool result = false; bool reset = m_reset && m_level; + if(js==NULL) + return false; + m_reset = false; switch(m_joymode) { @@ -397,7 +400,9 @@ char SCA_JoystickSensor::GetRealAxis_doc[] = "\tReturns a list of the values for each axis .\n"; PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); + if(joy) + return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); + return NULL; } @@ -478,7 +483,9 @@ 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); - return PyInt_FromLong( joy->GetNumberOfAxes() ); + if(joy) + return PyInt_FromLong( joy->GetNumberOfAxes() ); + return false; } @@ -487,7 +494,9 @@ 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); - return PyInt_FromLong( joy->GetNumberOfButtons() ); + if(joy) + return PyInt_FromLong( joy->GetNumberOfButtons() ); + return false; } @@ -496,7 +505,9 @@ 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); - return PyInt_FromLong( joy->GetNumberOfHats() ); + if(joy) + return PyInt_FromLong( joy->GetNumberOfHats() ); + return false; } char SCA_JoystickSensor::Connected_doc[] = @@ -504,5 +515,7 @@ 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); - return PyBool_FromLong( joy->Connected() ); + if(joy) + return PyBool_FromLong( joy->Connected() ); + return false; } |