mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 06:05:40 +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 keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
void loadLuaScript(const std::string& code);
|
||||
void reloadShader(const std::string& shader);
|
||||
void editCheat(u32 handle, const std::vector<uint8_t>& cheat, const std::function<void(u32)>& callback);
|
||||
|
||||
void handleScreenResize(u32 width, u32 height);
|
||||
void handleTouchscreenPress(QMouseEvent* event);
|
||||
};
|
||||
|
|
|
@ -487,6 +487,24 @@ void MainWindow::keyReleaseEvent(QKeyEvent* event) {
|
|||
|
||||
void MainWindow::mousePressEvent(QMouseEvent* event) {
|
||||
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 widgetPos = screen->mapFromGlobal(clickPos);
|
||||
|
||||
|
@ -511,13 +529,6 @@ void MainWindow::mousePressEvent(QMouseEvent* event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mouseReleaseEvent(QMouseEvent* event) {
|
||||
if (event->button() == Qt::MouseButton::LeftButton) {
|
||||
sendMessage(EmulatorMessage{.type = MessageType::ReleaseTouchscreen});
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadLuaScript(const std::string& code) {
|
||||
EmulatorMessage message{.type = MessageType::LoadLuaScript};
|
||||
|
|
Loading…
Add table
Reference in a new issue