diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 36 | ||||
-rw-r--r-- | source/gameengine/GameLogic/SCA_MouseSensor.cpp | 24 |
2 files changed, 60 insertions, 0 deletions
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index f8fc256b371..8a12bd298c2 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -163,6 +163,23 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { m_val=(active)?1:0; result = true; + } else + { + if (active) + { + if (m_val == 0) + { + m_val = 1; + result = true; + } + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } + } } } @@ -178,6 +195,13 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS) { + if (m_val == 1) + { + // this situation may occur after a scene suspend: the keyboard release + // event was not captured, produce now the event off + m_val = 0; + result = true; + } } else { if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) @@ -190,6 +214,18 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { m_val = 0; result = true; + } else + { + if (inevent.m_status == SCA_InputEvent::KX_ACTIVE) + { + if (m_val == 0) + { + // this may occur during a scene suspend, the keyboard + // press was not captured, do it now + m_val = 1; + result = true; + } + } } } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index a91cf3e0439..d8894ff593c 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -158,6 +158,23 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { m_val = 0; result = true; + } else + { + if (event.m_status == SCA_InputEvent::KX_ACTIVE) + { + if (m_val == 0) + { + m_val = 1; + result = true; + } + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } + } } } break; @@ -183,6 +200,13 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { m_val = 0; result = true; + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } } } break; |