diff options
author | german77 <juangerman-13@hotmail.com> | 2021-09-21 02:39:08 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2021-11-25 03:30:23 +0100 |
commit | 737d305f6324d28a7fde882077fb7e9a0e66311f (patch) | |
tree | b5023523b599a330633303e6b5c95d18d5653ca4 | |
parent | input_common: Rewrite main and add the new drivers (diff) | |
download | yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.gz yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.bz2 yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.lz yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.xz yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.tar.zst yuzu-737d305f6324d28a7fde882077fb7e9a0e66311f.zip |
-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 @@ #include "common/assert.h" #include "common/microprofile.h" +#include "common/param_package.h" #include "common/scm_rev.h" #include "common/scope_exit.h" #include "common/settings.h" #include "core/core.h" #include "core/frontend/framebuffer_layout.h" -#include "input_common/keyboard.h" +#include "input_common/drivers/keyboard.h" +#include "input_common/drivers/mouse.h" +#include "input_common/drivers/touch_screen.h" #include "input_common/main.h" #include "video_core/renderer_base.h" #include "video_core/video_core.h" @@ -294,7 +297,6 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); input_subsystem->Initialize(); - this->setMouseTracking(true); connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); @@ -392,34 +394,34 @@ void GRenderWindow::closeEvent(QCloseEvent* event) { void GRenderWindow::keyPressEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { - // input_subsystem->GetKeyboard()->PressKey(event->key()); + input_subsystem->GetKeyboard()->PressKey(event->key()); } } void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { - // input_subsystem->GetKeyboard()->ReleaseKey(event->key()); - } -} - -//MouseInput::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { -// switch (button) { -// case Qt::LeftButton: -// return MouseInput::MouseButton::Left; -// case Qt::RightButton: -// return MouseInput::MouseButton::Right; -// case Qt::MiddleButton: -// return MouseInput::MouseButton::Wheel; -// case Qt::BackButton: -// return MouseInput::MouseButton::Backward; -// case Qt::ForwardButton: -// return MouseInput::MouseButton::Forward; -// case Qt::TaskButton: -// return MouseInput::MouseButton::Task; -// default: -// return MouseInput::MouseButton::Extra; -// } -//} + input_subsystem->GetKeyboard()->ReleaseKey(event->key()); + } +} + +InputCommon::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { + switch (button) { + case Qt::LeftButton: + return InputCommon::MouseButton::Left; + case Qt::RightButton: + return InputCommon::MouseButton::Right; + case Qt::MiddleButton: + return InputCommon::MouseButton::Wheel; + case Qt::BackButton: + return InputCommon::MouseButton::Backward; + case Qt::ForwardButton: + return InputCommon::MouseButton::Forward; + case Qt::TaskButton: + return InputCommon::MouseButton::Task; + default: + return InputCommon::MouseButton::Extra; + } +} void GRenderWindow::mousePressEvent(QMouseEvent* event) { // Touch input is handled in TouchBeginEvent @@ -430,12 +432,9 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { // coordinates and map them to the current render area const auto pos = mapFromGlobal(QCursor::pos()); const auto [x, y] = ScaleTouch(pos); - //const auto button = QtButtonToMouseButton(event->button()); - //input_subsystem->GetMouse()->PressButton(x, y, button); - - if (event->button() == Qt::LeftButton) { - this->TouchPressed(x, y, 0); - } + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + const auto button = QtButtonToMouseButton(event->button()); + input_subsystem->GetMouse()->PressButton(x, y, touch_x, touch_y, button); emit MouseActivity(); } @@ -449,10 +448,10 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { // coordinates and map them to the current render area const auto pos = mapFromGlobal(QCursor::pos()); const auto [x, y] = ScaleTouch(pos); + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); const int center_x = width() / 2; const int center_y = height() / 2; - //input_subsystem->GetMouse()->MouseMove(x, y, center_x, center_y); - this->TouchMoved(x, y, 0); + input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, center_x, center_y); if (Settings::values.mouse_panning) { QCursor::setPos(mapToGlobal({center_x, center_y})); @@ -467,12 +466,8 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { return; } - //const auto button = QtButtonToMouseButton(event->button()); - //input_subsystem->GetMouse()->ReleaseButton(button); - - if (event->button() == Qt::LeftButton) { - this->TouchReleased(0); - } + const auto button = QtButtonToMouseButton(event->button()); + input_subsystem->GetMouse()->ReleaseButton(button); } void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { @@ -495,7 +490,7 @@ void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) { for (std::size_t id = 0; id < touch_ids.size(); ++id) { if (!TouchExist(touch_ids[id], touch_points)) { touch_ids[id] = 0; - this->TouchReleased(id + 1); + input_subsystem->GetTouchScreen()->TouchReleased(id); } } } @@ -504,28 +499,28 @@ void GRenderWindow::TouchEndEvent() { for (std::size_t id = 0; id < touch_ids.size(); ++id) { if (touch_ids[id] != 0) { touch_ids[id] = 0; - this->TouchReleased(id + 1); + input_subsystem->GetTouchScreen()->TouchReleased(id); } } } -bool GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) { +void GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) { for (std::size_t id = 0; id < touch_ids.size(); ++id) { if (touch_ids[id] == 0) { touch_ids[id] = touch_point.id() + 1; const auto [x, y] = ScaleTouch(touch_point.pos()); - this->TouchPressed(x, y, id + 1); - return true; + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, id); } } - return false; } bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) { for (std::size_t id = 0; id < touch_ids.size(); ++id) { if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) { const auto [x, y] = ScaleTouch(touch_point.pos()); - this->TouchMoved(x, y, id + 1); + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, id); return true; } } @@ -556,9 +551,9 @@ bool GRenderWindow::event(QEvent* event) { void GRenderWindow::focusOutEvent(QFocusEvent* event) { QWidget::focusOutEvent(event); - //input_subsystem->GetKeyboard()->ReleaseAllKeys(); - //input_subsystem->GetMouse()->ReleaseAllButtons(); - this->TouchReleased(0); + input_subsystem->GetKeyboard()->ReleaseAllKeys(); + input_subsystem->GetMouse()->ReleaseAllButtons(); + input_subsystem->GetTouchScreen()->ReleaseAllTouch(); } 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; namespace InputCommon { class InputSubsystem; -} - -namespace MouseInput { enum class MouseButton; -} +} // namespace InputCommon namespace VideoCore { enum class LoadCallbackStage; @@ -165,7 +162,7 @@ public: void keyReleaseEvent(QKeyEvent* event) override; /// Converts a Qt mouse button into MouseInput mouse button - // static MouseInput::MouseButton QtButtonToMouseButton(Qt::MouseButton button); + static InputCommon::MouseButton QtButtonToMouseButton(Qt::MouseButton button); void mousePressEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; @@ -214,7 +211,7 @@ private: void TouchUpdateEvent(const QTouchEvent* event); void TouchEndEvent(); - bool TouchStart(const QTouchEvent::TouchPoint& touch_point); + void TouchStart(const QTouchEvent::TouchPoint& touch_point); bool TouchUpdate(const QTouchEvent::TouchPoint& touch_point); bool TouchExist(std::size_t id, const QList<QTouchEvent::TouchPoint>& touch_points) const; 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 #include "core/loader/loader.h" #include "core/perf_stats.h" #include "core/telemetry_session.h" +#include "input_common/drivers/tas_input.h" #include "input_common/main.h" -#include "input_common/tas/tas_input.h" #include "ui_main.h" #include "util/overlay_dialog.h" #include "video_core/gpu.h" @@ -838,7 +838,6 @@ void GMainWindow::InitializeWidgets() { controller_type = Settings::ControllerType::ProController; ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); configure_dialog.ApplyConfiguration(); - controller_dialog->refreshConfiguration(); } Settings::values.use_docked_mode.SetValue(!is_docked); @@ -922,7 +921,7 @@ void GMainWindow::InitializeDebugWidgets() { waitTreeWidget->hide(); debug_menu->addAction(waitTreeWidget->toggleViewAction()); - controller_dialog = new ControllerDialog(this, input_subsystem.get()); + controller_dialog = new ControllerDialog(this); controller_dialog->hide(); debug_menu->addAction(controller_dialog->toggleViewAction()); @@ -2708,7 +2707,6 @@ void GMainWindow::OnConfigure() { ShowTelemetryCallout(); } - controller_dialog->refreshConfiguration(); InitializeHotkeys(); if (UISettings::values.theme != old_theme) { @@ -2969,15 +2967,15 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie } QString GMainWindow::GetTasStateDescription() const { - //auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); - //switch (tas_status) { - //case TasInput::TasState::Running: - // return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames); - //case TasInput::TasState::Recording: - // return tr("TAS state: Recording %1").arg(total_tas_frames); - //case TasInput::TasState::Stopped: - // return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames); - //default: + auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); + switch (tas_status) { + case InputCommon::TasInput::TasState::Running: + return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames); + case InputCommon::TasInput::TasState::Recording: + return tr("TAS state: Recording %1").arg(total_tas_frames); + case InputCommon::TasInput::TasState::Stopped: + return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames); + default: return tr("TAS State: Invalid"); } } @@ -3371,6 +3369,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { UpdateUISettings(); game_list->SaveInterfaceLayout(); hotkey_registry.SaveHotkeys(); + Core::System::GetInstance().HIDCore().UnloadInputDevices(); // Shutdown session if the emu thread is active... if (emu_thread != nullptr) { |