mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-10 18:07:57 -05:00
yuzu: Option to hide mouse on inactivity
Co-Authored-By: Vitor K <vitor-k@users.noreply.github.com>
This commit is contained in:
@ -135,6 +135,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
constexpr int default_mouse_timeout = 2500;
|
||||
|
||||
constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
|
||||
|
||||
/**
|
||||
@ -236,6 +238,14 @@ GMainWindow::GMainWindow()
|
||||
// Show one-time "callout" messages to the user
|
||||
ShowTelemetryCallout();
|
||||
|
||||
// make sure menubar has the arrow cursor instead of inheriting from this
|
||||
ui.menubar->setCursor(QCursor());
|
||||
statusBar()->setCursor(QCursor());
|
||||
|
||||
mouse_hide_timer.setInterval(default_mouse_timeout);
|
||||
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
|
||||
connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
|
||||
|
||||
QStringList args = QApplication::arguments();
|
||||
if (args.length() >= 2) {
|
||||
BootGame(args[1]);
|
||||
@ -1012,6 +1022,13 @@ void GMainWindow::BootGame(const QString& filename) {
|
||||
async_status_button->setDisabled(true);
|
||||
renderer_status_button->setDisabled(true);
|
||||
|
||||
if (UISettings::values.hide_mouse) {
|
||||
mouse_hide_timer.start();
|
||||
setMouseTracking(true);
|
||||
ui.centralwidget->setMouseTracking(true);
|
||||
ui.menubar->setMouseTracking(true);
|
||||
}
|
||||
|
||||
const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
|
||||
|
||||
std::string title_name;
|
||||
@ -1080,6 +1097,10 @@ void GMainWindow::ShutdownGame() {
|
||||
game_list->show();
|
||||
game_list->setFilterFocus();
|
||||
|
||||
setMouseTracking(false);
|
||||
ui.centralwidget->setMouseTracking(false);
|
||||
ui.menubar->setMouseTracking(false);
|
||||
|
||||
UpdateWindowTitle();
|
||||
|
||||
// Disable status bar updates
|
||||
@ -1835,6 +1856,17 @@ void GMainWindow::OnConfigure() {
|
||||
|
||||
config->Save();
|
||||
|
||||
if (UISettings::values.hide_mouse && emulation_running) {
|
||||
setMouseTracking(true);
|
||||
ui.centralwidget->setMouseTracking(true);
|
||||
ui.menubar->setMouseTracking(true);
|
||||
mouse_hide_timer.start();
|
||||
} else {
|
||||
setMouseTracking(false);
|
||||
ui.centralwidget->setMouseTracking(false);
|
||||
ui.menubar->setMouseTracking(false);
|
||||
}
|
||||
|
||||
dock_status_button->setChecked(Settings::values.use_docked_mode);
|
||||
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation);
|
||||
#ifdef HAS_VULKAN
|
||||
@ -1968,6 +2000,30 @@ void GMainWindow::UpdateStatusBar() {
|
||||
emu_frametime_label->setVisible(true);
|
||||
}
|
||||
|
||||
void GMainWindow::HideMouseCursor() {
|
||||
if (emu_thread == nullptr || UISettings::values.hide_mouse == false) {
|
||||
mouse_hide_timer.stop();
|
||||
ShowMouseCursor();
|
||||
return;
|
||||
}
|
||||
setCursor(QCursor(Qt::BlankCursor));
|
||||
}
|
||||
|
||||
void GMainWindow::ShowMouseCursor() {
|
||||
unsetCursor();
|
||||
if (emu_thread != nullptr && UISettings::values.hide_mouse) {
|
||||
mouse_hide_timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void GMainWindow::mouseMoveEvent(QMouseEvent* event) {
|
||||
ShowMouseCursor();
|
||||
}
|
||||
|
||||
void GMainWindow::mousePressEvent(QMouseEvent* event) {
|
||||
ShowMouseCursor();
|
||||
}
|
||||
|
||||
void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {
|
||||
QMessageBox::StandardButton answer;
|
||||
QString status_message;
|
||||
|
Reference in New Issue
Block a user