2016-10-11 18:48:38 -06:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-09 14:57:01 -07:00
|
|
|
#include <memory>
|
|
|
|
|
2016-10-11 18:48:38 -06: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:
|
|
|
|
static bool InputGateOn();
|
|
|
|
|
2017-02-10 11:58:42 -07:00
|
|
|
virtual ~ControlReference();
|
2016-10-11 18:48:38 -06:00
|
|
|
virtual ControlState State(const ControlState state = 0) = 0;
|
|
|
|
virtual ciface::Core::Device::Control* Detect(const unsigned int ms,
|
|
|
|
ciface::Core::Device* const device) = 0;
|
2016-12-09 14:13:11 -07:00
|
|
|
virtual bool IsInput() const = 0;
|
2016-10-11 18:48:38 -06:00
|
|
|
|
2016-12-09 14:07:49 -07:00
|
|
|
int BoundCount() const;
|
2017-02-28 02:58:03 -07:00
|
|
|
ciface::ExpressionParser::ParseStatus GetParseStatus() const;
|
2017-02-10 22:29:22 -07:00
|
|
|
void UpdateReference(const ciface::Core::DeviceContainer& devices,
|
2016-10-11 18:48:38 -06:00
|
|
|
const ciface::Core::DeviceQualifier& default_device);
|
|
|
|
|
|
|
|
ControlState range;
|
|
|
|
std::string expression;
|
|
|
|
|
|
|
|
protected:
|
2016-12-09 14:13:11 -07:00
|
|
|
ControlReference();
|
2016-12-09 14:57:01 -07:00
|
|
|
std::unique_ptr<ciface::ExpressionParser::Expression> m_parsed_expression;
|
2017-02-28 02:58:03 -07:00
|
|
|
ciface::ExpressionParser::ParseStatus m_parse_status;
|
2016-10-11 18:48:38 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// InputReference
|
|
|
|
//
|
|
|
|
// Control reference for inputs
|
|
|
|
//
|
|
|
|
class InputReference : public ControlReference
|
|
|
|
{
|
|
|
|
public:
|
2016-12-09 14:07:49 -07:00
|
|
|
InputReference();
|
2016-12-09 14:13:11 -07:00
|
|
|
bool IsInput() const override;
|
2016-10-11 18:48:38 -06:00
|
|
|
ControlState State(const ControlState state) override;
|
|
|
|
ciface::Core::Device::Control* Detect(const unsigned int ms,
|
|
|
|
ciface::Core::Device* const device) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// OutputReference
|
|
|
|
//
|
|
|
|
// Control reference for outputs
|
|
|
|
//
|
|
|
|
class OutputReference : public ControlReference
|
|
|
|
{
|
|
|
|
public:
|
2016-12-09 14:07:49 -07:00
|
|
|
OutputReference();
|
2016-12-09 14:13:11 -07:00
|
|
|
bool IsInput() const override;
|
2016-10-11 18:48:38 -06:00
|
|
|
ControlState State(const ControlState state) override;
|
|
|
|
ciface::Core::Device::Control* Detect(const unsigned int ms,
|
|
|
|
ciface::Core::Device* const device) override;
|
|
|
|
};
|