diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.cpp b/Source/Core/InputCommon/ControlReference/ControlReference.cpp index b1dd5deee3..671f2f3379 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.cpp +++ b/Source/Core/InputCommon/ControlReference/ControlReference.cpp @@ -50,12 +50,13 @@ std::string ControlReference::GetExpression() const return m_expression; } -void ControlReference::SetExpression(std::string expr) +std::optional ControlReference::SetExpression(std::string expr) { m_expression = std::move(expr); auto parse_result = ParseExpression(m_expression); m_parse_status = parse_result.status; m_parsed_expression = std::move(parse_result.expr); + return parse_result.description; } ControlReference::ControlReference() : range(1), m_parsed_expression(nullptr) diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h index de289ba265..fb4b5cc1df 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.h +++ b/Source/Core/InputCommon/ControlReference/ControlReference.h @@ -38,7 +38,9 @@ public: ciface::ExpressionParser::ParseStatus GetParseStatus() const; void UpdateReference(ciface::ExpressionParser::ControlEnvironment& env); std::string GetExpression() const; - void SetExpression(std::string expr); + + // Returns a human-readable error description when the given expression is invalid. + std::optional SetExpression(std::string expr); ControlState range;