diff options
| -rw-r--r-- | src/yuzu/applets/web_browser.cpp | 19 | ||||
| -rw-r--r-- | src/yuzu/applets/web_browser.h | 13 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 2 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/yuzu/applets/web_browser.cpp b/src/yuzu/applets/web_browser.cpp index 52c99d1ba..7e2dc6ee9 100644 --- a/src/yuzu/applets/web_browser.cpp +++ b/src/yuzu/applets/web_browser.cpp | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | #include "common/file_util.h" | 15 | #include "common/file_util.h" |
| 16 | #include "core/core.h" | 16 | #include "core/core.h" |
| 17 | #include "core/frontend/input_interpreter.h" | 17 | #include "core/frontend/input_interpreter.h" |
| 18 | #include "input_common/keyboard.h" | ||
| 19 | #include "input_common/main.h" | ||
| 18 | #include "yuzu/applets/web_browser.h" | 20 | #include "yuzu/applets/web_browser.h" |
| 19 | #include "yuzu/applets/web_browser_scripts.h" | 21 | #include "yuzu/applets/web_browser_scripts.h" |
| 20 | #include "yuzu/main.h" | 22 | #include "yuzu/main.h" |
| @@ -45,8 +47,10 @@ constexpr int HIDButtonToKey(HIDButton button) { | |||
| 45 | 47 | ||
| 46 | } // Anonymous namespace | 48 | } // Anonymous namespace |
| 47 | 49 | ||
| 48 | QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system) | 50 | QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system, |
| 49 | : QWebEngineView(parent), url_interceptor(std::make_unique<UrlRequestInterceptor>()), | 51 | InputCommon::InputSubsystem* input_subsystem_) |
| 52 | : QWebEngineView(parent), input_subsystem{input_subsystem_}, | ||
| 53 | url_interceptor(std::make_unique<UrlRequestInterceptor>()), | ||
| 50 | input_interpreter(std::make_unique<InputInterpreter>(system)) { | 54 | input_interpreter(std::make_unique<InputInterpreter>(system)) { |
| 51 | QWebEngineScript nx_font_css; | 55 | QWebEngineScript nx_font_css; |
| 52 | QWebEngineScript load_nx_font; | 56 | QWebEngineScript load_nx_font; |
| @@ -203,6 +207,14 @@ void QtNXWebEngineView::hide() { | |||
| 203 | QWidget::hide(); | 207 | QWidget::hide(); |
| 204 | } | 208 | } |
| 205 | 209 | ||
| 210 | void QtNXWebEngineView::keyPressEvent(QKeyEvent* event) { | ||
| 211 | input_subsystem->GetKeyboard()->PressKey(event->key()); | ||
| 212 | } | ||
| 213 | |||
| 214 | void QtNXWebEngineView::keyReleaseEvent(QKeyEvent* event) { | ||
| 215 | input_subsystem->GetKeyboard()->ReleaseKey(event->key()); | ||
| 216 | } | ||
| 217 | |||
| 206 | template <HIDButton... T> | 218 | template <HIDButton... T> |
| 207 | void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() { | 219 | void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() { |
| 208 | const auto f = [this](HIDButton button) { | 220 | const auto f = [this](HIDButton button) { |
| @@ -282,6 +294,7 @@ void QtNXWebEngineView::StartInputThread() { | |||
| 282 | } | 294 | } |
| 283 | 295 | ||
| 284 | void QtNXWebEngineView::StopInputThread() { | 296 | void QtNXWebEngineView::StopInputThread() { |
| 297 | QWidget::releaseKeyboard(); | ||
| 285 | input_thread_running = false; | 298 | input_thread_running = false; |
| 286 | if (input_thread.joinable()) { | 299 | if (input_thread.joinable()) { |
| 287 | input_thread.join(); | 300 | input_thread.join(); |
| @@ -292,6 +305,8 @@ void QtNXWebEngineView::InputThread() { | |||
| 292 | // Wait for 1 second before allowing any inputs to be processed. | 305 | // Wait for 1 second before allowing any inputs to be processed. |
| 293 | std::this_thread::sleep_for(std::chrono::seconds(1)); | 306 | std::this_thread::sleep_for(std::chrono::seconds(1)); |
| 294 | 307 | ||
| 308 | QWidget::grabKeyboard(); | ||
| 309 | |||
| 295 | while (input_thread_running) { | 310 | while (input_thread_running) { |
| 296 | input_interpreter->PollInput(); | 311 | input_interpreter->PollInput(); |
| 297 | 312 | ||
diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index 18b8640a7..cfddaa6f8 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h | |||
| @@ -26,6 +26,10 @@ namespace Core { | |||
| 26 | class System; | 26 | class System; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | namespace InputCommon { | ||
| 30 | class InputSubsystem; | ||
| 31 | } | ||
| 32 | |||
| 29 | #ifdef YUZU_USE_QT_WEB_ENGINE | 33 | #ifdef YUZU_USE_QT_WEB_ENGINE |
| 30 | 34 | ||
| 31 | enum class UserAgent { | 35 | enum class UserAgent { |
| @@ -41,7 +45,8 @@ class QtNXWebEngineView : public QWebEngineView { | |||
| 41 | Q_OBJECT | 45 | Q_OBJECT |
| 42 | 46 | ||
| 43 | public: | 47 | public: |
| 44 | explicit QtNXWebEngineView(QWidget* parent, Core::System& system); | 48 | explicit QtNXWebEngineView(QWidget* parent, Core::System& system, |
| 49 | InputCommon::InputSubsystem* input_subsystem_); | ||
| 45 | ~QtNXWebEngineView() override; | 50 | ~QtNXWebEngineView() override; |
| 46 | 51 | ||
| 47 | /** | 52 | /** |
| @@ -86,6 +91,10 @@ public: | |||
| 86 | public slots: | 91 | public slots: |
| 87 | void hide(); | 92 | void hide(); |
| 88 | 93 | ||
| 94 | protected: | ||
| 95 | void keyPressEvent(QKeyEvent* event) override; | ||
| 96 | void keyReleaseEvent(QKeyEvent* event) override; | ||
| 97 | |||
| 89 | private: | 98 | private: |
| 90 | /** | 99 | /** |
| 91 | * Handles button presses to execute functions assigned in yuzu_key_callbacks. | 100 | * Handles button presses to execute functions assigned in yuzu_key_callbacks. |
| @@ -138,6 +147,8 @@ private: | |||
| 138 | /// The thread where input is being polled and processed. | 147 | /// The thread where input is being polled and processed. |
| 139 | void InputThread(); | 148 | void InputThread(); |
| 140 | 149 | ||
| 150 | InputCommon::InputSubsystem* input_subsystem; | ||
| 151 | |||
| 141 | std::unique_ptr<UrlRequestInterceptor> url_interceptor; | 152 | std::unique_ptr<UrlRequestInterceptor> url_interceptor; |
| 142 | 153 | ||
| 143 | std::unique_ptr<InputInterpreter> input_interpreter; | 154 | std::unique_ptr<InputInterpreter> input_interpreter; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index ccff08074..f835ee9cb 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -376,7 +376,7 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url, | |||
| 376 | return; | 376 | return; |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | QtNXWebEngineView web_browser_view(this, Core::System::GetInstance()); | 379 | QtNXWebEngineView web_browser_view(this, Core::System::GetInstance(), input_subsystem.get()); |
| 380 | 380 | ||
| 381 | ui.action_Pause->setEnabled(false); | 381 | ui.action_Pause->setEnabled(false); |
| 382 | ui.action_Restart->setEnabled(false); | 382 | ui.action_Restart->setEnabled(false); |