mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Simplify away some nonsense
This commit is contained in:
@@ -183,18 +183,16 @@ void ScreenManager::touch(const TouchInput &touch) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ScreenManager::key(const KeyInput &key) {
|
||||
void ScreenManager::key(const KeyInput &key) {
|
||||
std::lock_guard<std::recursive_mutex> guard(inputLock_);
|
||||
bool result = false;
|
||||
// Send key up to every screen layer, to avoid stuck keys.
|
||||
if (key.flags & KeyInputFlags::UP) {
|
||||
for (auto &layer : stack_) {
|
||||
result = layer.screen->UnsyncKey(key);
|
||||
layer.screen->UnsyncKey(key);
|
||||
}
|
||||
} else if (!stack_.empty()) {
|
||||
result = stack_.back().screen->UnsyncKey(key);
|
||||
stack_.back().screen->UnsyncKey(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ScreenManager::axis(const AxisInput *axes, size_t count) {
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ public:
|
||||
// Return value of UnsyncTouch is only used to let the overlay screen block touches.
|
||||
virtual bool UnsyncTouch(const TouchInput &touch) = 0;
|
||||
// Return value of UnsyncKey is used to not block certain system keys like volume when unhandled, on Android.
|
||||
virtual bool UnsyncKey(const KeyInput &touch) = 0;
|
||||
virtual void UnsyncKey(const KeyInput &touch) = 0;
|
||||
virtual void UnsyncAxis(const AxisInput *axes, size_t count) = 0;
|
||||
|
||||
virtual void RecreateViews() {}
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
|
||||
// Instant touch, separate from the update() mechanism.
|
||||
void touch(const TouchInput &touch);
|
||||
bool key(const KeyInput &key);
|
||||
void key(const KeyInput &key);
|
||||
void axis(const AxisInput *axes, size_t count);
|
||||
|
||||
void sendMessage(UIMessage message, const char *value);
|
||||
|
||||
+1
-36
@@ -114,47 +114,12 @@ void UIScreen::UnsyncAxis(const AxisInput *axes, size_t count) {
|
||||
}
|
||||
}
|
||||
|
||||
bool UIScreen::UnsyncKey(const KeyInput &key) {
|
||||
bool retval = false;
|
||||
using namespace UI;
|
||||
|
||||
// Ignore volume keys and stuff here. Not elegant but need to propagate bools through the view hierarchy as well...
|
||||
switch (key.keyCode) {
|
||||
case NKCODE_VOLUME_DOWN:
|
||||
case NKCODE_VOLUME_UP:
|
||||
case NKCODE_VOLUME_MUTE:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (root_) {
|
||||
KeyEventResult kev = KeyEventToFocusMoves(key);
|
||||
if (!(key.flags & KeyInputFlags::IS_REPEAT)) {
|
||||
// If a repeat, we follow what KeyEventToFocusMoves set it to.
|
||||
// Otherwise we signal that we used the key, always.
|
||||
kev = KeyEventResult::ACCEPT;
|
||||
}
|
||||
|
||||
switch (kev) {
|
||||
case UI::KeyEventResult::ACCEPT:
|
||||
retval = true;
|
||||
break;
|
||||
case UI::KeyEventResult::PASS_THROUGH:
|
||||
retval = false;
|
||||
break;
|
||||
case UI::KeyEventResult::IGNORE_KEY:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void UIScreen::UnsyncKey(const KeyInput &key) {
|
||||
QueuedEvent ev{};
|
||||
ev.type = QueuedEventType::KEY;
|
||||
ev.key = key;
|
||||
|
||||
std::lock_guard<std::mutex> guard(eventQueueLock_);
|
||||
eventQueue_.push_back(ev);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void UIScreen::update() {
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
virtual void axis(const AxisInput &axis);
|
||||
|
||||
bool UnsyncTouch(const TouchInput &touch) override;
|
||||
bool UnsyncKey(const KeyInput &key) override;
|
||||
void UnsyncKey(const KeyInput &key) override;
|
||||
void UnsyncAxis(const AxisInput *axes, size_t count) override;
|
||||
|
||||
TouchInput transformTouch(const TouchInput &touch) override;
|
||||
|
||||
+31
-1
@@ -1526,8 +1526,38 @@ bool NativeKey(const KeyInput &key) {
|
||||
KeyInput modKey = key;
|
||||
modKey.flags |= modifierFlags;
|
||||
|
||||
// Ignore volume keys and stuff here. Not elegant but need to propagate bools through the view hierarchy as well...
|
||||
switch (key.keyCode) {
|
||||
case NKCODE_VOLUME_DOWN:
|
||||
case NKCODE_VOLUME_UP:
|
||||
case NKCODE_VOLUME_MUTE:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bool retval = false;
|
||||
|
||||
UI::KeyEventResult kev = UI::KeyEventToFocusMoves(key);
|
||||
if (!(key.flags & KeyInputFlags::IS_REPEAT)) {
|
||||
// If a repeat, we follow what KeyEventToFocusMoves set it to.
|
||||
// Otherwise we signal that we used the key, always.
|
||||
kev = UI::KeyEventResult::ACCEPT;
|
||||
}
|
||||
|
||||
switch (kev) {
|
||||
case UI::KeyEventResult::ACCEPT:
|
||||
retval = true;
|
||||
break;
|
||||
case UI::KeyEventResult::PASS_THROUGH:
|
||||
retval = false;
|
||||
break;
|
||||
case UI::KeyEventResult::IGNORE_KEY:
|
||||
return false;
|
||||
}
|
||||
|
||||
// Dispatch the key event.
|
||||
bool retval = g_screenManager->key(modKey);
|
||||
g_screenManager->key(modKey);
|
||||
|
||||
// The Mode key can have weird consequences on some devices, see #17245.
|
||||
if (key.keyCode == NKCODE_BUTTON_MODE) {
|
||||
|
||||
Reference in New Issue
Block a user