2014-02-10 18:54:46 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 18:54:46 +00:00
|
|
|
// Refer to the license.txt file included.
|
2013-06-14 03:09:55 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2013-06-14 03:09:55 +00:00
|
|
|
|
2016-06-26 03:34:09 +00:00
|
|
|
#include <memory>
|
2013-06-14 03:09:55 +00:00
|
|
|
#include <string>
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
2013-06-14 03:09:55 +00:00
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
|
|
|
namespace ExpressionParser
|
|
|
|
{
|
|
|
|
class ControlQualifier
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
bool has_device;
|
|
|
|
Core::DeviceQualifier device_qualifier;
|
|
|
|
std::string control_name;
|
2013-06-14 03:09:55 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ControlQualifier() : has_device(false) {}
|
|
|
|
operator std::string()
|
|
|
|
{
|
|
|
|
if (has_device)
|
|
|
|
return device_qualifier.ToString() + ":" + control_name;
|
|
|
|
else
|
|
|
|
return control_name;
|
|
|
|
}
|
2013-06-14 03:09:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ControlFinder
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
ControlFinder(const Core::DeviceContainer& container_, const Core::DeviceQualifier& default_,
|
|
|
|
const bool is_input_)
|
|
|
|
: container(container_), default_device(default_), is_input(is_input_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
Core::Device::Control* FindControl(ControlQualifier qualifier);
|
2013-06-14 03:09:55 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-25 19:46:39 +00:00
|
|
|
std::shared_ptr<Core::Device> FindDevice(ControlQualifier qualifier);
|
2016-06-24 08:43:46 +00:00
|
|
|
const Core::DeviceContainer& container;
|
|
|
|
const Core::DeviceQualifier& default_device;
|
|
|
|
bool is_input;
|
2013-06-14 03:09:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ExpressionNode;
|
|
|
|
class Expression
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
Expression() : node(nullptr) {}
|
|
|
|
Expression(ExpressionNode* node);
|
|
|
|
~Expression();
|
|
|
|
ControlState GetValue();
|
|
|
|
void SetValue(ControlState state);
|
|
|
|
int num_controls;
|
|
|
|
ExpressionNode* node;
|
2013-06-14 03:09:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ExpressionParseStatus
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPRESSION_PARSE_SUCCESS = 0,
|
|
|
|
EXPRESSION_PARSE_SYNTAX_ERROR,
|
|
|
|
EXPRESSION_PARSE_NO_DEVICE,
|
2013-06-14 03:09:55 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ExpressionParseStatus ParseExpression(const std::string& expr, ControlFinder& finder,
|
|
|
|
Expression** expr_out);
|
2013-06-14 03:09:55 +00:00
|
|
|
}
|
|
|
|
}
|