Files
ppsspp/UI/GameBrowser.h
Henrik RydgårdandClaude Opus 5.5 b0382ed91a Game browser: Backspace goes up a directory, Windows raw input flags key repeats
With no type-to-search active, Backspace goes to the parent directory. Never
on a repeat, so holding it doesn't climb to the root. Not every platform
flags repeats, so the browser also tracks whether it's held.

Windows raw input now flags auto-repeated key downs as IS_REPEAT, like
Android and UWP, and forgets the held keys it releases on losing focus. The
UI drops OS repeats of a key it's already repeating itself, so held arrows
don't double up (they were dropped before too, a step later).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 11:36:30 +02:00

104 lines
2.7 KiB
C++

#pragma once
#include <functional>
#include <string_view>
#include "Common/File/Path.h"
#include "Common/UI/ViewGroup.h"
#include "Common/File/PathBrowser.h"
#include "Core/ConfigValues.h"
#include "UI/MiscViews.h"
enum GameBrowserFlags {
FLAG_HOMEBREWSTOREBUTTON = 1
};
enum class BrowseFlags {
NONE = 0,
NAVIGATE = 1,
BROWSE = 2,
ARCHIVES = 4,
PIN = 8,
HOMEBREW_STORE = 16,
UPLOAD_BUTTON = 32,
STANDARD = 1 | 2 | 4 | 8 | 32,
};
ENUM_CLASS_BITOPS(BrowseFlags);
class GameBrowser : public UI::LinearLayout {
public:
GameBrowser(int token, const Path &path, BrowseFlags browseFlags, bool portrait, int *viewMode, ScreenManager *screenManager, std::string_view lastText, std::string_view lastLink, UI::LayoutParams *layoutParams = nullptr);
UI::Event OnChoice;
UI::Event OnHoldChoice;
UI::Event OnHighlight;
void FocusGame(const Path &gamePath);
void SetPath(const Path &path);
void SetSearchBar(SearchBar *searchBar);
bool Key(const KeyInput &key) override;
void SetSearchFilter(const std::string &filter, bool setKeyboardFocus);
void Draw(UIContext &dc) override;
void Update() override;
void RequestRefresh() {
refreshPending_ = true;
}
void SetHomePath(const Path &path) {
homePath_ = path;
}
protected:
virtual bool HasSpecialFiles(std::vector<Path> &filenames);
virtual Path HomePath();
void Refresh();
GameBrowserViewMode ViewMode() const;
Path homePath_;
private:
bool IsCurrentPathPinned();
std::vector<Path> GetPinnedPaths() const;
void GameButtonClick(UI::EventParams &e);
void GameButtonHoldClick(UI::EventParams &e);
void GameButtonHighlight(UI::EventParams &e);
void NavigateClick(UI::EventParams &e);
void NavigateUp();
void PathChanged();
void LayoutChange(UI::EventParams &e);
void LastClick(UI::EventParams &e);
void BrowseClick(UI::EventParams &e);
void StorageClick(UI::EventParams &e);
void OnHomeClick(UI::EventParams &e);
void PinToggleClick(UI::EventParams &e);
void GridSettingsClick(UI::EventParams &e);
void OnRecentClear(UI::EventParams &e);
void OnHomebrewStore(UI::EventParams &e);
UI::ViewGroup *gameList_ = nullptr;
PathBrowser path_;
int *viewMode_ = nullptr;
BrowseFlags browseFlags_;
std::string lastText_;
std::string lastLink_;
ViewSearch search_{};
// A game or directory for Refresh to focus.
Path focusPath_;
// Set when entering a directory, for Refresh to focus its first entry.
bool focusFirstItem_ = false;
bool backspaceHeld_ = false;
bool listingPending_ = false;
bool refreshPending_ = false;
float lastScale_ = 1.0f;
GameBrowserViewMode lastViewMode_ = GameBrowserViewMode::GRID;
ScreenManager *screenManager_;
int token_ = -1;
bool portrait_ = false;
Path aliasMatch_;
std::string aliasDisplay_;
};