diff options
author | Ton Roosendaal <ton@blender.org> | 2008-09-12 19:26:00 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-09-12 19:26:00 +0400 |
commit | 6ebd6cfa73aa96af2b97384242b716e75897766f (patch) | |
tree | 8c52785cf125f531956c2fcdda1cfe78ceee2016 /source/gameengine/GameLogic | |
parent | ed0a0c704d2032fdbe28b59559b723646ef63c7e (diff) |
Bugfixes in SDL joystick, apparently it gives NULLs in OSX.
Diffstat (limited to 'source/gameengine/GameLogic')
-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; } |