summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/Device.h
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2019-03-13 19:00:24 -0400
committerGitHub <noreply@github.com>2019-03-13 19:00:24 -0400
commit011ecd92e8e2b0b78471cc7ad394b6ed1f7a451e (patch)
treeee12d70ff3889b093c2696715eace0952aee8ccb /Source/Core/InputCommon/ControllerInterface/Device.h
parentbc9e9caf19749778d01b9721a1ff92acccf70fac (diff)
parentc389d68186ea7fa95d763d7bb55bc09e5a45c4cd (diff)
Merge pull request #7829 from jordan-woyak/detect-input-improve
ControllerInterface/DolphinQt: Improve input detection.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Device.h')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Device.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Device.h b/Source/Core/InputCommon/ControllerInterface/Device.h
index 7b36da934a..7d7623ba03 100644
--- a/Source/Core/InputCommon/ControllerInterface/Device.h
+++ b/Source/Core/InputCommon/ControllerInterface/Device.h
@@ -55,9 +55,22 @@ public:
class Input : public Control
{
public:
- // things like absolute axes/ absolute mouse position will override this
+ // Things like absolute axes/ absolute mouse position should override this to prevent
+ // undesirable behavior in our mapping logic.
virtual bool IsDetectable() { return true; }
+
+ // Implementations should return a value from 0.0 to 1.0 across their normal range.
+ // One input should be provided for each "direction". (e.g. 2 for each axis)
+ // If possible, negative values may be returned in situations where an opposing input is
+ // activated. (e.g. When an underlying axis, X, is currently negative, "Axis X-", will return a
+ // positive value and "Axis X+" may return a negative value.)
+ // Doing so is solely to allow our input detection logic to better detect false positives.
+ // This is necessary when making use of "FullAnalogSurface" as multiple inputs will be seen
+ // increasing from 0.0 to 1.0 as a user tries to map just one. The negative values provide a
+ // view of the underlying axis. (Negative values are clamped off before they reach
+ // expression-parser or controller-emu)
virtual ControlState GetState() const = 0;
+
Input* ToInput() override { return this; }
};
@@ -96,11 +109,7 @@ protected:
{
public:
FullAnalogSurface(Input* low, Input* high) : m_low(*low), m_high(*high) {}
- ControlState GetState() const override
- {
- return (1 + m_high.GetState() - m_low.GetState()) / 2;
- }
-
+ ControlState GetState() const override;
std::string GetName() const override { return m_low.GetName() + *m_high.GetName().rbegin(); }
private:
@@ -163,6 +172,9 @@ public:
bool HasConnectedDevice(const DeviceQualifier& qualifier) const;
+ std::pair<std::shared_ptr<Device>, Device::Input*>
+ DetectInput(u32 wait_ms, std::vector<std::string> device_strings);
+
protected:
mutable std::mutex m_devices_mutex;
std::vector<std::shared_ptr<Device>> m_devices;