mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-26 15:53:35 +01:00
UI: Track page up/down and home/end as focus moves.
Doesn't actually do anything yet when pressed.
This commit is contained in:
1 parent
9c49fba595
commit
fe949aafda
2 files changed
+25
-1
No files matched your search
+17
-1
@@ -195,11 +195,23 @@ static std::set<HeldKey> heldKeys;
|
||||
const double repeatDelay = 15 * (1.0 / 60.0f); // 15 frames like before.
|
||||
const double repeatInterval = 5 * (1.0 / 60.0f); // 5 frames like before.
|
||||
|
||||
bool IsScrollKey(const KeyInput &input) {
|
||||
switch (input.keyCode) {
|
||||
case NKCODE_PAGE_UP:
|
||||
case NKCODE_PAGE_DOWN:
|
||||
case NKCODE_MOVE_HOME:
|
||||
case NKCODE_MOVE_END:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool KeyEvent(const KeyInput &key, ViewGroup *root) {
|
||||
bool retval = false;
|
||||
// Ignore repeats for focus moves.
|
||||
if ((key.flags & (KEY_DOWN | KEY_IS_REPEAT)) == KEY_DOWN) {
|
||||
if (IsDPadKey(key)) {
|
||||
if (IsDPadKey(key) || IsScrollKey(key)) {
|
||||
// Let's only repeat DPAD initially.
|
||||
HeldKey hk;
|
||||
hk.key = key.keyCode;
|
||||
@@ -399,6 +411,10 @@ void UpdateViewHierarchy(ViewGroup *root) {
|
||||
case NKCODE_DPAD_RIGHT: MoveFocus(root, FOCUS_RIGHT); break;
|
||||
case NKCODE_DPAD_UP: MoveFocus(root, FOCUS_UP); break;
|
||||
case NKCODE_DPAD_DOWN: MoveFocus(root, FOCUS_DOWN); break;
|
||||
case NKCODE_PAGE_UP: MoveFocus(root, FOCUS_PREV_PAGE); break;
|
||||
case NKCODE_PAGE_DOWN: MoveFocus(root, FOCUS_NEXT_PAGE); break;
|
||||
case NKCODE_MOVE_HOME: MoveFocus(root, FOCUS_FIRST); break;
|
||||
case NKCODE_MOVE_END: MoveFocus(root, FOCUS_LAST); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +128,10 @@ enum FocusDirection {
|
||||
FOCUS_RIGHT,
|
||||
FOCUS_NEXT,
|
||||
FOCUS_PREV,
|
||||
FOCUS_FIRST,
|
||||
FOCUS_LAST,
|
||||
FOCUS_PREV_PAGE,
|
||||
FOCUS_NEXT_PAGE,
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -177,6 +181,10 @@ inline FocusDirection Opposite(FocusDirection d) {
|
||||
case FOCUS_RIGHT: return FOCUS_LEFT;
|
||||
case FOCUS_PREV: return FOCUS_NEXT;
|
||||
case FOCUS_NEXT: return FOCUS_PREV;
|
||||
case FOCUS_FIRST: return FOCUS_LAST;
|
||||
case FOCUS_LAST: return FOCUS_FIRST;
|
||||
case FOCUS_PREV_PAGE: return FOCUS_NEXT_PAGE;
|
||||
case FOCUS_NEXT_PAGE: return FOCUS_PREV_PAGE;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user