aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/bootmanager.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-09-20 19:39:08 -0500
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-24 20:30:23 -0600
commit737d305f6324d28a7fde882077fb7e9a0e66311f (patch)
treeb5023523b599a330633303e6b5c95d18d5653ca4 /src/yuzu/bootmanager.cpp
parent29ae42f3e2c297898d88858861f7d860ce9fc2f3 (diff)
yuzu: Use new input on main and bootmanager
Diffstat (limited to 'src/yuzu/bootmanager.cpp')
-rw-r--r--src/yuzu/bootmanager.cpp93
1 files changed, 44 insertions, 49 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 8a0ea90f9d..726f789b7f 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) {