diff options
| author | Gabriel Corona <gabriel.corona@enst-bretagne.fr> | 2015-02-26 00:41:59 +0100 |
|---|---|---|
| committer | Gabriel Corona <gabriel.corona@enst-bretagne.fr> | 2015-02-26 01:24:54 +0100 |
| commit | c626ce58092cff0aafd2feb4c3b3570b80595399 (patch) | |
| tree | 76432bd9d2ab9fb59b3bdffd6a04e5b2dcb98a30 /Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp | |
| parent | b1fbf205ec54ad2404edb14fbf19c80abde4ab05 (diff) | |
Do not fail to evaluate an expression if some input is missing
My keyboard layout does not have Alt_R but ISO_Level3_Shift. As a
consequence any control expression containing Alt_R fails to evaluate
completely and is unusable. This modification replace the missing term
of the expression by a dummy expression which always evaluate to
0. This way, the keybinding can work even if some keys are not
available.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp index 8c9060e69c..b49d4b8dce 100644 --- a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp @@ -219,6 +219,33 @@ public: virtual operator std::string() { return ""; } }; +class DummyExpression : public ExpressionNode +{ +public: + std::string name; + + DummyExpression(const std::string& name_) : name(name_) {} + + ControlState GetValue() override + { + return 0.0; + } + + void SetValue(ControlState value) override + { + } + + int CountNumControls() override + { + return 0; + } + + operator std::string() override + { + return "`" + name + "`"; + } +}; + class ControlExpression : public ExpressionNode { public: @@ -416,7 +443,10 @@ private: { Device::Control *control = finder.FindControl(tok.qualifier); if (control == nullptr) - return EXPRESSION_PARSE_NO_DEVICE; + { + *expr_out = new DummyExpression(tok.qualifier); + return EXPRESSION_PARSE_SUCCESS; + } *expr_out = new ControlExpression(tok.qualifier, control); return EXPRESSION_PARSE_SUCCESS; |
