mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 01:29:41 +01:00
Move event queueing out of ScreenManager. This is a prerequisite for an upcoming change.
This commit is contained in:
1 parent
7219cd2f5a
commit
a47edbf6ef
3 files changed
+52
-65
No files matched your search
@@ -61,7 +61,7 @@ void ScreenManager::cancelScreensAbove(Screen *screen) {
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenManager::update() {
|
||||
void ScreenManager::update(const std::vector<QueuedEvent> &events) {
|
||||
if (cancelScreensAbove_) {
|
||||
bool found = false;
|
||||
for (int i = (int)stack_.size() - 1; i >= 0; i--) {
|
||||
@@ -84,14 +84,6 @@ void ScreenManager::update() {
|
||||
overlayScreen_->update();
|
||||
}
|
||||
|
||||
// Process queued events.
|
||||
std::deque<QueuedEvent> events;
|
||||
{
|
||||
std::lock_guard<std::mutex> eventGuard(eventQueueLock_);
|
||||
events = std::move(eventQueue_);
|
||||
eventQueue_.clear();
|
||||
}
|
||||
|
||||
for (const QueuedEvent &ev : events) {
|
||||
switch (ev.type) {
|
||||
case QueuedEventType::TOUCH:
|
||||
@@ -174,32 +166,6 @@ void ScreenManager::switchToNext() {
|
||||
nextStack_.clear();
|
||||
}
|
||||
|
||||
void ScreenManager::touch(const TouchInput &touch) {
|
||||
QueuedEvent ev{};
|
||||
ev.type = QueuedEventType::TOUCH;
|
||||
ev.touch = touch;
|
||||
std::lock_guard<std::mutex> guard(eventQueueLock_);
|
||||
eventQueue_.push_back(ev);
|
||||
}
|
||||
|
||||
void ScreenManager::key(const KeyInput &key) {
|
||||
QueuedEvent ev{};
|
||||
ev.type = QueuedEventType::KEY;
|
||||
ev.key = key;
|
||||
std::lock_guard<std::mutex> guard(eventQueueLock_);
|
||||
eventQueue_.push_back(ev);
|
||||
}
|
||||
|
||||
void ScreenManager::axis(const AxisInput *axes, size_t count) {
|
||||
QueuedEvent ev{};
|
||||
ev.type = QueuedEventType::AXIS;
|
||||
std::lock_guard<std::mutex> guard(eventQueueLock_);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
ev.axis = axes[i];
|
||||
eventQueue_.push_back(ev);
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenManager::deviceLost() {
|
||||
for (auto &iter : stack_)
|
||||
iter.screen->deviceLost();
|
||||
@@ -331,16 +297,7 @@ void ScreenManager::getFocusPosition(float &x, float &y, float &z) {
|
||||
void ScreenManager::sendMessage(UIMessage message, const char *value) {
|
||||
if (message == UIMessage::RECREATE_VIEWS) {
|
||||
RecreateAllViews();
|
||||
} else if (message == UIMessage::LOST_FOCUS) {
|
||||
TouchInput input{};
|
||||
input.x = -50000.0f;
|
||||
input.y = -50000.0f;
|
||||
input.flags = TouchInputFlags::RELEASE_ALL;
|
||||
input.timestamp = time_now_d();
|
||||
input.id = 0;
|
||||
touch(input);
|
||||
}
|
||||
|
||||
if (backgroundScreen_) {
|
||||
backgroundScreen_->sendMessage(message, value);
|
||||
}
|
||||
@@ -380,13 +337,6 @@ void ScreenManager::push(Screen *screen, int layerFlags) {
|
||||
|
||||
// Release touches and unfocus.
|
||||
UI::SetFocusedView(nullptr, UI::FocusFlags::CAUSE_SCREEN_CHANGE);
|
||||
TouchInput input{};
|
||||
input.x = -50000.0f;
|
||||
input.y = -50000.0f;
|
||||
input.flags = TouchInputFlags::RELEASE_ALL;
|
||||
input.timestamp = time_now_d();
|
||||
input.id = 0;
|
||||
touch(input);
|
||||
|
||||
Layer layer = {screen, layerFlags};
|
||||
|
||||
|
||||
Reference in new issue
Block a user