mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +02:00
Merge pull request #6255 from samcake/controllers
Controllers : Adding support for 'NOT' ito the conditional endpoint
This commit is contained in:
commit
5d957e6535
3 changed files with 48 additions and 9 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
||||||
#include "impl/conditionals/AndConditional.h"
|
#include "impl/conditionals/AndConditional.h"
|
||||||
|
#include "impl/conditionals/NotConditional.h"
|
||||||
#include "impl/conditionals/EndpointConditional.h"
|
#include "impl/conditionals/EndpointConditional.h"
|
||||||
#include "impl/conditionals/ScriptConditional.h"
|
#include "impl/conditionals/ScriptConditional.h"
|
||||||
|
|
||||||
|
@ -826,13 +827,31 @@ Conditional::Pointer UserInputMapper::parseConditional(const QJsonValue& value)
|
||||||
return std::make_shared<AndConditional>(children);
|
return std::make_shared<AndConditional>(children);
|
||||||
} else if (value.isString()) {
|
} else if (value.isString()) {
|
||||||
// Support "when" : "GamePad.RB"
|
// Support "when" : "GamePad.RB"
|
||||||
auto input = findDeviceInput(value.toString());
|
auto conditionalToken = value.toString();
|
||||||
|
|
||||||
|
// Detect for modifier case (Not...)
|
||||||
|
QString conditionalModifier;
|
||||||
|
const QString JSON_CONDITIONAL_MODIFIER_NOT("!");
|
||||||
|
if (conditionalToken.startsWith(JSON_CONDITIONAL_MODIFIER_NOT)) {
|
||||||
|
conditionalModifier = JSON_CONDITIONAL_MODIFIER_NOT;
|
||||||
|
conditionalToken = conditionalToken.right(conditionalToken.size() - conditionalModifier.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto input = findDeviceInput(conditionalToken);
|
||||||
auto endpoint = endpointFor(input);
|
auto endpoint = endpointFor(input);
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
return Conditional::Pointer();
|
return Conditional::Pointer();
|
||||||
}
|
}
|
||||||
|
auto conditional = std::make_shared<EndpointConditional>(endpoint);
|
||||||
|
|
||||||
return std::make_shared<EndpointConditional>(endpoint);
|
if (!conditionalModifier.isEmpty()) {
|
||||||
|
if (conditionalModifier == JSON_CONDITIONAL_MODIFIER_NOT) {
|
||||||
|
return std::make_shared<NotConditional>(conditional);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default and conditional behavior
|
||||||
|
return conditional;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Conditional::parse(value);
|
return Conditional::parse(value);
|
||||||
|
|
|
@ -6,10 +6,16 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
|
||||||
// By removing this header we prevent these warnings on windows:
|
#include "NotConditional.h"
|
||||||
//
|
|
||||||
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
using namespace controller;
|
||||||
// so it will not be used by any link operation that consumes this library
|
|
||||||
//
|
bool NotConditional::satisfied() {
|
||||||
//#include "NotConditional.h"
|
if (_operand) {
|
||||||
|
return (!_operand->satisfied());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,19 @@
|
||||||
|
|
||||||
#include "../Conditional.h"
|
#include "../Conditional.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class NotConditional : public Conditional {
|
||||||
|
public:
|
||||||
|
using Pointer = std::shared_ptr<NotConditional>;
|
||||||
|
|
||||||
|
NotConditional(Conditional::Pointer operand) : _operand(operand) { }
|
||||||
|
|
||||||
|
virtual bool satisfied() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Conditional::Pointer _operand;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue