diff options
| -rw-r--r-- | src/yuzu/applets/qt_controller.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_web_browser.cpp | 65 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_web_browser.h | 12 |
3 files changed, 44 insertions, 36 deletions
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index 32cb5b5ff..59289c6a5 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp | |||
| @@ -28,7 +28,8 @@ namespace { | |||
| 28 | 28 | ||
| 29 | constexpr std::size_t HANDHELD_INDEX = 8; | 29 | constexpr std::size_t HANDHELD_INDEX = 8; |
| 30 | 30 | ||
| 31 | void UpdateController(Core::HID::EmulatedController* controller, Core::HID::NpadType controller_type, bool connected) { | 31 | void UpdateController(Core::HID::EmulatedController* controller, |
| 32 | Core::HID::NpadType controller_type, bool connected) { | ||
| 32 | if (controller->IsConnected()) { | 33 | if (controller->IsConnected()) { |
| 33 | controller->Disconnect(); | 34 | controller->Disconnect(); |
| 34 | } | 35 | } |
diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index 8e190f9fe..cb3c5d826 100644 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "common/fs/path_util.h" | 16 | #include "common/fs/path_util.h" |
| 17 | #include "common/param_package.h" | 17 | #include "common/param_package.h" |
| 18 | #include "core/core.h" | 18 | #include "core/core.h" |
| 19 | #include "core/hid/hid_types.h" | ||
| 19 | #include "core/hid/input_interpreter.h" | 20 | #include "core/hid/input_interpreter.h" |
| 20 | #include "input_common/drivers/keyboard.h" | 21 | #include "input_common/drivers/keyboard.h" |
| 21 | #include "input_common/main.h" | 22 | #include "input_common/main.h" |
| @@ -28,19 +29,19 @@ | |||
| 28 | 29 | ||
| 29 | namespace { | 30 | namespace { |
| 30 | 31 | ||
| 31 | constexpr int HIDButtonToKey(HIDButton button) { | 32 | constexpr int HIDButtonToKey(Core::HID::NpadButton button) { |
| 32 | switch (button) { | 33 | switch (button) { |
| 33 | case HIDButton::DLeft: | 34 | case Core::HID::NpadButton::Left: |
| 34 | case HIDButton::LStickLeft: | 35 | case Core::HID::NpadButton::StickLLeft: |
| 35 | return Qt::Key_Left; | 36 | return Qt::Key_Left; |
| 36 | case HIDButton::DUp: | 37 | case Core::HID::NpadButton::Up: |
| 37 | case HIDButton::LStickUp: | 38 | case Core::HID::NpadButton::StickLUp: |
| 38 | return Qt::Key_Up; | 39 | return Qt::Key_Up; |
| 39 | case HIDButton::DRight: | 40 | case Core::HID::NpadButton::Right: |
| 40 | case HIDButton::LStickRight: | 41 | case Core::HID::NpadButton::StickLRight: |
| 41 | return Qt::Key_Right; | 42 | return Qt::Key_Right; |
| 42 | case HIDButton::DDown: | 43 | case Core::HID::NpadButton::Down: |
| 43 | case HIDButton::LStickDown: | 44 | case Core::HID::NpadButton::StickLDown: |
| 44 | return Qt::Key_Down; | 45 | return Qt::Key_Down; |
| 45 | default: | 46 | default: |
| 46 | return 0; | 47 | return 0; |
| @@ -209,25 +210,25 @@ void QtNXWebEngineView::keyReleaseEvent(QKeyEvent* event) { | |||
| 209 | } | 210 | } |
| 210 | } | 211 | } |
| 211 | 212 | ||
| 212 | template <HIDButton... T> | 213 | template <Core::HID::NpadButton... T> |
| 213 | void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() { | 214 | void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() { |
| 214 | const auto f = [this](HIDButton button) { | 215 | const auto f = [this](Core::HID::NpadButton button) { |
| 215 | if (input_interpreter->IsButtonPressedOnce(button)) { | 216 | if (input_interpreter->IsButtonPressedOnce(button)) { |
| 216 | page()->runJavaScript( | 217 | page()->runJavaScript( |
| 217 | QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)), | 218 | QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)), |
| 218 | [this, button](const QVariant& variant) { | 219 | [this, button](const QVariant& variant) { |
| 219 | if (variant.toBool()) { | 220 | if (variant.toBool()) { |
| 220 | switch (button) { | 221 | switch (button) { |
| 221 | case HIDButton::A: | 222 | case Core::HID::NpadButton::A: |
| 222 | SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>(); | 223 | SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>(); |
| 223 | break; | 224 | break; |
| 224 | case HIDButton::B: | 225 | case Core::HID::NpadButton::B: |
| 225 | SendKeyPressEvent(Qt::Key_B); | 226 | SendKeyPressEvent(Qt::Key_B); |
| 226 | break; | 227 | break; |
| 227 | case HIDButton::X: | 228 | case Core::HID::NpadButton::X: |
| 228 | SendKeyPressEvent(Qt::Key_X); | 229 | SendKeyPressEvent(Qt::Key_X); |
| 229 | break; | 230 | break; |
| 230 | case HIDButton::Y: | 231 | case Core::HID::NpadButton::Y: |
| 231 | SendKeyPressEvent(Qt::Key_Y); | 232 | SendKeyPressEvent(Qt::Key_Y); |
| 232 | break; | 233 | break; |
| 233 | default: | 234 | default: |
| @@ -245,9 +246,9 @@ void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() { | |||
| 245 | (f(T), ...); | 246 | (f(T), ...); |
| 246 | } | 247 | } |
| 247 | 248 | ||
| 248 | template <HIDButton... T> | 249 | template <Core::HID::NpadButton... T> |
| 249 | void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() { | 250 | void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() { |
| 250 | const auto f = [this](HIDButton button) { | 251 | const auto f = [this](Core::HID::NpadButton button) { |
| 251 | if (input_interpreter->IsButtonPressedOnce(button)) { | 252 | if (input_interpreter->IsButtonPressedOnce(button)) { |
| 252 | SendKeyPressEvent(HIDButtonToKey(button)); | 253 | SendKeyPressEvent(HIDButtonToKey(button)); |
| 253 | } | 254 | } |
| @@ -256,9 +257,9 @@ void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() { | |||
| 256 | (f(T), ...); | 257 | (f(T), ...); |
| 257 | } | 258 | } |
| 258 | 259 | ||
| 259 | template <HIDButton... T> | 260 | template <Core::HID::NpadButton... T> |
| 260 | void QtNXWebEngineView::HandleWindowKeyButtonHold() { | 261 | void QtNXWebEngineView::HandleWindowKeyButtonHold() { |
| 261 | const auto f = [this](HIDButton button) { | 262 | const auto f = [this](Core::HID::NpadButton button) { |
| 262 | if (input_interpreter->IsButtonHeld(button)) { | 263 | if (input_interpreter->IsButtonHeld(button)) { |
| 263 | SendKeyPressEvent(HIDButtonToKey(button)); | 264 | SendKeyPressEvent(HIDButtonToKey(button)); |
| 264 | } | 265 | } |
| @@ -309,17 +310,21 @@ void QtNXWebEngineView::InputThread() { | |||
| 309 | while (input_thread_running) { | 310 | while (input_thread_running) { |
| 310 | input_interpreter->PollInput(); | 311 | input_interpreter->PollInput(); |
| 311 | 312 | ||
| 312 | HandleWindowFooterButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::X, HIDButton::Y, | 313 | HandleWindowFooterButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B, |
| 313 | HIDButton::L, HIDButton::R>(); | 314 | Core::HID::NpadButton::X, Core::HID::NpadButton::Y, |
| 314 | 315 | Core::HID::NpadButton::L, Core::HID::NpadButton::R>(); | |
| 315 | HandleWindowKeyButtonPressedOnce<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight, | 316 | |
| 316 | HIDButton::DDown, HIDButton::LStickLeft, | 317 | HandleWindowKeyButtonPressedOnce< |
| 317 | HIDButton::LStickUp, HIDButton::LStickRight, | 318 | Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, |
| 318 | HIDButton::LStickDown>(); | 319 | Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, |
| 319 | 320 | Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, | |
| 320 | HandleWindowKeyButtonHold<HIDButton::DLeft, HIDButton::DUp, HIDButton::DRight, | 321 | Core::HID::NpadButton::StickLDown>(); |
| 321 | HIDButton::DDown, HIDButton::LStickLeft, HIDButton::LStickUp, | 322 | |
| 322 | HIDButton::LStickRight, HIDButton::LStickDown>(); | 323 | HandleWindowKeyButtonHold< |
| 324 | Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, | ||
| 325 | Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, | ||
| 326 | Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, | ||
| 327 | Core::HID::NpadButton::StickLDown>(); | ||
| 323 | 328 | ||
| 324 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); | 329 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); |
| 325 | } | 330 | } |
diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h index 7e9f703fc..fa18aecac 100644 --- a/src/yuzu/applets/qt_web_browser.h +++ b/src/yuzu/applets/qt_web_browser.h | |||
| @@ -16,8 +16,6 @@ | |||
| 16 | 16 | ||
| 17 | #include "core/frontend/applets/web_browser.h" | 17 | #include "core/frontend/applets/web_browser.h" |
| 18 | 18 | ||
| 19 | enum class HIDButton : u8; | ||
| 20 | |||
| 21 | class GMainWindow; | 19 | class GMainWindow; |
| 22 | class InputInterpreter; | 20 | class InputInterpreter; |
| 23 | class UrlRequestInterceptor; | 21 | class UrlRequestInterceptor; |
| @@ -26,6 +24,10 @@ namespace Core { | |||
| 26 | class System; | 24 | class System; |
| 27 | } | 25 | } |
| 28 | 26 | ||
| 27 | namespace Core::HID { | ||
| 28 | enum class NpadButton : u64; | ||
| 29 | } | ||
| 30 | |||
| 29 | namespace InputCommon { | 31 | namespace InputCommon { |
| 30 | class InputSubsystem; | 32 | class InputSubsystem; |
| 31 | } | 33 | } |
| @@ -114,7 +116,7 @@ private: | |||
| 114 | * | 116 | * |
| 115 | * @tparam HIDButton The list of buttons contained in yuzu_key_callbacks | 117 | * @tparam HIDButton The list of buttons contained in yuzu_key_callbacks |
| 116 | */ | 118 | */ |
| 117 | template <HIDButton... T> | 119 | template <Core::HID::NpadButton... T> |
| 118 | void HandleWindowFooterButtonPressedOnce(); | 120 | void HandleWindowFooterButtonPressedOnce(); |
| 119 | 121 | ||
| 120 | /** | 122 | /** |
| @@ -123,7 +125,7 @@ private: | |||
| 123 | * | 125 | * |
| 124 | * @tparam HIDButton The list of buttons that can be converted into keyboard input. | 126 | * @tparam HIDButton The list of buttons that can be converted into keyboard input. |
| 125 | */ | 127 | */ |
| 126 | template <HIDButton... T> | 128 | template <Core::HID::NpadButton... T> |
| 127 | void HandleWindowKeyButtonPressedOnce(); | 129 | void HandleWindowKeyButtonPressedOnce(); |
| 128 | 130 | ||
| 129 | /** | 131 | /** |
| @@ -132,7 +134,7 @@ private: | |||
| 132 | * | 134 | * |
| 133 | * @tparam HIDButton The list of buttons that can be converted into keyboard input. | 135 | * @tparam HIDButton The list of buttons that can be converted into keyboard input. |
| 134 | */ | 136 | */ |
| 135 | template <HIDButton... T> | 137 | template <Core::HID::NpadButton... T> |
| 136 | void HandleWindowKeyButtonHold(); | 138 | void HandleWindowKeyButtonHold(); |
| 137 | 139 | ||
| 138 | /** | 140 | /** |