early-access version 2684

This commit is contained in:
pineappleEA 2022-04-18 14:36:15 +02:00
parent 163a08529f
commit 88d2038112
4 changed files with 44 additions and 4 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 2683. This is the source code for early-access 2684.
## Legal Notice ## Legal Notice

View File

@ -934,7 +934,8 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) {
const f32 res_scale = Settings::values.resolution_info.up_factor; const f32 res_scale = Settings::values.resolution_info.up_factor;
if (renderer.IsScreenshotPending()) { if (renderer.IsScreenshotPending()) {
LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request"); LOG_WARNING(Render,
"A screenshot is already requested or in progress, ignoring the request");
return; return;
} }

View File

@ -152,7 +152,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
} }
#endif #endif
constexpr int default_mouse_timeout = 2500; constexpr int default_mouse_hide_timeout = 2500;
constexpr int default_mouse_center_timeout = 10;
/** /**
* "Callouts" are one-time instructional messages shown to the user. In the config settings, there * "Callouts" are one-time instructional messages shown to the user. In the config settings, there
@ -287,10 +288,13 @@ GMainWindow::GMainWindow()
ui->menubar->setCursor(QCursor()); ui->menubar->setCursor(QCursor());
statusBar()->setCursor(QCursor()); statusBar()->setCursor(QCursor());
mouse_hide_timer.setInterval(default_mouse_timeout); mouse_hide_timer.setInterval(default_mouse_hide_timeout);
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
mouse_center_timer.setInterval(default_mouse_center_timeout);
connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
MigrateConfigFiles(); MigrateConfigFiles();
#if defined(HAVE_SDL2) && !defined(_WIN32) #if defined(HAVE_SDL2) && !defined(_WIN32)
@ -3301,10 +3305,26 @@ void GMainWindow::ShowMouseCursor() {
} }
} }
void GMainWindow::CenterMouseCursor() {
if (emu_thread == nullptr || !Settings::values.mouse_panning) {
mouse_center_timer.stop();
return;
}
if (!this->isActiveWindow()) {
mouse_center_timer.stop();
return;
}
const int center_x = render_window->width() / 2;
const int center_y = render_window->height() / 2;
QCursor::setPos(mapToGlobal({center_x, center_y}));
}
void GMainWindow::OnMouseActivity() { void GMainWindow::OnMouseActivity() {
if (!Settings::values.mouse_panning) { if (!Settings::values.mouse_panning) {
ShowMouseCursor(); ShowMouseCursor();
} }
mouse_center_timer.stop();
} }
void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) { void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) {
@ -3577,6 +3597,22 @@ void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
AcceptDropEvent(event); AcceptDropEvent(event);
} }
void GMainWindow::leaveEvent(QEvent* event) {
if (Settings::values.mouse_panning) {
const QRect& rect = geometry();
QPoint position = QCursor::pos();
qint32 x = qBound(rect.left(), position.x(), rect.right());
qint32 y = qBound(rect.top(), position.y(), rect.bottom());
// Only start the timer if the mouse has left the window bound.
// The leave event is also triggered when the window looses focus.
if (x != position.x() || y != position.y()) {
mouse_center_timer.start();
}
event->accept();
}
}
bool GMainWindow::ConfirmChangeGame() { bool GMainWindow::ConfirmChangeGame() {
if (emu_thread == nullptr) if (emu_thread == nullptr)
return true; return true;

View File

@ -328,6 +328,7 @@ private:
void UpdateUISettings(); void UpdateUISettings();
void HideMouseCursor(); void HideMouseCursor();
void ShowMouseCursor(); void ShowMouseCursor();
void CenterMouseCursor();
void OpenURL(const QUrl& url); void OpenURL(const QUrl& url);
void LoadTranslation(); void LoadTranslation();
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
@ -372,6 +373,7 @@ private:
bool auto_paused = false; bool auto_paused = false;
bool auto_muted = false; bool auto_muted = false;
QTimer mouse_hide_timer; QTimer mouse_hide_timer;
QTimer mouse_center_timer;
// FS // FS
std::shared_ptr<FileSys::VfsFilesystem> vfs; std::shared_ptr<FileSys::VfsFilesystem> vfs;
@ -418,4 +420,5 @@ protected:
void dropEvent(QDropEvent* event) override; void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override; void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override; void dragMoveEvent(QDragMoveEvent* event) override;
void leaveEvent(QEvent* event) override;
}; };