diff options
| -rw-r--r-- | src/yuzu/util/overlay_dialog.cpp | 27 | ||||
| -rw-r--r-- | src/yuzu/util/overlay_dialog.h | 10 |
2 files changed, 21 insertions, 16 deletions
diff --git a/src/yuzu/util/overlay_dialog.cpp b/src/yuzu/util/overlay_dialog.cpp index 95b148545..c66dfbdff 100644 --- a/src/yuzu/util/overlay_dialog.cpp +++ b/src/yuzu/util/overlay_dialog.cpp | |||
| @@ -6,7 +6,8 @@ | |||
| 6 | #include <QScreen> | 6 | #include <QScreen> |
| 7 | 7 | ||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/frontend/input_interpreter.h" | 9 | #include "core/hid/hid_types.h" |
| 10 | #include "core/hid/input_interpreter.h" | ||
| 10 | #include "ui_overlay_dialog.h" | 11 | #include "ui_overlay_dialog.h" |
| 11 | #include "yuzu/util/overlay_dialog.h" | 12 | #include "yuzu/util/overlay_dialog.h" |
| 12 | 13 | ||
| @@ -179,9 +180,9 @@ void OverlayDialog::MoveAndResizeWindow() { | |||
| 179 | QDialog::resize(width, height); | 180 | QDialog::resize(width, height); |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | template <HIDButton... T> | 183 | template <Core::HID::NpadButton... T> |
| 183 | void OverlayDialog::HandleButtonPressedOnce() { | 184 | void OverlayDialog::HandleButtonPressedOnce() { |
| 184 | const auto f = [this](HIDButton button) { | 185 | const auto f = [this](Core::HID::NpadButton button) { |
| 185 | if (input_interpreter->IsButtonPressedOnce(button)) { | 186 | if (input_interpreter->IsButtonPressedOnce(button)) { |
| 186 | TranslateButtonPress(button); | 187 | TranslateButtonPress(button); |
| 187 | } | 188 | } |
| @@ -190,7 +191,7 @@ void OverlayDialog::HandleButtonPressedOnce() { | |||
| 190 | (f(T), ...); | 191 | (f(T), ...); |
| 191 | } | 192 | } |
| 192 | 193 | ||
| 193 | void OverlayDialog::TranslateButtonPress(HIDButton button) { | 194 | void OverlayDialog::TranslateButtonPress(Core::HID::NpadButton button) { |
| 194 | QPushButton* left_button = use_rich_text ? ui->button_cancel_rich : ui->button_cancel; | 195 | QPushButton* left_button = use_rich_text ? ui->button_cancel_rich : ui->button_cancel; |
| 195 | QPushButton* right_button = use_rich_text ? ui->button_ok_rich : ui->button_ok_label; | 196 | QPushButton* right_button = use_rich_text ? ui->button_ok_rich : ui->button_ok_label; |
| 196 | 197 | ||
| @@ -198,20 +199,20 @@ void OverlayDialog::TranslateButtonPress(HIDButton button) { | |||
| 198 | // TODO (Morph): focusPrevious/NextChild() doesn't work well with the rich text dialog, fix it | 199 | // TODO (Morph): focusPrevious/NextChild() doesn't work well with the rich text dialog, fix it |
| 199 | 200 | ||
| 200 | switch (button) { | 201 | switch (button) { |
| 201 | case HIDButton::A: | 202 | case Core::HID::NpadButton::A: |
| 202 | case HIDButton::B: | 203 | case Core::HID::NpadButton::B: |
| 203 | if (left_button->hasFocus()) { | 204 | if (left_button->hasFocus()) { |
| 204 | left_button->click(); | 205 | left_button->click(); |
| 205 | } else if (right_button->hasFocus()) { | 206 | } else if (right_button->hasFocus()) { |
| 206 | right_button->click(); | 207 | right_button->click(); |
| 207 | } | 208 | } |
| 208 | break; | 209 | break; |
| 209 | case HIDButton::DLeft: | 210 | case Core::HID::NpadButton::Left: |
| 210 | case HIDButton::LStickLeft: | 211 | case Core::HID::NpadButton::StickLLeft: |
| 211 | focusPreviousChild(); | 212 | focusPreviousChild(); |
| 212 | break; | 213 | break; |
| 213 | case HIDButton::DRight: | 214 | case Core::HID::NpadButton::Right: |
| 214 | case HIDButton::LStickRight: | 215 | case Core::HID::NpadButton::StickLRight: |
| 215 | focusNextChild(); | 216 | focusNextChild(); |
| 216 | break; | 217 | break; |
| 217 | default: | 218 | default: |
| @@ -241,8 +242,10 @@ void OverlayDialog::InputThread() { | |||
| 241 | while (input_thread_running) { | 242 | while (input_thread_running) { |
| 242 | input_interpreter->PollInput(); | 243 | input_interpreter->PollInput(); |
| 243 | 244 | ||
| 244 | HandleButtonPressedOnce<HIDButton::A, HIDButton::B, HIDButton::DLeft, HIDButton::DRight, | 245 | HandleButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B, |
| 245 | HIDButton::LStickLeft, HIDButton::LStickRight>(); | 246 | Core::HID::NpadButton::Left, Core::HID::NpadButton::Right, |
| 247 | Core::HID::NpadButton::StickLLeft, | ||
| 248 | Core::HID::NpadButton::StickLRight>(); | ||
| 246 | 249 | ||
| 247 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); | 250 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); |
| 248 | } | 251 | } |
diff --git a/src/yuzu/util/overlay_dialog.h b/src/yuzu/util/overlay_dialog.h index e8c388bd0..d8a140ff3 100644 --- a/src/yuzu/util/overlay_dialog.h +++ b/src/yuzu/util/overlay_dialog.h | |||
| @@ -13,14 +13,16 @@ | |||
| 13 | 13 | ||
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | 15 | ||
| 16 | enum class HIDButton : u8; | ||
| 17 | |||
| 18 | class InputInterpreter; | 16 | class InputInterpreter; |
| 19 | 17 | ||
| 20 | namespace Core { | 18 | namespace Core { |
| 21 | class System; | 19 | class System; |
| 22 | } | 20 | } |
| 23 | 21 | ||
| 22 | namespace Core::HID { | ||
| 23 | enum class NpadButton : u64; | ||
| 24 | } | ||
| 25 | |||
| 24 | namespace Ui { | 26 | namespace Ui { |
| 25 | class OverlayDialog; | 27 | class OverlayDialog; |
| 26 | } | 28 | } |
| @@ -79,7 +81,7 @@ private: | |||
| 79 | * | 81 | * |
| 80 | * @tparam HIDButton The list of buttons that can be converted into keyboard input. | 82 | * @tparam HIDButton The list of buttons that can be converted into keyboard input. |
| 81 | */ | 83 | */ |
| 82 | template <HIDButton... T> | 84 | template <Core::HID::NpadButton... T> |
| 83 | void HandleButtonPressedOnce(); | 85 | void HandleButtonPressedOnce(); |
| 84 | 86 | ||
| 85 | /** | 87 | /** |
| @@ -87,7 +89,7 @@ private: | |||
| 87 | * | 89 | * |
| 88 | * @param button The button press to process. | 90 | * @param button The button press to process. |
| 89 | */ | 91 | */ |
| 90 | void TranslateButtonPress(HIDButton button); | 92 | void TranslateButtonPress(Core::HID::NpadButton button); |
| 91 | 93 | ||
| 92 | void StartInputThread(); | 94 | void StartInputThread(); |
| 93 | void StopInputThread(); | 95 | void StopInputThread(); |