mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
Qt: Handle mouse move events properly (#678)
This commit is contained in:
parent
79d24cba11
commit
4ce0768ba1
2 changed files with 36 additions and 22 deletions
|
@ -146,12 +146,15 @@ class MainWindow : public QMainWindow {
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
void keyReleaseEvent(QKeyEvent* event) override;
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
void loadLuaScript(const std::string& code);
|
void loadLuaScript(const std::string& code);
|
||||||
void reloadShader(const std::string& shader);
|
void reloadShader(const std::string& shader);
|
||||||
void editCheat(u32 handle, const std::vector<uint8_t>& cheat, const std::function<void(u32)>& callback);
|
void editCheat(u32 handle, const std::vector<uint8_t>& cheat, const std::function<void(u32)>& callback);
|
||||||
|
|
||||||
void handleScreenResize(u32 width, u32 height);
|
void handleScreenResize(u32 width, u32 height);
|
||||||
|
void handleTouchscreenPress(QMouseEvent* event);
|
||||||
};
|
};
|
||||||
|
|
|
@ -487,6 +487,24 @@ void MainWindow::keyReleaseEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
void MainWindow::mousePressEvent(QMouseEvent* event) {
|
void MainWindow::mousePressEvent(QMouseEvent* event) {
|
||||||
if (event->button() == Qt::MouseButton::LeftButton) {
|
if (event->button() == Qt::MouseButton::LeftButton) {
|
||||||
|
// We handle actual mouse press & movement logic inside the mouseMoveEvent handler
|
||||||
|
handleTouchscreenPress(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
if (event->buttons().testFlag(Qt::MouseButton::LeftButton)) {
|
||||||
|
handleTouchscreenPress(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
|
if (event->button() == Qt::MouseButton::LeftButton) {
|
||||||
|
sendMessage(EmulatorMessage{.type = MessageType::ReleaseTouchscreen});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::handleTouchscreenPress(QMouseEvent* event) {
|
||||||
const QPointF clickPos = event->globalPosition();
|
const QPointF clickPos = event->globalPosition();
|
||||||
const QPointF widgetPos = screen->mapFromGlobal(clickPos);
|
const QPointF widgetPos = screen->mapFromGlobal(clickPos);
|
||||||
|
|
||||||
|
@ -510,13 +528,6 @@ void MainWindow::mousePressEvent(QMouseEvent* event) {
|
||||||
sendMessage(EmulatorMessage{.type = MessageType::ReleaseTouchscreen});
|
sendMessage(EmulatorMessage{.type = MessageType::ReleaseTouchscreen});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::mouseReleaseEvent(QMouseEvent* event) {
|
|
||||||
if (event->button() == Qt::MouseButton::LeftButton) {
|
|
||||||
sendMessage(EmulatorMessage{.type = MessageType::ReleaseTouchscreen});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadLuaScript(const std::string& code) {
|
void MainWindow::loadLuaScript(const std::string& code) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue