[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16331] trunk/blender/source/gameengine/ GameLogic: BGE joystick sensor bugfix, was sending true events logic tick ( as if the true pulse option was enabled).
Campbell Barton
ideasman42 at gmail.com
Tue Sep 2 04:03:04 CEST 2008
Revision: 16331
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16331
Author: campbellbarton
Date: 2008-09-02 04:03:03 +0200 (Tue, 02 Sep 2008)
Log Message:
-----------
BGE joystick sensor bugfix, was sending true events logic tick (as if the true pulse option was enabled).
Modified Paths:
--------------
trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.h
Modified: trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp 2008-09-01 14:04:22 UTC (rev 16330)
+++ trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.cpp 2008-09-02 02:03:03 UTC (rev 16331)
@@ -120,7 +120,7 @@
js->cSetPrecision(m_precision);
if(m_axisf == 1){
if(js->aUpAxisIsPositive(m_axis)){
- m_istrig =1;
+ m_istrig = 1;
result = true;
}else{
if(m_istrig){
@@ -243,11 +243,31 @@
printf("Error invalid switch statement\n");
break;
}
- if(!js->IsTrig()){
+
+ if (js->IsTrig()) {
+ /* This test detects changes with the joystick trigger state.
+ * js->IsTrig() will stay true as long as the key is held.
+ * even though the event from SDL will only be sent once.
+ * istrig_js && m_istrig_lastjs - when this is true it means this sensor
+ * had the same joystick trigger state last time,
+ * Setting the result false this time means it wont run the sensors
+ * controller every time (like a pulse sensor)
+ *
+ * This is not done with the joystick its self incase other sensors use
+ * it or become active.
+ */
+ if (m_istrig_lastjs) {
+ result = false;
+ }
+ m_istrig_lastjs = true;
+ } else {
m_istrig = 0;
+ m_istrig_lastjs = false;
}
+
if (reset)
result = true;
+
return result;
}
Modified: trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.h 2008-09-01 14:04:22 UTC (rev 16330)
+++ trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.h 2008-09-02 02:03:03 UTC (rev 16331)
@@ -69,6 +69,12 @@
*/
bool m_istrig;
/**
+ * Last trigger state for this sensors joystick,
+ * Otherwise it will trigger all the time
+ * this is used to see if the trigger state changes.
+ */
+ bool m_istrig_lastjs;
+ /**
* The mode to determine axis,button or hat
*/
short int m_joymode;
More information about the Bf-blender-cvs
mailing list