[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16491] trunk/blender/source/gameengine/ GameLogic/SCA_JoystickSensor.cpp: Bugfixes in SDL joystick, apparently it gives NULLs in OSX.
Ton Roosendaal
ton at blender.org
Fri Sep 12 17:26:00 CEST 2008
Revision: 16491
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16491
Author: ton
Date: 2008-09-12 17:26:00 +0200 (Fri, 12 Sep 2008)
Log Message:
-----------
Bugfixes in SDL joystick, apparently it gives NULLs in OSX.
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-12 14:09:44 UTC (rev 16490)
+++ trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp 2008-09-12 15:26:00 UTC (rev 16491)
@@ -108,6 +108,9 @@
bool result = false;
bool reset = m_reset && m_level;
+ if(js==NULL)
+ return false;
+
m_reset = false;
switch(m_joymode)
{
@@ -397,7 +400,9 @@
"\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 @@
"\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 @@
"\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 @@
"\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 @@
"\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;
}
More information about the Bf-blender-cvs
mailing list