diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-05-02 00:43:18 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-05-02 00:43:18 +0400 |
commit | d99ddc5cf8c308bf7c0a61c1c266776a313936fa (patch) | |
tree | c724668b20202a1d47dd3bb6975a622819c714fd /source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | |
parent | 57b819301cba95357c421aee0e6b927a715ffb16 (diff) |
Fix BGE bug #8863: Keyboard Sensor does not send negative pulse if key released while scene suspended. The fix covers keyboard and mouse sensor
Diffstat (limited to 'source/gameengine/GameLogic/SCA_KeyboardSensor.cpp')
-rw-r--r-- | source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 36 |
1 files changed, 36 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; + } + } } } } |