mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06: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:
@ -219,6 +219,33 @@ public:
|
|||||||
virtual operator std::string() { return ""; }
|
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
|
class ControlExpression : public ExpressionNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -416,7 +443,10 @@ private:
|
|||||||
{
|
{
|
||||||
Device::Control *control = finder.FindControl(tok.qualifier);
|
Device::Control *control = finder.FindControl(tok.qualifier);
|
||||||
if (control == nullptr)
|
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);
|
*expr_out = new ControlExpression(tok.qualifier, control);
|
||||||
return EXPRESSION_PARSE_SUCCESS;
|
return EXPRESSION_PARSE_SUCCESS;
|
||||||
|
Reference in New Issue
Block a user