mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-01 10:31:31 +02:00
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.
This commit is contained in:
parent
b1fbf205ec
commit
c626ce5809
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user