Fix BGE bug #8863: Keyboard Sensor does not send negative pulse if key released while scene suspended. The fix covers keyboard and mouse sensor

This commit is contained in:
Benoit Bolsee 2008-05-01 20:43:18 +00:00
parent 57b819301c
commit d99ddc5cf8
2 changed files with 60 additions and 0 deletions

@ -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;
}
}
}
}
}

@ -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;