mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-07-03 03:27:51 -05:00
inputCommon: Mouse fixes
This commit is contained in:
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user