diff options
author | german77 <juangerman-13@hotmail.com> | 2021-02-24 03:39:02 +0100 |
---|---|---|
committer | german <german@thesoftwareartisans.com> | 2021-02-28 00:53:10 +0100 |
commit | 4738e14cb052a44c53e47379e595f00cef034dca (patch) | |
tree | 4264dd4e9d4a750951d1581241c484513c89b571 /src/yuzu | |
parent | Merge pull request #5944 from Morph1984/gc-vibrations (diff) | |
download | yuzu-4738e14cb052a44c53e47379e595f00cef034dca.tar yuzu-4738e14cb052a44c53e47379e595f00cef034dca.tar.gz yuzu-4738e14cb052a44c53e47379e595f00cef034dca.tar.bz2 yuzu-4738e14cb052a44c53e47379e595f00cef034dca.tar.lz yuzu-4738e14cb052a44c53e47379e595f00cef034dca.tar.xz yuzu-4738e14cb052a44c53e47379e595f00cef034dca.tar.zst yuzu-4738e14cb052a44c53e47379e595f00cef034dca.zip |
Diffstat (limited to 'src/yuzu')
-rw-r--r-- | src/yuzu/bootmanager.cpp | 25 | ||||
-rw-r--r-- | src/yuzu/bootmanager.h | 7 | ||||
-rw-r--r-- | src/yuzu/configuration/config.cpp | 5 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 4 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 19 |
5 files changed, 46 insertions, 14 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1c61d419d..ae49cbb45 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -383,6 +383,25 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { input_subsystem->GetKeyboard()->ReleaseKey(event->key()); } +MouseInput::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { + switch (button) { + case Qt::LeftButton: + return MouseInput::MouseButton::Left; + case Qt::RightButton: + return MouseInput::MouseButton::Right; + case Qt::MiddleButton: + return MouseInput::MouseButton::Wheel; + case Qt::BackButton: + return MouseInput::MouseButton::Backward; + case Qt::ForwardButton: + return MouseInput::MouseButton::Forward; + case Qt::TaskButton: + return MouseInput::MouseButton::Task; + default: + return MouseInput::MouseButton::Extra; + } +} + void GRenderWindow::mousePressEvent(QMouseEvent* event) { // Touch input is handled in TouchBeginEvent if (event->source() == Qt::MouseEventSynthesizedBySystem) { @@ -391,7 +410,8 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { auto pos = event->pos(); const auto [x, y] = ScaleTouch(pos); - input_subsystem->GetMouse()->PressButton(x, y, event->button()); + const auto button = QtButtonToMouseButton(event->button()); + input_subsystem->GetMouse()->PressButton(x, y, button); if (event->button() == Qt::LeftButton) { this->TouchPressed(x, y, 0); @@ -425,7 +445,8 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { return; } - input_subsystem->GetMouse()->ReleaseButton(event->button()); + const auto button = QtButtonToMouseButton(event->button()); + input_subsystem->GetMouse()->ReleaseButton(button); if (event->button() == Qt::LeftButton) { this->TouchReleased(0); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index b5ec7de07..acfe2bc8c 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -28,6 +28,10 @@ namespace InputCommon { class InputSubsystem; } +namespace MouseInput { +enum class MouseButton; +} + namespace VideoCore { enum class LoadCallbackStage; } @@ -149,6 +153,9 @@ public: void keyPressEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override; + /// Converts a Qt mouse button into MouseInput mouse button + static MouseInput::MouseButton QtButtonToMouseButton(Qt::MouseButton button); + void mousePressEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 3d6f64300..e6537d295 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -235,7 +235,7 @@ const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{ {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, - {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("F9"), Qt::ApplicationShortcut}}, + {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, }}; @@ -508,7 +508,7 @@ void Config::ReadControlValues() { Settings::values.emulate_analog_keyboard = ReadSetting(QStringLiteral("emulate_analog_keyboard"), false).toBool(); - Settings::values.mouse_panning = ReadSetting(QStringLiteral("mouse_panning"), false).toBool(); + Settings::values.mouse_panning = false; Settings::values.mouse_panning_sensitivity = ReadSetting(QStringLiteral("mouse_panning_sensitivity"), 1).toFloat(); @@ -1182,7 +1182,6 @@ void Config::SaveControlValues() { WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false); WriteSetting(QStringLiteral("emulate_analog_keyboard"), Settings::values.emulate_analog_keyboard, false); - WriteSetting(QStringLiteral("mouse_panning"), Settings::values.mouse_panning, false); WriteSetting(QStringLiteral("mouse_panning_sensitivity"), Settings::values.mouse_panning_sensitivity, 1.0f); qt_config->endGroup(); diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 21d0d3449..bc572d319 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -21,6 +21,7 @@ #include "input_common/mouse/mouse_poller.h" #include "input_common/udp/udp.h" #include "ui_configure_input_player.h" +#include "yuzu/bootmanager.h" #include "yuzu/configuration/config.h" #include "yuzu/configuration/configure_input_player.h" #include "yuzu/configuration/configure_input_player_widget.h" @@ -1345,7 +1346,8 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) { return; } - input_subsystem->GetMouse()->PressButton(0, 0, event->button()); + const auto button = GRenderWindow::QtButtonToMouseButton(event->button()); + input_subsystem->GetMouse()->PressButton(0, 0, button); } void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 0ba7c07cc..56d892a31 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -854,8 +854,7 @@ void GMainWindow::InitializeHotkeys() { connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Mouse Panning"), this), &QShortcut::activated, this, [&] { Settings::values.mouse_panning = !Settings::values.mouse_panning; - if (UISettings::values.hide_mouse || Settings::values.mouse_panning) { - mouse_hide_timer.start(); + if (Settings::values.mouse_panning) { render_window->installEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, true); } @@ -1208,11 +1207,14 @@ void GMainWindow::BootGame(const QString& filename, std::size_t program_index) { renderer_status_button->setDisabled(true); if (UISettings::values.hide_mouse || Settings::values.mouse_panning) { - mouse_hide_timer.start(); render_window->installEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, true); } + if (UISettings::values.hide_mouse) { + mouse_hide_timer.start(); + } + std::string title_name; std::string title_version; const auto res = system.GetGameName(title_name); @@ -2372,12 +2374,15 @@ void GMainWindow::OnConfigure() { if ((UISettings::values.hide_mouse || Settings::values.mouse_panning) && emulation_running) { render_window->installEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, true); - mouse_hide_timer.start(); } else { render_window->removeEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, false); } + if (UISettings::values.hide_mouse) { + mouse_hide_timer.start(); + } + UpdateStatusButtons(); } @@ -2615,8 +2620,7 @@ void GMainWindow::UpdateUISettings() { } void GMainWindow::HideMouseCursor() { - if (emu_thread == nullptr || - (!UISettings::values.hide_mouse && !Settings::values.mouse_panning)) { + if (emu_thread == nullptr && UISettings::values.hide_mouse) { mouse_hide_timer.stop(); ShowMouseCursor(); return; @@ -2626,8 +2630,7 @@ void GMainWindow::HideMouseCursor() { void GMainWindow::ShowMouseCursor() { render_window->unsetCursor(); - if (emu_thread != nullptr && - (UISettings::values.hide_mouse || Settings::values.mouse_panning)) { + if (emu_thread != nullptr && UISettings::values.hide_mouse) { mouse_hide_timer.start(); } } |