mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
InputCommon: Add a new ExpressionParser to replace the old hack language
This contains a new, hand-written expression parser to replace the old hack language based on string munging. The new approach is a simple AST-based evaluation approach, instead of the "list of operations" infix-based hack that there was before. The new language for configuration has support for parentheses, and counts "!" as a unary operator instead of the binary "NOT OR" operator it was before. A simple example: (X & Y) | !B Explicit device references, and complex device names ("Right Y+") are handled with backticks and colons: (`SDL/0/6 axis joystick:Right X+` & `DInput/0/Keyboard Mouse:A`) The basic editor UI that inserts tokens has not been updated to reflect the new language.
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "Thread.h"
|
||||
#include "ExpressionParser.h"
|
||||
#include "Device.h"
|
||||
|
||||
// enable disable sources
|
||||
@ -53,30 +54,28 @@ public:
|
||||
class ControlReference
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
|
||||
public:
|
||||
virtual ~ControlReference() {}
|
||||
|
||||
virtual ControlState State(const ControlState state = 0) = 0;
|
||||
virtual Device::Control* Detect(const unsigned int ms, Device* const device) = 0;
|
||||
size_t BoundCount() const { return m_controls.size(); }
|
||||
|
||||
ControlState range;
|
||||
ControlState range;
|
||||
std::string expression;
|
||||
const bool is_input;
|
||||
|
||||
virtual ~ControlReference() {
|
||||
delete parsed_expression;
|
||||
}
|
||||
|
||||
int BoundCount() {
|
||||
if (parsed_expression)
|
||||
return parsed_expression->num_controls;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
ControlReference(const bool _is_input) : range(1), is_input(_is_input) {}
|
||||
|
||||
struct DeviceControl
|
||||
{
|
||||
DeviceControl() : control(NULL), mode(0) {}
|
||||
|
||||
Device::Control* control;
|
||||
int mode;
|
||||
};
|
||||
|
||||
std::vector<DeviceControl> m_controls;
|
||||
ControlReference(const bool _is_input) : range(1), is_input(_is_input), parsed_expression(NULL) {}
|
||||
ciface::ExpressionParser::Expression *parsed_expression;
|
||||
};
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user