summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControlReference/ControlReference.h
diff options
context:
space:
mode:
authorMichael Maltese <michaeljosephmaltese@gmail.com>2016-10-11 17:48:38 -0700
committerMichael Maltese <michaeljosephmaltese@gmail.com>2017-02-07 22:59:10 -0800
commita509f56116d308c96e38898e07d3538f26a1b7af (patch)
tree1df255d62c9057cb3b53869afab04e737e96f0e0 /Source/Core/InputCommon/ControlReference/ControlReference.h
parentf621a6af431e53a71890f916dd812ccf987ab429 (diff)
InputCommon: Extract ControlReference from ControllerInterface
Better separation of concerns. Relegates `ControllerInterface` to enumerating input controls, and the new `ControlReference` deals with combining inputs and configuration expression parsing.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ControlReference.h')
-rw-r--r--Source/Core/InputCommon/ControlReference/ControlReference.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h
new file mode 100644
index 0000000000..335675e5eb
--- /dev/null
+++ b/Source/Core/InputCommon/ControlReference/ControlReference.h
@@ -0,0 +1,79 @@
+// Copyright 2016 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#pragma once
+
+#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();
+
+ virtual ControlState State(const ControlState state = 0) = 0;
+ virtual ciface::Core::Device::Control* Detect(const unsigned int ms,
+ ciface::Core::Device* const device) = 0;
+
+ void UpdateReference(ciface::Core::DeviceContainer& devices,
+ const ciface::Core::DeviceQualifier& default_device);
+
+ ControlState range;
+ std::string expression;
+ const bool is_input;
+ ciface::ExpressionParser::ExpressionParseStatus parse_error;
+
+ 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), parsed_expression(nullptr)
+ {
+ }
+ ciface::ExpressionParser::Expression* parsed_expression;
+};
+
+//
+// InputReference
+//
+// Control reference for inputs
+//
+class InputReference : public ControlReference
+{
+public:
+ InputReference() : ControlReference(true) {}
+ 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:
+ OutputReference() : ControlReference(false) {}
+ ControlState State(const ControlState state) override;
+ ciface::Core::Device::Control* Detect(const unsigned int ms,
+ ciface::Core::Device* const device) override;
+};