From d99ddc5cf8c308bf7c0a61c1c266776a313936fa Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 1 May 2008 20:43:18 +0000 Subject: Fix BGE bug #8863: Keyboard Sensor does not send negative pulse if key released while scene suspended. The fix covers keyboard and mouse sensor --- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'source/gameengine/GameLogic/SCA_KeyboardSensor.cpp') 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; + } + } } } } -- cgit v1.2.3