Skip to content

Commit

Permalink
UPBGE: Fix keyboard sensor without qualifiers.
Browse files Browse the repository at this point in the history
Previously the qualifiers was taken in count event if they was unused.
It create the sensor to be always true as the default status of qualifier is
to true in the Evaluate function.

To fix this issue the logic was inverted : the default value is to false and
test on these values are done only if m_qual and m_qual2 are valid.
  • Loading branch information
panzergame committed Jun 28, 2016
1 parent 6ee296f commit 2c5c0b8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool SCA_KeyboardSensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
bool qual[2] = {true, true};
bool qual[2] = {false, false};

SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
// cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n";
Expand Down Expand Up @@ -190,15 +190,15 @@ bool SCA_KeyboardSensor::Evaluate()
*/
if (m_qual > 0) {
const SCA_InputEvent & qualevent = inputdev->GetInput((SCA_IInputDevice::SCA_EnumInputs) m_qual);
if (!qualevent.Find(SCA_InputEvent::ACTIVE)) {
qual[0] = false;
if (qualevent.Find(SCA_InputEvent::ACTIVE)) {
qual[0] = true;
}
}
if (m_qual2 > 0) {
const SCA_InputEvent & qualevent = inputdev->GetInput((SCA_IInputDevice::SCA_EnumInputs) m_qual2);
/* copy of above */
if (!qualevent.Find(SCA_InputEvent::ACTIVE)) {
qual[1] = false;
if (qualevent.Find(SCA_InputEvent::ACTIVE)) {
qual[1] = true;
}
}
/* done reading qualifiers */
Expand Down Expand Up @@ -229,7 +229,7 @@ bool SCA_KeyboardSensor::Evaluate()
m_status[1] = qual[0];
m_status[2] = qual[1];

if (!qual[0] || !qual[1]) { /* one of the qualifiers are not pressed */
if ((m_qual > 0 && !qual[0]) || (m_qual2 > 0 && !qual[1])) { /* one of the used qualifiers are not pressed */
m_val = 0; /* since one of the qualifiers is not on, set the state to false */
}
/* done with key quals */
Expand Down

0 comments on commit 2c5c0b8

Please sign in to comment.