diff options
| author | 2021-09-20 19:39:08 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:23 -0600 | |
| commit | 737d305f6324d28a7fde882077fb7e9a0e66311f (patch) | |
| tree | b5023523b599a330633303e6b5c95d18d5653ca4 /src | |
| parent | input_common: Rewrite main and add the new drivers (diff) | |
| download | yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.gz yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.xz yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.zip | |
yuzu: Use new input on main and bootmanager
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 93 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 9 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 25 |
3 files changed, 59 insertions, 68 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 8a0ea90f9..726f789b7 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -27,12 +27,15 @@ | |||
| 27 | 27 | ||
| 28 | #include "common/assert.h" | 28 | #include "common/assert.h" |
| 29 | #include "common/microprofile.h" | 29 | #include "common/microprofile.h" |
| 30 | #include "common/param_package.h" | ||
| 30 | #include "common/scm_rev.h" | 31 | #include "common/scm_rev.h" |
| 31 | #include "common/scope_exit.h" | 32 | #include "common/scope_exit.h" |
| 32 | #include "common/settings.h" | 33 | #include "common/settings.h" |
| 33 | #include "core/core.h" | 34 | #include "core/core.h" |
| 34 | #include "core/frontend/framebuffer_layout.h" | 35 | #include "core/frontend/framebuffer_layout.h" |
| 35 | #include "input_common/keyboard.h" | 36 | #include "input_common/drivers/keyboard.h" |
| 37 | #include "input_common/drivers/mouse.h" | ||
| 38 | #include "input_common/drivers/touch_screen.h" | ||
| 36 | #include "input_common/main.h" | 39 | #include "input_common/main.h" |
| 37 | #include "video_core/renderer_base.h" | 40 | #include "video_core/renderer_base.h" |
| 38 | #include "video_core/video_core.h" | 41 | #include "video_core/video_core.h" |
| @@ -294,7 +297,6 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, | |||
| 294 | layout->setContentsMargins(0, 0, 0, 0); | 297 | layout->setContentsMargins(0, 0, 0, 0); |
| 295 | setLayout(layout); | 298 | setLayout(layout); |
| 296 | input_subsystem->Initialize(); | 299 | input_subsystem->Initialize(); |
| 297 | |||
| 298 | this->setMouseTracking(true); | 300 | this->setMouseTracking(true); |
| 299 | 301 | ||
| 300 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); | 302 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); |
| @@ -392,34 +394,34 @@ void GRenderWindow::closeEvent(QCloseEvent* event) { | |||
| 392 | 394 | ||
| 393 | void GRenderWindow::keyPressEvent(QKeyEvent* event) { | 395 | void GRenderWindow::keyPressEvent(QKeyEvent* event) { |
| 394 | if (!event->isAutoRepeat()) { | 396 | if (!event->isAutoRepeat()) { |
| 395 | // input_subsystem->GetKeyboard()->PressKey(event->key()); | 397 | input_subsystem->GetKeyboard()->PressKey(event->key()); |
| 396 | } | 398 | } |
| 397 | } | 399 | } |
| 398 | 400 | ||
| 399 | void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { | 401 | void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { |
| 400 | if (!event->isAutoRepeat()) { | 402 | if (!event->isAutoRepeat()) { |
| 401 | // input_subsystem->GetKeyboard()->ReleaseKey(event->key()); | 403 | input_subsystem->GetKeyboard()->ReleaseKey(event->key()); |
| 402 | } | 404 | } |
| 403 | } | 405 | } |
| 404 | 406 | ||
| 405 | //MouseInput::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { | 407 | InputCommon::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { |
| 406 | // switch (button) { | 408 | switch (button) { |
| 407 | // case Qt::LeftButton: | 409 | case Qt::LeftButton: |
| 408 | // return MouseInput::MouseButton::Left; | 410 | return InputCommon::MouseButton::Left; |
| 409 | // case Qt::RightButton: | 411 | case Qt::RightButton: |
| 410 | // return MouseInput::MouseButton::Right; | 412 | return InputCommon::MouseButton::Right; |
| 411 | // case Qt::MiddleButton: | 413 | case Qt::MiddleButton: |
| 412 | // return MouseInput::MouseButton::Wheel; | 414 | return InputCommon::MouseButton::Wheel; |
| 413 | // case Qt::BackButton: | 415 | case Qt::BackButton: |
| 414 | // return MouseInput::MouseButton::Backward; | 416 | return InputCommon::MouseButton::Backward; |
| 415 | // case Qt::ForwardButton: | 417 | case Qt::ForwardButton: |
| 416 | // return MouseInput::MouseButton::Forward; | 418 | return InputCommon::MouseButton::Forward; |
| 417 | // case Qt::TaskButton: | 419 | case Qt::TaskButton: |
| 418 | // return MouseInput::MouseButton::Task; | 420 | return InputCommon::MouseButton::Task; |
| 419 | // default: | 421 | default: |
| 420 | // return MouseInput::MouseButton::Extra; | 422 | return InputCommon::MouseButton::Extra; |
| 421 | // } | 423 | } |
| 422 | //} | 424 | } |
| 423 | 425 | ||
| 424 | void GRenderWindow::mousePressEvent(QMouseEvent* event) { | 426 | void GRenderWindow::mousePressEvent(QMouseEvent* event) { |
| 425 | // Touch input is handled in TouchBeginEvent | 427 | // Touch input is handled in TouchBeginEvent |
| @@ -430,12 +432,9 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { | |||
| 430 | // coordinates and map them to the current render area | 432 | // coordinates and map them to the current render area |
| 431 | const auto pos = mapFromGlobal(QCursor::pos()); | 433 | const auto pos = mapFromGlobal(QCursor::pos()); |
| 432 | const auto [x, y] = ScaleTouch(pos); | 434 | const auto [x, y] = ScaleTouch(pos); |
| 433 | //const auto button = QtButtonToMouseButton(event->button()); | 435 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); |
| 434 | //input_subsystem->GetMouse()->PressButton(x, y, button); | 436 | const auto button = QtButtonToMouseButton(event->button()); |
| 435 | 437 | input_subsystem->GetMouse()->PressButton(x, y, touch_x, touch_y, button); | |
| 436 | if (event->button() == Qt::LeftButton) { | ||
| 437 | this->TouchPressed(x, y, 0); | ||
| 438 | } | ||
| 439 | 438 | ||
| 440 | emit MouseActivity(); | 439 | emit MouseActivity(); |
| 441 | } | 440 | } |
| @@ -449,10 +448,10 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | |||
| 449 | // coordinates and map them to the current render area | 448 | // coordinates and map them to the current render area |
| 450 | const auto pos = mapFromGlobal(QCursor::pos()); | 449 | const auto pos = mapFromGlobal(QCursor::pos()); |
| 451 | const auto [x, y] = ScaleTouch(pos); | 450 | const auto [x, y] = ScaleTouch(pos); |
| 451 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); | ||
| 452 | const int center_x = width() / 2; | 452 | const int center_x = width() / 2; |
| 453 | const int center_y = height() / 2; | 453 | const int center_y = height() / 2; |
| 454 | //input_subsystem->GetMouse()->MouseMove(x, y, center_x, center_y); | 454 | input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, center_x, center_y); |
| 455 | this->TouchMoved(x, y, 0); | ||
| 456 | 455 | ||
| 457 | if (Settings::values.mouse_panning) { | 456 | if (Settings::values.mouse_panning) { |
| 458 | QCursor::setPos(mapToGlobal({center_x, center_y})); | 457 | QCursor::setPos(mapToGlobal({center_x, center_y})); |
| @@ -467,12 +466,8 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { | |||
| 467 | return; | 466 | return; |
| 468 | } | 467 | } |
| 469 | 468 | ||
| 470 | //const auto button = QtButtonToMouseButton(event->button()); | 469 | const auto button = QtButtonToMouseButton(event->button()); |
| 471 | //input_subsystem->GetMouse()->ReleaseButton(button); | 470 | input_subsystem->GetMouse()->ReleaseButton(button); |
| 472 | |||
| 473 | if (event->button() == Qt::LeftButton) { | ||
| 474 | this->TouchReleased(0); | ||
| 475 | } | ||
| 476 | } | 471 | } |
| 477 | 472 | ||
| 478 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { | 473 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { |
| @@ -495,7 +490,7 @@ void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) { | |||
| 495 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { | 490 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { |
| 496 | if (!TouchExist(touch_ids[id], touch_points)) { | 491 | if (!TouchExist(touch_ids[id], touch_points)) { |
| 497 | touch_ids[id] = 0; | 492 | touch_ids[id] = 0; |
| 498 | this->TouchReleased(id + 1); | 493 | input_subsystem->GetTouchScreen()->TouchReleased(id); |
| 499 | } | 494 | } |
| 500 | } | 495 | } |
| 501 | } | 496 | } |
| @@ -504,28 +499,28 @@ void GRenderWindow::TouchEndEvent() { | |||
| 504 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { | 499 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { |
| 505 | if (touch_ids[id] != 0) { | 500 | if (touch_ids[id] != 0) { |
| 506 | touch_ids[id] = 0; | 501 | touch_ids[id] = 0; |
| 507 | this->TouchReleased(id + 1); | 502 | input_subsystem->GetTouchScreen()->TouchReleased(id); |
| 508 | } | 503 | } |
| 509 | } | 504 | } |
| 510 | } | 505 | } |
| 511 | 506 | ||
| 512 | bool GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) { | 507 | void GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) { |
| 513 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { | 508 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { |
| 514 | if (touch_ids[id] == 0) { | 509 | if (touch_ids[id] == 0) { |
| 515 | touch_ids[id] = touch_point.id() + 1; | 510 | touch_ids[id] = touch_point.id() + 1; |
| 516 | const auto [x, y] = ScaleTouch(touch_point.pos()); | 511 | const auto [x, y] = ScaleTouch(touch_point.pos()); |
| 517 | this->TouchPressed(x, y, id + 1); | 512 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); |
| 518 | return true; | 513 | input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, id); |
| 519 | } | 514 | } |
| 520 | } | 515 | } |
| 521 | return false; | ||
| 522 | } | 516 | } |
| 523 | 517 | ||
| 524 | bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) { | 518 | bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) { |
| 525 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { | 519 | for (std::size_t id = 0; id < touch_ids.size(); ++id) { |
| 526 | if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) { | 520 | if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) { |
| 527 | const auto [x, y] = ScaleTouch(touch_point.pos()); | 521 | const auto [x, y] = ScaleTouch(touch_point.pos()); |
| 528 | this->TouchMoved(x, y, id + 1); | 522 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); |
| 523 | input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, id); | ||
| 529 | return true; | 524 | return true; |
| 530 | } | 525 | } |
| 531 | } | 526 | } |
| @@ -556,9 +551,9 @@ bool GRenderWindow::event(QEvent* event) { | |||
| 556 | 551 | ||
| 557 | void GRenderWindow::focusOutEvent(QFocusEvent* event) { | 552 | void GRenderWindow::focusOutEvent(QFocusEvent* event) { |
| 558 | QWidget::focusOutEvent(event); | 553 | QWidget::focusOutEvent(event); |
| 559 | //input_subsystem->GetKeyboard()->ReleaseAllKeys(); | 554 | input_subsystem->GetKeyboard()->ReleaseAllKeys(); |
| 560 | //input_subsystem->GetMouse()->ReleaseAllButtons(); | 555 | input_subsystem->GetMouse()->ReleaseAllButtons(); |
| 561 | this->TouchReleased(0); | 556 | input_subsystem->GetTouchScreen()->ReleaseAllTouch(); |
| 562 | } | 557 | } |
| 563 | 558 | ||
| 564 | void GRenderWindow::resizeEvent(QResizeEvent* event) { | 559 | void GRenderWindow::resizeEvent(QResizeEvent* event) { |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index f0784046b..95594f81c 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -30,11 +30,8 @@ class System; | |||
| 30 | 30 | ||
| 31 | namespace InputCommon { | 31 | namespace InputCommon { |
| 32 | class InputSubsystem; | 32 | class InputSubsystem; |
| 33 | } | ||
| 34 | |||
| 35 | namespace MouseInput { | ||
| 36 | enum class MouseButton; | 33 | enum class MouseButton; |
| 37 | } | 34 | } // namespace InputCommon |
| 38 | 35 | ||
| 39 | namespace VideoCore { | 36 | namespace VideoCore { |
| 40 | enum class LoadCallbackStage; | 37 | enum class LoadCallbackStage; |
| @@ -165,7 +162,7 @@ public: | |||
| 165 | void keyReleaseEvent(QKeyEvent* event) override; | 162 | void keyReleaseEvent(QKeyEvent* event) override; |
| 166 | 163 | ||
| 167 | /// Converts a Qt mouse button into MouseInput mouse button | 164 | /// Converts a Qt mouse button into MouseInput mouse button |
| 168 | // static MouseInput::MouseButton QtButtonToMouseButton(Qt::MouseButton button); | 165 | static InputCommon::MouseButton QtButtonToMouseButton(Qt::MouseButton button); |
| 169 | 166 | ||
| 170 | void mousePressEvent(QMouseEvent* event) override; | 167 | void mousePressEvent(QMouseEvent* event) override; |
| 171 | void mouseMoveEvent(QMouseEvent* event) override; | 168 | void mouseMoveEvent(QMouseEvent* event) override; |
| @@ -214,7 +211,7 @@ private: | |||
| 214 | void TouchUpdateEvent(const QTouchEvent* event); | 211 | void TouchUpdateEvent(const QTouchEvent* event); |
| 215 | void TouchEndEvent(); | 212 | void TouchEndEvent(); |
| 216 | 213 | ||
| 217 | bool TouchStart(const QTouchEvent::TouchPoint& touch_point); | 214 | void TouchStart(const QTouchEvent::TouchPoint& touch_point); |
| 218 | bool TouchUpdate(const QTouchEvent::TouchPoint& touch_point); | 215 | bool TouchUpdate(const QTouchEvent::TouchPoint& touch_point); |
| 219 | bool TouchExist(std::size_t id, const QList<QTouchEvent::TouchPoint>& touch_points) const; | 216 | bool TouchExist(std::size_t id, const QList<QTouchEvent::TouchPoint>& touch_points) const; |
| 220 | 217 | ||
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 663760a1e..7f36f6e2f 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -106,8 +106,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual | |||
| 106 | #include "core/loader/loader.h" | 106 | #include "core/loader/loader.h" |
| 107 | #include "core/perf_stats.h" | 107 | #include "core/perf_stats.h" |
| 108 | #include "core/telemetry_session.h" | 108 | #include "core/telemetry_session.h" |
| 109 | #include "input_common/drivers/tas_input.h" | ||
| 109 | #include "input_common/main.h" | 110 | #include "input_common/main.h" |
| 110 | #include "input_common/tas/tas_input.h" | ||
| 111 | #include "ui_main.h" | 111 | #include "ui_main.h" |
| 112 | #include "util/overlay_dialog.h" | 112 | #include "util/overlay_dialog.h" |
| 113 | #include "video_core/gpu.h" | 113 | #include "video_core/gpu.h" |
| @@ -838,7 +838,6 @@ void GMainWindow::InitializeWidgets() { | |||
| 838 | controller_type = Settings::ControllerType::ProController; | 838 | controller_type = Settings::ControllerType::ProController; |
| 839 | ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); | 839 | ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); |
| 840 | configure_dialog.ApplyConfiguration(); | 840 | configure_dialog.ApplyConfiguration(); |
| 841 | controller_dialog->refreshConfiguration(); | ||
| 842 | } | 841 | } |
| 843 | 842 | ||
| 844 | Settings::values.use_docked_mode.SetValue(!is_docked); | 843 | Settings::values.use_docked_mode.SetValue(!is_docked); |
| @@ -922,7 +921,7 @@ void GMainWindow::InitializeDebugWidgets() { | |||
| 922 | waitTreeWidget->hide(); | 921 | waitTreeWidget->hide(); |
| 923 | debug_menu->addAction(waitTreeWidget->toggleViewAction()); | 922 | debug_menu->addAction(waitTreeWidget->toggleViewAction()); |
| 924 | 923 | ||
| 925 | controller_dialog = new ControllerDialog(this, input_subsystem.get()); | 924 | controller_dialog = new ControllerDialog(this); |
| 926 | controller_dialog->hide(); | 925 | controller_dialog->hide(); |
| 927 | debug_menu->addAction(controller_dialog->toggleViewAction()); | 926 | debug_menu->addAction(controller_dialog->toggleViewAction()); |
| 928 | 927 | ||
| @@ -2708,7 +2707,6 @@ void GMainWindow::OnConfigure() { | |||
| 2708 | 2707 | ||
| 2709 | ShowTelemetryCallout(); | 2708 | ShowTelemetryCallout(); |
| 2710 | } | 2709 | } |
| 2711 | controller_dialog->refreshConfiguration(); | ||
| 2712 | InitializeHotkeys(); | 2710 | InitializeHotkeys(); |
| 2713 | 2711 | ||
| 2714 | if (UISettings::values.theme != old_theme) { | 2712 | if (UISettings::values.theme != old_theme) { |
| @@ -2969,15 +2967,15 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie | |||
| 2969 | } | 2967 | } |
| 2970 | 2968 | ||
| 2971 | QString GMainWindow::GetTasStateDescription() const { | 2969 | QString GMainWindow::GetTasStateDescription() const { |
| 2972 | //auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); | 2970 | auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); |
| 2973 | //switch (tas_status) { | 2971 | switch (tas_status) { |
| 2974 | //case TasInput::TasState::Running: | 2972 | case InputCommon::TasInput::TasState::Running: |
| 2975 | // return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames); | 2973 | return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames); |
| 2976 | //case TasInput::TasState::Recording: | 2974 | case InputCommon::TasInput::TasState::Recording: |
| 2977 | // return tr("TAS state: Recording %1").arg(total_tas_frames); | 2975 | return tr("TAS state: Recording %1").arg(total_tas_frames); |
| 2978 | //case TasInput::TasState::Stopped: | 2976 | case InputCommon::TasInput::TasState::Stopped: |
| 2979 | // return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames); | 2977 | return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames); |
| 2980 | //default: | 2978 | default: |
| 2981 | return tr("TAS State: Invalid"); | 2979 | return tr("TAS State: Invalid"); |
| 2982 | } | 2980 | } |
| 2983 | } | 2981 | } |
| @@ -3371,6 +3369,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { | |||
| 3371 | UpdateUISettings(); | 3369 | UpdateUISettings(); |
| 3372 | game_list->SaveInterfaceLayout(); | 3370 | game_list->SaveInterfaceLayout(); |
| 3373 | hotkey_registry.SaveHotkeys(); | 3371 | hotkey_registry.SaveHotkeys(); |
| 3372 | Core::System::GetInstance().HIDCore().UnloadInputDevices(); | ||
| 3374 | 3373 | ||
| 3375 | // Shutdown session if the emu thread is active... | 3374 | // Shutdown session if the emu thread is active... |
| 3376 | if (emu_thread != nullptr) { | 3375 | if (emu_thread != nullptr) { |