summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input_common/helpers/udp_protocol.h9
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp20
-rw-r--r--src/yuzu/main.cpp40
-rw-r--r--src/yuzu/main.h3
4 files changed, 69 insertions, 3 deletions
diff --git a/src/input_common/helpers/udp_protocol.h b/src/input_common/helpers/udp_protocol.h
index 9c205e944..597f51cd3 100644
--- a/src/input_common/helpers/udp_protocol.h
+++ b/src/input_common/helpers/udp_protocol.h
@@ -8,8 +8,17 @@
8#include <optional> 8#include <optional>
9#include <type_traits> 9#include <type_traits>
10 10
11#ifdef _MSC_VER
12#pragma warning(push)
13#pragma warning(disable : 4701) // Potentially uninitialized local variable 'result' used
14#endif
15
11#include <boost/crc.hpp> 16#include <boost/crc.hpp>
12 17
18#ifdef _MSC_VER
19#pragma warning(pop)
20#endif
21
13#include "common/swap.h" 22#include "common/swap.h"
14 23
15namespace InputCommon::CemuhookUDP { 24namespace InputCommon::CemuhookUDP {
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 291e37acf..a0f29d147 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -10,6 +10,7 @@
10#include <QMenu> 10#include <QMenu>
11#include <QMessageBox> 11#include <QMessageBox>
12#include <QTimer> 12#include <QTimer>
13#include "common/assert.h"
13#include "common/param_package.h" 14#include "common/param_package.h"
14#include "core/hid/emulated_controller.h" 15#include "core/hid/emulated_controller.h"
15#include "core/hid/hid_core.h" 16#include "core/hid/hid_core.h"
@@ -119,6 +120,23 @@ QString GetButtonName(Common::Input::ButtonNames button_name) {
119 } 120 }
120} 121}
121 122
123QString GetDirectionName(const std::string& direction) {
124 if (direction == "left") {
125 return QObject::tr("Left");
126 }
127 if (direction == "right") {
128 return QObject::tr("Right");
129 }
130 if (direction == "up") {
131 return QObject::tr("Up");
132 }
133 if (direction == "down") {
134 return QObject::tr("Down");
135 }
136 UNIMPLEMENTED_MSG("Unimplemented direction name={}", direction);
137 return QString::fromStdString(direction);
138}
139
122void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param, 140void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param,
123 const std::string& button_name) { 141 const std::string& button_name) {
124 // The poller returned a complete axis, so set all the buttons 142 // The poller returned a complete axis, so set all the buttons
@@ -162,7 +180,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
162 180
163 if (common_button_name == Common::Input::ButtonNames::Value) { 181 if (common_button_name == Common::Input::ButtonNames::Value) {
164 if (param.Has("hat")) { 182 if (param.Has("hat")) {
165 const QString hat = QString::fromStdString(param.Get("direction", "")); 183 const QString hat = GetDirectionName(param.Get("direction", ""));
166 return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat); 184 return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat);
167 } 185 }
168 if (param.Has("axis")) { 186 if (param.Has("axis")) {
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 52879a989..5e26aad29 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -152,7 +152,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
152} 152}
153#endif 153#endif
154 154
155constexpr int default_mouse_timeout = 2500; 155constexpr int default_mouse_hide_timeout = 2500;
156constexpr int default_mouse_center_timeout = 10;
156 157
157/** 158/**
158 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there 159 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there
@@ -287,10 +288,13 @@ GMainWindow::GMainWindow()
287 ui->menubar->setCursor(QCursor()); 288 ui->menubar->setCursor(QCursor());
288 statusBar()->setCursor(QCursor()); 289 statusBar()->setCursor(QCursor());
289 290
290 mouse_hide_timer.setInterval(default_mouse_timeout); 291 mouse_hide_timer.setInterval(default_mouse_hide_timeout);
291 connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); 292 connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
292 connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); 293 connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
293 294
295 mouse_center_timer.setInterval(default_mouse_center_timeout);
296 connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
297
294 MigrateConfigFiles(); 298 MigrateConfigFiles();
295 299
296#if defined(HAVE_SDL2) && !defined(_WIN32) 300#if defined(HAVE_SDL2) && !defined(_WIN32)
@@ -3301,10 +3305,26 @@ void GMainWindow::ShowMouseCursor() {
3301 } 3305 }
3302} 3306}
3303 3307
3308void GMainWindow::CenterMouseCursor() {
3309 if (emu_thread == nullptr || !Settings::values.mouse_panning) {
3310 mouse_center_timer.stop();
3311 return;
3312 }
3313 if (!this->isActiveWindow()) {
3314 mouse_center_timer.stop();
3315 return;
3316 }
3317 const int center_x = render_window->width() / 2;
3318 const int center_y = render_window->height() / 2;
3319
3320 QCursor::setPos(mapToGlobal({center_x, center_y}));
3321}
3322
3304void GMainWindow::OnMouseActivity() { 3323void GMainWindow::OnMouseActivity() {
3305 if (!Settings::values.mouse_panning) { 3324 if (!Settings::values.mouse_panning) {
3306 ShowMouseCursor(); 3325 ShowMouseCursor();
3307 } 3326 }
3327 mouse_center_timer.stop();
3308} 3328}
3309 3329
3310void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) { 3330void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) {
@@ -3577,6 +3597,22 @@ void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
3577 AcceptDropEvent(event); 3597 AcceptDropEvent(event);
3578} 3598}
3579 3599
3600void GMainWindow::leaveEvent(QEvent* event) {
3601 if (Settings::values.mouse_panning) {
3602 const QRect& rect = geometry();
3603 QPoint position = QCursor::pos();
3604
3605 qint32 x = qBound(rect.left(), position.x(), rect.right());
3606 qint32 y = qBound(rect.top(), position.y(), rect.bottom());
3607 // Only start the timer if the mouse has left the window bound.
3608 // The leave event is also triggered when the window looses focus.
3609 if (x != position.x() || y != position.y()) {
3610 mouse_center_timer.start();
3611 }
3612 event->accept();
3613 }
3614}
3615
3580bool GMainWindow::ConfirmChangeGame() { 3616bool GMainWindow::ConfirmChangeGame() {
3581 if (emu_thread == nullptr) 3617 if (emu_thread == nullptr)
3582 return true; 3618 return true;
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index ab95a7518..b399e9b01 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -328,6 +328,7 @@ private:
328 void UpdateUISettings(); 328 void UpdateUISettings();
329 void HideMouseCursor(); 329 void HideMouseCursor();
330 void ShowMouseCursor(); 330 void ShowMouseCursor();
331 void CenterMouseCursor();
331 void OpenURL(const QUrl& url); 332 void OpenURL(const QUrl& url);
332 void LoadTranslation(); 333 void LoadTranslation();
333 void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); 334 void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
@@ -372,6 +373,7 @@ private:
372 bool auto_paused = false; 373 bool auto_paused = false;
373 bool auto_muted = false; 374 bool auto_muted = false;
374 QTimer mouse_hide_timer; 375 QTimer mouse_hide_timer;
376 QTimer mouse_center_timer;
375 377
376 // FS 378 // FS
377 std::shared_ptr<FileSys::VfsFilesystem> vfs; 379 std::shared_ptr<FileSys::VfsFilesystem> vfs;
@@ -418,4 +420,5 @@ protected:
418 void dropEvent(QDropEvent* event) override; 420 void dropEvent(QDropEvent* event) override;
419 void dragEnterEvent(QDragEnterEvent* event) override; 421 void dragEnterEvent(QDragEnterEvent* event) override;
420 void dragMoveEvent(QDragMoveEvent* event) override; 422 void dragMoveEvent(QDragMoveEvent* event) override;
423 void leaveEvent(QEvent* event) override;
421}; 424};