mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
FullscreenUI: Make right click on binding clear it
This commit is contained in:
parent
8531a5c8f0
commit
39498cda10
|
@ -150,6 +150,7 @@ static void DrawSettingsWindow();
|
||||||
static void BeginInputBinding(InputBindingType type, const std::string_view& section, const std::string_view& key,
|
static void BeginInputBinding(InputBindingType type, const std::string_view& section, const std::string_view& key,
|
||||||
const std::string_view& display_name);
|
const std::string_view& display_name);
|
||||||
static void EndInputBinding();
|
static void EndInputBinding();
|
||||||
|
static void ClearInputBinding(const char* section, const char* key);
|
||||||
static void DrawInputBindingWindow();
|
static void DrawInputBindingWindow();
|
||||||
|
|
||||||
static SettingsPage s_settings_page = SettingsPage::InterfaceSettings;
|
static SettingsPage s_settings_page = SettingsPage::InterfaceSettings;
|
||||||
|
@ -834,6 +835,8 @@ static void DrawInputBindingButton(InputBindingType type, const char* section, c
|
||||||
|
|
||||||
if (clicked)
|
if (clicked)
|
||||||
BeginInputBinding(type, section, name, display_name);
|
BeginInputBinding(type, section, name, display_name);
|
||||||
|
else if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
|
||||||
|
ClearInputBinding(section, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClearInputBindingVariables()
|
static void ClearInputBindingVariables()
|
||||||
|
@ -844,6 +847,11 @@ static void ClearInputBindingVariables()
|
||||||
s_input_binding_display_name.Clear();
|
s_input_binding_display_name.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsBindingInput()
|
||||||
|
{
|
||||||
|
return s_input_binding_type != InputBindingType::None;
|
||||||
|
}
|
||||||
|
|
||||||
bool HandleKeyboardBinding(const char* keyName, bool pressed)
|
bool HandleKeyboardBinding(const char* keyName, bool pressed)
|
||||||
{
|
{
|
||||||
if (s_input_binding_type == InputBindingType::None)
|
if (s_input_binding_type == InputBindingType::None)
|
||||||
|
@ -856,16 +864,15 @@ bool HandleKeyboardBinding(const char* keyName, bool pressed)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s_input_binding_keyboard_pressed)
|
if (!s_input_binding_keyboard_pressed)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
TinyString value;
|
TinyString value;
|
||||||
value.Format("Keyboard/%s", keyName);
|
value.Format("Keyboard/%s", keyName);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto lock = s_host_interface->GetSettingsLock();
|
||||||
s_host_interface->GetSettingsInterface()->SetStringValue(s_input_binding_section, s_input_binding_key, value);
|
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();
|
EndInputBinding();
|
||||||
s_host_interface->RunLater(SaveAndApplySettings);
|
s_host_interface->RunLater(SaveAndApplySettings);
|
||||||
|
@ -922,9 +929,10 @@ void BeginInputBinding(InputBindingType type, const std::string_view& section, c
|
||||||
if (value.IsEmpty())
|
if (value.IsEmpty())
|
||||||
return ControllerInterface::Hook::CallbackResult::ContinueMonitoring;
|
return ControllerInterface::Hook::CallbackResult::ContinueMonitoring;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto lock = s_host_interface->GetSettingsLock();
|
||||||
s_host_interface->GetSettingsInterface()->SetStringValue(s_input_binding_section, s_input_binding_key, value);
|
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());
|
|
||||||
|
|
||||||
ClearInputBindingVariables();
|
ClearInputBindingVariables();
|
||||||
s_host_interface->RunLater(SaveAndApplySettings);
|
s_host_interface->RunLater(SaveAndApplySettings);
|
||||||
|
@ -944,6 +952,16 @@ void EndInputBinding()
|
||||||
ci->ClearHook();
|
ci->ClearHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearInputBinding(const char* section, const char* key)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
auto lock = s_host_interface->GetSettingsLock();
|
||||||
|
s_host_interface->GetSettingsInterface()->DeleteValue(section, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
s_host_interface->RunLater(SaveAndApplySettings);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawInputBindingWindow()
|
void DrawInputBindingWindow()
|
||||||
{
|
{
|
||||||
DebugAssert(s_input_binding_type != InputBindingType::None);
|
DebugAssert(s_input_binding_type != InputBindingType::None);
|
||||||
|
|
|
@ -48,6 +48,8 @@ void OpenQuickMenu();
|
||||||
void CloseQuickMenu();
|
void CloseQuickMenu();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void Render();
|
void Render();
|
||||||
|
|
||||||
|
bool IsBindingInput();
|
||||||
bool HandleKeyboardBinding(const char* keyName, bool pressed);
|
bool HandleKeyboardBinding(const char* keyName, bool pressed);
|
||||||
|
|
||||||
bool InvalidateCachedTexture(const std::string& path);
|
bool InvalidateCachedTexture(const std::string& path);
|
||||||
|
|
Loading…
Reference in a new issue