mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add categories for control bindings
This commit is contained in:
parent
2d4e59eb62
commit
9cb3d03098
7 changed files with 70 additions and 14 deletions
|
@ -182,6 +182,16 @@ Point View::GetFocusPosition(FocusDirection dir) const {
|
|||
}
|
||||
}
|
||||
|
||||
Point CollapsibleHeader::GetFocusPosition(FocusDirection dir) const {
|
||||
// Bias the focus position to the left.
|
||||
switch (dir) {
|
||||
case FOCUS_UP: return Point(bounds_.x + 50, bounds_.y + 2);
|
||||
case FOCUS_DOWN: return Point(bounds_.x + 50, bounds_.y2() - 2);
|
||||
default:
|
||||
return View::GetFocusPosition(dir);
|
||||
}
|
||||
}
|
||||
|
||||
bool View::SetFocus() {
|
||||
if (IsFocusMovementEnabled()) {
|
||||
if (CanBeFocused()) {
|
||||
|
|
|
@ -468,7 +468,7 @@ public:
|
|||
virtual bool IsViewGroup() const { return false; }
|
||||
virtual bool ContainsSubview(const View *view) const { return false; }
|
||||
|
||||
Point GetFocusPosition(FocusDirection dir) const;
|
||||
virtual Point GetFocusPosition(FocusDirection dir) const;
|
||||
|
||||
template <class T>
|
||||
T *AddTween(T *t) {
|
||||
|
@ -871,6 +871,8 @@ public:
|
|||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
|
||||
Point GetFocusPosition(FocusDirection dir) const override;
|
||||
|
||||
void SetHasSubitems(bool hasSubItems) { hasSubItems_ = hasSubItems; }
|
||||
private:
|
||||
bool hasSubItems_ = true;
|
||||
|
|
|
@ -1186,9 +1186,7 @@ CollapsibleSection::CollapsibleSection(const std::string &title, LayoutParams *l
|
|||
heading_->OnClick.Add([=](UI::EventParams &) {
|
||||
// Change the visibility of all children except the first one.
|
||||
// Later maybe try something more ambitious.
|
||||
for (size_t i = 1; i < views_.size(); i++) {
|
||||
views_[i]->SetVisibility(open_ ? V_VISIBLE : V_GONE);
|
||||
}
|
||||
UpdateVisibility();
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
}
|
||||
|
@ -1198,4 +1196,10 @@ void CollapsibleSection::Update() {
|
|||
heading_->SetHasSubitems(views_.size() > 1);
|
||||
}
|
||||
|
||||
void CollapsibleSection::UpdateVisibility() {
|
||||
for (size_t i = 1; i < views_.size(); i++) {
|
||||
views_[i]->SetVisibility(open_ ? V_VISIBLE : V_GONE);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace UI
|
||||
|
|
|
@ -327,7 +327,13 @@ public:
|
|||
|
||||
void Update() override;
|
||||
|
||||
void SetOpen(bool open) {
|
||||
open_ = open;
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateVisibility();
|
||||
bool open_ = true;
|
||||
CollapsibleHeader *heading_;
|
||||
};
|
||||
|
|
|
@ -399,9 +399,13 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
|||
{VIRTKEY_AXIS_Y_MIN, "An.Down"},
|
||||
{VIRTKEY_AXIS_X_MIN, "An.Left"},
|
||||
{VIRTKEY_AXIS_X_MAX, "An.Right"},
|
||||
{VIRTKEY_ANALOG_LIGHTLY, "Analog limiter"},
|
||||
|
||||
{VIRTKEY_ANALOG_ROTATE_CW, "Rotate Analog (CW)"},
|
||||
{VIRTKEY_ANALOG_ROTATE_CCW, "Rotate Analog (CCW)"},
|
||||
{VIRTKEY_ANALOG_LIGHTLY, "Analog limiter"},
|
||||
{VIRTKEY_RAPID_FIRE, "RapidFire"},
|
||||
{VIRTKEY_AXIS_SWAP, "AxisSwap"},
|
||||
|
||||
{VIRTKEY_FASTFORWARD, "Fast-forward"},
|
||||
{VIRTKEY_SPEED_TOGGLE, "SpeedToggle"},
|
||||
{VIRTKEY_SPEED_CUSTOM1, "Alt speed 1"},
|
||||
|
@ -421,20 +425,13 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
|||
{VIRTKEY_TOGGLE_FULLSCREEN, "Toggle Fullscreen"},
|
||||
#endif
|
||||
|
||||
{VIRTKEY_AXIS_RIGHT_Y_MAX, "RightAn.Up"},
|
||||
{VIRTKEY_AXIS_RIGHT_Y_MIN, "RightAn.Down"},
|
||||
{VIRTKEY_AXIS_RIGHT_X_MIN, "RightAn.Left"},
|
||||
{VIRTKEY_AXIS_RIGHT_X_MAX, "RightAn.Right"},
|
||||
{VIRTKEY_OPENCHAT, "OpenChat" },
|
||||
|
||||
{VIRTKEY_AXIS_SWAP, "AxisSwap"},
|
||||
{VIRTKEY_DEVMENU, "DevMenu"},
|
||||
{VIRTKEY_TEXTURE_DUMP, "Texture Dumping"},
|
||||
{VIRTKEY_TEXTURE_REPLACE, "Texture Replacement"},
|
||||
{VIRTKEY_SCREENSHOT, "Screenshot"},
|
||||
{VIRTKEY_MUTE_TOGGLE, "Mute toggle"},
|
||||
{VIRTKEY_ANALOG_ROTATE_CW, "Rotate Analog (CW)"},
|
||||
{VIRTKEY_ANALOG_ROTATE_CCW, "Rotate Analog (CCW)"},
|
||||
|
||||
#ifdef OPENXR
|
||||
{VIRTKEY_VR_CAMERA_ADJUST, "VR camera adjust"},
|
||||
|
@ -449,6 +446,11 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
|||
{VIRTKEY_TOGGLE_WLAN, "Toggle WLAN"},
|
||||
{VIRTKEY_EXIT_APP, "Exit App"},
|
||||
|
||||
{VIRTKEY_AXIS_RIGHT_Y_MAX, "RightAn.Up"},
|
||||
{VIRTKEY_AXIS_RIGHT_Y_MIN, "RightAn.Down"},
|
||||
{VIRTKEY_AXIS_RIGHT_X_MIN, "RightAn.Left"},
|
||||
{VIRTKEY_AXIS_RIGHT_X_MAX, "RightAn.Right"},
|
||||
|
||||
{CTRL_HOME, "Home"},
|
||||
{CTRL_HOLD, "Hold"},
|
||||
{CTRL_WLAN, "Wlan"},
|
||||
|
|
|
@ -275,13 +275,40 @@ void ControlMappingScreen::CreateViews() {
|
|||
root_->Add(rightScroll_);
|
||||
|
||||
std::vector<KeyMap::KeyMap_IntStrPair> mappableKeys = KeyMap::GetMappableKeys();
|
||||
|
||||
struct Cat {
|
||||
const char *catName;
|
||||
int firstKey;
|
||||
bool openByDefault;
|
||||
};
|
||||
// Category name, first input from psp_button_names.
|
||||
static const Cat cats[] = {
|
||||
{"Standard PSP controls", CTRL_UP, true},
|
||||
{"Control modifiers", VIRTKEY_ANALOG_ROTATE_CW, true},
|
||||
{"Emulator controls", VIRTKEY_FASTFORWARD, true},
|
||||
{"Extended PSP controls", VIRTKEY_AXIS_RIGHT_Y_MAX, false},
|
||||
};
|
||||
|
||||
int curCat = -1;
|
||||
CollapsibleSection *curSection = nullptr;
|
||||
for (size_t i = 0; i < mappableKeys.size(); i++) {
|
||||
SingleControlMapper *mapper = rightColumn->Add(
|
||||
if (curCat < (int)ARRAY_SIZE(cats) && mappableKeys[i].key == cats[curCat + 1].firstKey) {
|
||||
if (curCat >= 0 && !cats[curCat].openByDefault) {
|
||||
curSection->SetOpen(false);
|
||||
}
|
||||
curCat++;
|
||||
curSection = rightColumn->Add(new CollapsibleSection(km->T(cats[curCat].catName)));
|
||||
curSection->SetSpacing(6.0f);
|
||||
}
|
||||
SingleControlMapper *mapper = curSection->Add(
|
||||
new SingleControlMapper(mappableKeys[i].key, mappableKeys[i].name, screenManager(),
|
||||
new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
mapper->SetTag(StringFromFormat("KeyMap%s", mappableKeys[i].name));
|
||||
mappers_.push_back(mapper);
|
||||
}
|
||||
if (curCat >= 0 && curSection && !cats[curCat].openByDefault) {
|
||||
curSection->SetOpen(false);
|
||||
}
|
||||
|
||||
keyMapGeneration_ = KeyMap::g_controllerMapGeneration;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,10 @@ class SingleControlMapper;
|
|||
|
||||
class ControlMappingScreen : public UIDialogScreenWithGameBackground {
|
||||
public:
|
||||
explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
||||
explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
|
||||
categoryToggles_[0] = true;
|
||||
categoryToggles_[1] = true;
|
||||
}
|
||||
const char *tag() const override { return "ControlMapping"; }
|
||||
|
||||
protected:
|
||||
|
@ -51,6 +54,8 @@ private:
|
|||
UI::ScrollView *rightScroll_ = nullptr;
|
||||
std::vector<SingleControlMapper *> mappers_;
|
||||
int keyMapGeneration_ = -1;
|
||||
|
||||
bool categoryToggles_[10]{};
|
||||
};
|
||||
|
||||
class KeyMappingNewKeyDialog : public PopupScreen {
|
||||
|
|
Loading…
Add table
Reference in a new issue