2016-10-12 00:48:38 +00:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-09 21:57:01 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-10-12 00:48:38 +00:00
|
|
|
#include "InputCommon/ControlReference/ExpressionParser.h"
|
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
|
|
|
|
|
|
|
// ControlReference
|
|
|
|
//
|
|
|
|
// These are what you create to actually use the inputs, InputReference or OutputReference.
|
|
|
|
//
|
|
|
|
// After being bound to devices and controls with UpdateReference,
|
|
|
|
// each one can link to multiple devices and controls
|
|
|
|
// when you change a ControlReference's expression,
|
|
|
|
// you must use UpdateReference on it to rebind controls
|
|
|
|
//
|
|
|
|
|
|
|
|
class ControlReference
|
|
|
|
{
|
|
|
|
public:
|
2019-11-06 21:59:36 +00:00
|
|
|
// Note: this is per thread.
|
|
|
|
static void SetInputGate(bool enable);
|
|
|
|
static bool GetInputGate();
|
2016-10-12 00:48:38 +00:00
|
|
|
|
2017-02-10 18:58:42 +00:00
|
|
|
virtual ~ControlReference();
|
2016-10-12 00:48:38 +00:00
|
|
|
virtual ControlState State(const ControlState state = 0) = 0;
|
2016-12-09 21:13:11 +00:00
|
|
|
virtual bool IsInput() const = 0;
|
2016-10-12 00:48:38 +00:00
|
|
|
|
2016-12-09 21:07:49 +00:00
|
|
|
int BoundCount() const;
|
2017-02-28 09:58:03 +00:00
|
|
|
ciface::ExpressionParser::ParseStatus GetParseStatus() const;
|
2018-12-30 22:06:29 +00:00
|
|
|
void UpdateReference(ciface::ExpressionParser::ControlEnvironment& env);
|
2017-06-08 02:02:16 +00:00
|
|
|
std::string GetExpression() const;
|
|
|
|
void SetExpression(std::string expr);
|
2016-10-12 00:48:38 +00:00
|
|
|
|
|
|
|
ControlState range;
|
|
|
|
|
|
|
|
protected:
|
2016-12-09 21:13:11 +00:00
|
|
|
ControlReference();
|
2017-06-08 02:02:16 +00:00
|
|
|
std::string m_expression;
|
2016-12-09 21:57:01 +00:00
|
|
|
std::unique_ptr<ciface::ExpressionParser::Expression> m_parsed_expression;
|
2017-02-28 09:58:03 +00:00
|
|
|
ciface::ExpressionParser::ParseStatus m_parse_status;
|
2016-10-12 00:48:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// InputReference
|
|
|
|
//
|
|
|
|
// Control reference for inputs
|
|
|
|
//
|
|
|
|
class InputReference : public ControlReference
|
|
|
|
{
|
|
|
|
public:
|
2016-12-09 21:07:49 +00:00
|
|
|
InputReference();
|
2016-12-09 21:13:11 +00:00
|
|
|
bool IsInput() const override;
|
2016-10-12 00:48:38 +00:00
|
|
|
ControlState State(const ControlState state) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// OutputReference
|
|
|
|
//
|
|
|
|
// Control reference for outputs
|
|
|
|
//
|
|
|
|
class OutputReference : public ControlReference
|
|
|
|
{
|
|
|
|
public:
|
2016-12-09 21:07:49 +00:00
|
|
|
OutputReference();
|
2016-12-09 21:13:11 +00:00
|
|
|
bool IsInput() const override;
|
2016-10-12 00:48:38 +00:00
|
|
|
ControlState State(const ControlState state) override;
|
|
|
|
};
|