summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-07-11 10:53:51 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-07-11 13:38:52 -0400
commit74f308338195ac6c78008def5a6a4342c8b824af (patch)
tree6b2b065a3baf274b0881cc1899fb2ede6bff4845 /Source/Core/InputCommon/ControllerInterface
parent5abc028ace035479e46d545bf8231db5531a3d9f (diff)
ControllerInterface: Gate the input based on our new background input setting
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Device.cpp16
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Device.h18
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp4
3 files changed, 36 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Device.cpp b/Source/Core/InputCommon/ControllerInterface/Device.cpp
index e1383efc9d..61057c8162 100644
--- a/Source/Core/InputCommon/ControllerInterface/Device.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Device.cpp
@@ -5,6 +5,12 @@
#include <sstream>
#include <string>
+// For InputGateOn()
+// This is a really bad layering violation, but it's the cleanest
+// place I could find to put it.
+#include "Core/ConfigManager.h"
+#include "Core/Host.h"
+
#include "InputCommon/ControllerInterface/Device.h"
namespace ciface
@@ -74,6 +80,16 @@ void Device::ClearInputState()
// kinda slow but, w/e, should only happen when user unplugs a device while playing
}
+bool Device::Control::InputGateOn()
+{
+ if (SConfig::GetInstance().m_BackgroundInput)
+ return true;
+ else if (Host_RendererHasFocus())
+ return true;
+ else
+ return false;
+}
+
//
// DeviceQualifier :: ToString
//
diff --git a/Source/Core/InputCommon/ControllerInterface/Device.h b/Source/Core/InputCommon/ControllerInterface/Device.h
index a096bcb8b9..6e1868a4ba 100644
--- a/Source/Core/InputCommon/ControllerInterface/Device.h
+++ b/Source/Core/InputCommon/ControllerInterface/Device.h
@@ -42,6 +42,8 @@ public:
virtual std::string GetName() const = 0;
virtual ~Control() {}
+ bool InputGateOn();
+
virtual Input* ToInput() { return nullptr; }
virtual Output* ToOutput() { return nullptr; }
};
@@ -59,6 +61,16 @@ public:
virtual ControlState GetState() const = 0;
+ bool ShouldHaveInput();
+
+ ControlState GetGatedState()
+ {
+ if (InputGateOn())
+ return GetState();
+ else
+ return 0.0;
+ }
+
Input* ToInput() override { return this; }
};
@@ -74,6 +86,12 @@ public:
virtual void SetState(ControlState state) = 0;
+ void SetGatedState(ControlState state)
+ {
+ if (InputGateOn())
+ SetState(state);
+ }
+
Output* ToOutput() override { return this; }
};
diff --git a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp
index 2261a5df98..da740bbb7e 100644
--- a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp
@@ -228,12 +228,12 @@ public:
virtual ControlState GetValue() override
{
- return control->ToInput()->GetState();
+ return control->ToInput()->GetGatedState();
}
virtual void SetValue(ControlState value) override
{
- control->ToOutput()->SetState(value);
+ control->ToOutput()->SetGatedState(value);
}
virtual int CountNumControls() override