Update main.cpp
This commit is contained in:
+32
-2
@@ -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,29 @@ void GMainWindow::ShowMouseCursor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::CenterMouseCursor() {
|
||||||
|
static bool logged = false;
|
||||||
|
if (emu_thread == nullptr || !Settings::values.mouse_panning) {
|
||||||
|
mouse_center_timer.stop();
|
||||||
|
logged = false;
|
||||||
|
LOG_INFO(Debug, "Stopped centering cursor!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!logged) {
|
||||||
|
LOG_INFO(Debug, "Started centering cursor!");
|
||||||
|
logged = true;
|
||||||
|
}
|
||||||
|
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 +3600,13 @@ void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
|
|||||||
AcceptDropEvent(event);
|
AcceptDropEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::leaveEvent(QEvent* event) {
|
||||||
|
if (Settings::values.mouse_panning) {
|
||||||
|
mouse_center_timer.start();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GMainWindow::ConfirmChangeGame() {
|
bool GMainWindow::ConfirmChangeGame() {
|
||||||
if (emu_thread == nullptr)
|
if (emu_thread == nullptr)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user