mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
ControllerInterface: Add platform consistent names for modifier keys.
This commit is contained in:
parent
d2729df281
commit
f015c99a51
@ -87,6 +87,11 @@ KeyboardMouse::KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device,
|
||||
for (u8 i = 0; i < sizeof(named_keys) / sizeof(*named_keys); ++i)
|
||||
AddInput(new Key(i, m_state_in.keyboard[named_keys[i].code]));
|
||||
|
||||
// Add combined left/right modifiers with consistent naming across platforms.
|
||||
AddCombinedInput("Alt", {"LMENU", "RMENU"});
|
||||
AddCombinedInput("Shift", {"LSHIFT", "RSHIFT"});
|
||||
AddCombinedInput("Ctrl", {"LCONTROL", "RCONTROL"});
|
||||
|
||||
// MOUSE
|
||||
DIDEVCAPS mouse_caps = {};
|
||||
mouse_caps.dwSize = sizeof(mouse_caps);
|
||||
|
@ -103,6 +103,39 @@ bool Device::FullAnalogSurface::IsMatchingName(std::string_view name) const
|
||||
return old_name == name;
|
||||
}
|
||||
|
||||
Device::CombinedInput::CombinedInput(std::string name, const Inputs& inputs)
|
||||
: m_name(std::move(name)), m_inputs(inputs)
|
||||
{
|
||||
}
|
||||
|
||||
ControlState Device::CombinedInput::GetState() const
|
||||
{
|
||||
ControlState result = 0;
|
||||
|
||||
if (m_inputs.first)
|
||||
result = m_inputs.first->GetState();
|
||||
|
||||
if (m_inputs.second)
|
||||
result = std::max(result, m_inputs.second->GetState());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Device::CombinedInput::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool Device::CombinedInput::IsDetectable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Device::AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs)
|
||||
{
|
||||
AddInput(new CombinedInput(std::move(name), {FindInput(inputs.first), FindInput(inputs.second)}));
|
||||
}
|
||||
|
||||
//
|
||||
// DeviceQualifier :: ToString
|
||||
//
|
||||
|
@ -147,6 +147,23 @@ 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:
|
||||
int m_id;
|
||||
std::vector<Input*> m_inputs;
|
||||
|
@ -143,6 +143,11 @@ KeyboardAndMouse::KeyboardAndMouse(void* window)
|
||||
for (int keycode = 0; keycode < 0x80; ++keycode)
|
||||
AddInput(new Key(keycode));
|
||||
|
||||
// Add combined left/right modifiers with consistent naming across platforms.
|
||||
AddCombinedInput("Alt", {"Left Alt", "Right Alt"});
|
||||
AddCombinedInput("Shift", {"Left Shift", "Right Shift"});
|
||||
AddCombinedInput("Ctrl", {"Left Control", "Right Control"});
|
||||
|
||||
m_windowid = [[reinterpret_cast<NSView*>(window) window] windowNumber];
|
||||
|
||||
// cursor, with a hax for-loop
|
||||
|
@ -172,6 +172,11 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
|
||||
delete temp_key;
|
||||
}
|
||||
|
||||
// Add combined left/right modifiers with consistent naming across platforms.
|
||||
AddCombinedInput("Alt", {"Alt_L", "Alt_R"});
|
||||
AddCombinedInput("Shift", {"Shift_L", "Shift_R"});
|
||||
AddCombinedInput("Ctrl", {"Control_L", "Control_R"});
|
||||
|
||||
// Mouse Buttons
|
||||
for (int i = 0; i < 32; i++)
|
||||
AddInput(new Button(i, &m_state.buttons));
|
||||
|
Loading…
Reference in New Issue
Block a user