Skip to content

Commit e46890f

Browse files
TheLastRarlightningterror
authored andcommitted
FSUI: Use ImGui::Shortcut for most input handling
1 parent 3888638 commit e46890f

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

pcsx2/ImGui/FullscreenUI.cpp

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,19 +1530,16 @@ void FullscreenUI::DrawLandingWindow()
15301530
QueueResetFocus(FocusResetType::WindowChanged);
15311531
}
15321532
}
1533-
EndHorizontalMenu();
1534-
15351533
ImGui::PopStyleColor();
15361534

1537-
if (!AreAnyDialogsOpen())
1538-
{
1539-
if (ImGui::IsKeyPressed(ImGuiKey_GamepadBack, false) || ImGui::IsKeyPressed(ImGuiKey_F1, false))
1540-
OpenAboutWindow();
1541-
if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadInput, false) || ImGui::IsKeyPressed(ImGuiKey_Space, false))
1542-
SwitchToGameList();
1543-
else if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) || ImGui::IsKeyPressed(ImGuiKey_F11, false))
1544-
DoToggleFullscreen();
1545-
}
1535+
if (ImGui::Shortcut(ImGuiKey_GamepadBack) || ImGui::Shortcut(ImGuiKey_F1))
1536+
OpenAboutWindow();
1537+
if (ImGui::Shortcut(ImGuiKey_NavGamepadInput) || ImGui::Shortcut(ImGuiKey_Space))
1538+
SwitchToGameList();
1539+
else if (ImGui::Shortcut(ImGuiKey_NavGamepadMenu) || ImGui::Shortcut(ImGuiKey_F11))
1540+
DoToggleFullscreen();
1541+
1542+
EndHorizontalMenu();
15461543

15471544
if (IsGamepadInputSource())
15481545
{
@@ -1607,15 +1604,13 @@ void FullscreenUI::DrawStartGameWindow()
16071604
QueueResetFocus(FocusResetType::WindowChanged);
16081605
}
16091606
}
1610-
EndHorizontalMenu();
16111607

16121608
ImGui::PopStyleColor();
16131609

1614-
if (!AreAnyDialogsOpen())
1615-
{
1616-
if (ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) || ImGui::IsKeyPressed(ImGuiKey_F1, false))
1617-
OpenSaveStateSelector(true);
1618-
}
1610+
if (ImGui::Shortcut(ImGuiKey_NavGamepadMenu) || ImGui::Shortcut(ImGuiKey_F1))
1611+
OpenSaveStateSelector(true);
1612+
1613+
EndHorizontalMenu();
16191614

16201615
if (IsGamepadInputSource())
16211616
{
@@ -1838,7 +1833,7 @@ void FullscreenUI::DrawInputBindingButton(
18381833
{
18391834
BeginInputBinding(bsi, type, section, name, display_name);
18401835
}
1841-
else if (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false))
1836+
else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu)))
18421837
{
18431838
bsi->DeleteValue(section, name);
18441839
SetSettingsChanged(bsi);
@@ -6298,8 +6293,8 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
62986293
ReturnToMainWindow();
62996294
break;
63006295
}
6301-
else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) ||
6302-
ImGui::IsKeyPressed(ImGuiKey_F1, false)))
6296+
else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) ||
6297+
ImGui::Shortcut(ImGuiKey_F1)))
63036298
{
63046299
s_save_state_selector_submenu_index = static_cast<s32>(i);
63056300
}
@@ -6740,8 +6735,8 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
67406735
selected_entry = entry;
67416736

67426737
if (selected_entry &&
6743-
(ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) ||
6744-
ImGui::IsKeyPressed(ImGuiKey_F3, false)))
6738+
(ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) ||
6739+
ImGui::Shortcut(ImGuiKey_F3)))
67456740
{
67466741
HandleGameListOptions(selected_entry);
67476742
}
@@ -6966,8 +6961,8 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
69666961
{
69676962
HandleGameListActivate(entry);
69686963
}
6969-
else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false) ||
6970-
ImGui::IsKeyPressed(ImGuiKey_F3, false)))
6964+
else if (hovered && (ImGui::IsItemClicked(ImGuiMouseButton_Right) || ImGui::Shortcut(ImGuiKey_NavGamepadMenu) ||
6965+
ImGui::Shortcut(ImGuiKey_F3)))
69716966
{
69726967
HandleGameListOptions(entry);
69736968
}

pcsx2/ImGui/ImGuiFullscreen.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,7 @@ void ImGuiFullscreen::DrawFileSelector()
22402240

22412241
bool is_open = !WantsToCloseMenu();
22422242
bool directory_selected = false;
2243+
bool parent_wanted = false;
22432244
if (ImGui::BeginPopupModal(
22442245
s_file_selector_title.c_str(), &is_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
22452246
{
@@ -2270,6 +2271,12 @@ void ImGuiFullscreen::DrawFileSelector()
22702271

22712272
ImGui::PopStyleColor(1);
22722273

2274+
if ((ImGui::Shortcut(ImGuiKey_Backspace, false) || ImGui::Shortcut(ImGuiKey_NavGamepadInput, false)) &&
2275+
(!s_file_selector_items.empty() && s_file_selector_items.front().display_name == ICON_FA_FOLDER_OPEN " <Parent Directory>"))
2276+
{
2277+
parent_wanted = true;
2278+
}
2279+
22732280
ImGui::EndPopup();
22742281
}
22752282
else
@@ -2306,17 +2313,10 @@ void ImGuiFullscreen::DrawFileSelector()
23062313
s_file_selector_callback(no_path);
23072314
CloseFileSelector();
23082315
}
2309-
else
2316+
else if (parent_wanted)
23102317
{
2311-
if (ImGui::IsKeyPressed(ImGuiKey_Backspace, false) || ImGui::IsKeyPressed(ImGuiKey_NavGamepadMenu, false))
2312-
{
2313-
if (!s_file_selector_items.empty() && s_file_selector_items.front().display_name == ICON_FA_FOLDER_OPEN
2314-
" <Parent Directory>")
2315-
{
2316-
SetFileSelectorDirectory(std::move(s_file_selector_items.front().full_path));
2317-
QueueResetFocus(FocusResetType::Other);
2318-
}
2319-
}
2318+
SetFileSelectorDirectory(std::move(s_file_selector_items.front().full_path));
2319+
QueueResetFocus(FocusResetType::Other);
23202320
}
23212321
}
23222322

0 commit comments

Comments
 (0)