mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
ControllerInterface: Gate the input based on our new background input setting
This commit is contained in:
parent
5abc028ace
commit
74f3083381
@ -5,6 +5,12 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#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"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
namespace ciface
|
namespace ciface
|
||||||
@ -74,6 +80,16 @@ void Device::ClearInputState()
|
|||||||
// kinda slow but, w/e, should only happen when user unplugs a device while playing
|
// 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
|
// DeviceQualifier :: ToString
|
||||||
//
|
//
|
||||||
|
@ -42,6 +42,8 @@ public:
|
|||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
virtual ~Control() {}
|
virtual ~Control() {}
|
||||||
|
|
||||||
|
bool InputGateOn();
|
||||||
|
|
||||||
virtual Input* ToInput() { return nullptr; }
|
virtual Input* ToInput() { return nullptr; }
|
||||||
virtual Output* ToOutput() { return nullptr; }
|
virtual Output* ToOutput() { return nullptr; }
|
||||||
};
|
};
|
||||||
@ -59,6 +61,16 @@ public:
|
|||||||
|
|
||||||
virtual ControlState GetState() const = 0;
|
virtual ControlState GetState() const = 0;
|
||||||
|
|
||||||
|
bool ShouldHaveInput();
|
||||||
|
|
||||||
|
ControlState GetGatedState()
|
||||||
|
{
|
||||||
|
if (InputGateOn())
|
||||||
|
return GetState();
|
||||||
|
else
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
Input* ToInput() override { return this; }
|
Input* ToInput() override { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,6 +86,12 @@ public:
|
|||||||
|
|
||||||
virtual void SetState(ControlState state) = 0;
|
virtual void SetState(ControlState state) = 0;
|
||||||
|
|
||||||
|
void SetGatedState(ControlState state)
|
||||||
|
{
|
||||||
|
if (InputGateOn())
|
||||||
|
SetState(state);
|
||||||
|
}
|
||||||
|
|
||||||
Output* ToOutput() override { return this; }
|
Output* ToOutput() override { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,12 +228,12 @@ public:
|
|||||||
|
|
||||||
virtual ControlState GetValue() override
|
virtual ControlState GetValue() override
|
||||||
{
|
{
|
||||||
return control->ToInput()->GetState();
|
return control->ToInput()->GetGatedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetValue(ControlState value) override
|
virtual void SetValue(ControlState value) override
|
||||||
{
|
{
|
||||||
control->ToOutput()->SetState(value);
|
control->ToOutput()->SetGatedState(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int CountNumControls() override
|
virtual int CountNumControls() override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user