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