|
|
@@ -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) {
|