InputCommon: Make hotkeys and input detection aware of Ctrl -> L_Ctrl / R_Ctrl hierarchy.

This commit is contained in:
Jordan Woyak
2020-01-26 13:58:20 -06:00
parent aae913fbc6
commit d8ad8c3861
4 changed files with 65 additions and 44 deletions

View File

@ -85,6 +85,11 @@ public:
virtual ControlState GetState() const = 0;
Input* ToInput() override { return this; }
// Overridden by CombinedInput,
// so hotkey logic knows Ctrl, L_Ctrl, and R_Ctrl are the same,
// and so input detection can return the parent name.
virtual bool IsChild(const Input*) const { return false; }
};
//
@ -119,6 +124,8 @@ public:
const std::vector<Input*>& Inputs() const { return m_inputs; }
const std::vector<Output*>& Outputs() const { return m_outputs; }
Input* GetParentMostInput(Input* input) const;
Input* FindInput(std::string_view name) const;
Output* FindOutput(std::string_view name) const;
@ -147,21 +154,6 @@ protected:
AddInput(new FullAnalogSurface(high, low));
}
class CombinedInput final : public Input
{
public:
using Inputs = std::pair<Input*, Input*>;
CombinedInput(std::string name, const Inputs& inputs);
ControlState GetState() const override;
std::string GetName() const override;
bool IsDetectable() override;
private:
const std::string m_name;
const std::pair<Input*, Input*> m_inputs;
};
void AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs);
private: