Allow keyboard binding in nogui/fullscreen mode (#1679)

* Allow keyboard binding in nogui/fullscreen mode
This commit is contained in:
Chris
2021-02-24 11:05:33 -05:00
committed by GitHub
parent 0d0a7eac1f
commit dd3d5dbd86
5 changed files with 55 additions and 1 deletions

View File

@ -141,6 +141,7 @@ static InputBindingType s_input_binding_type = InputBindingType::None;
static TinyString s_input_binding_section;
static TinyString s_input_binding_key;
static TinyString s_input_binding_display_name;
static bool s_input_binding_keyboard_pressed;
static Common::Timer s_input_binding_timer;
//////////////////////////////////////////////////////////////////////////
@ -816,6 +817,34 @@ static void ClearInputBindingVariables()
s_input_binding_display_name.Clear();
}
bool HandleKeyboardBinding(const char* keyName, bool pressed)
{
if (s_input_binding_type == InputBindingType::None)
return false;
if (pressed)
{
s_input_binding_keyboard_pressed = true;
return true;
}
if (!s_input_binding_keyboard_pressed)
{
return false;
}
TinyString value;
value.Format("Keyboard/%s", keyName);
s_host_interface->GetSettingsInterface()->SetStringValue(s_input_binding_section, s_input_binding_key, value);
s_host_interface->AddFormattedOSDMessage(5.0f, "Set %s binding %s to %s.", s_input_binding_section.GetCharArray(),
s_input_binding_display_name.GetCharArray(), value.GetCharArray());
EndInputBinding();
s_host_interface->RunLater(SaveAndApplySettings);
return true;
}
void BeginInputBinding(InputBindingType type, const std::string_view& section, const std::string_view& key,
const std::string_view& display_name)
{