diff --git a/QtScrcpy/device/controller/controller.cpp b/QtScrcpy/device/controller/controller.cpp index d24c69f..953a11d 100644 --- a/QtScrcpy/device/controller/controller.cpp +++ b/QtScrcpy/device/controller/controller.cpp @@ -56,6 +56,15 @@ void Controller::updateScript(QString gameScript) connect(m_inputConvert, &InputConvertBase::grabCursor, this, &Controller::grabCursor); } +bool Controller::isCurrentCustomKeymap() +{ + if (!m_inputConvert) { + return false; + } + + return m_inputConvert->isCurrentCustomKeymap(); +} + void Controller::onPostBackOrScreenOn() { ControlMsg *controlMsg = new ControlMsg(ControlMsg::CMT_BACK_OR_SCREEN_ON); diff --git a/QtScrcpy/device/controller/controller.h b/QtScrcpy/device/controller/controller.h index ca19b77..3a7ef06 100644 --- a/QtScrcpy/device/controller/controller.h +++ b/QtScrcpy/device/controller/controller.h @@ -21,6 +21,7 @@ public: void test(QRect rc); void updateScript(QString gameScript = ""); + bool isCurrentCustomKeymap(); public slots: void onPostGoBack(); diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertbase.h b/QtScrcpy/device/controller/inputconvert/inputconvertbase.h index 6cc28cf..7cdde2c 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertbase.h +++ b/QtScrcpy/device/controller/inputconvert/inputconvertbase.h @@ -21,6 +21,10 @@ public: virtual void mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) = 0; virtual void wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize) = 0; virtual void keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize) = 0; + virtual bool isCurrentCustomKeymap() + { + return false; + }; signals: void grabCursor(bool grab); diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp b/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp index 30cc0f8..0624462 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp +++ b/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp @@ -124,6 +124,11 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize &frameSize, c } } +bool InputConvertGame::isCurrentCustomKeymap() +{ + return m_gameMap; +} + void InputConvertGame::loadKeyMap(const QString &json) { m_keyMap.loadKeyMap(json); diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertgame.h b/QtScrcpy/device/controller/inputconvert/inputconvertgame.h index de36855..b286d77 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertgame.h +++ b/QtScrcpy/device/controller/inputconvert/inputconvertgame.h @@ -17,6 +17,7 @@ public: virtual void mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize); virtual void wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize); virtual void keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize); + virtual bool isCurrentCustomKeymap(); void loadKeyMap(const QString &json); diff --git a/QtScrcpy/device/device.cpp b/QtScrcpy/device/device.cpp index 86cb318..55ca712 100644 --- a/QtScrcpy/device/device.cpp +++ b/QtScrcpy/device/device.cpp @@ -339,6 +339,14 @@ Device::GroupControlState Device::controlState() return m_controlState; } +bool Device::isCurrentCustomKeymap() +{ + if (!m_controller) { + return false; + } + return m_controller->isCurrentCustomKeymap(); +} + bool Device::saveFrame(const AVFrame *frame) { if (!frame) { diff --git a/QtScrcpy/device/device.h b/QtScrcpy/device/device.h index 29d4b15..38bc164 100644 --- a/QtScrcpy/device/device.h +++ b/QtScrcpy/device/device.h @@ -56,6 +56,8 @@ public: void updateScript(QString script); Device::GroupControlState controlState(); + bool isCurrentCustomKeymap(); + signals: void deviceDisconnect(QString serial); diff --git a/QtScrcpy/device/ui/videoform.cpp b/QtScrcpy/device/ui/videoform.cpp index 88bc6c3..282bc16 100644 --- a/QtScrcpy/device/ui/videoform.cpp +++ b/QtScrcpy/device/ui/videoform.cpp @@ -501,7 +501,7 @@ void VideoForm::setDevice(Device *device) void VideoForm::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::MiddleButton) { - if (m_device) { + if (m_device && !m_device->isCurrentCustomKeymap()) { emit m_device->postGoHome(); } } @@ -580,7 +580,7 @@ void VideoForm::mouseDoubleClickEvent(QMouseEvent *event) } } - if (event->button() == Qt::RightButton && m_device) { + if (event->button() == Qt::RightButton && m_device && !m_device->isCurrentCustomKeymap()) { emit m_device->postBackOrScreenOn(); } @@ -701,7 +701,7 @@ void VideoForm::dropEvent(QDropEvent *event) const QMimeData *qm = event->mimeData(); QList urls = qm->urls(); - for (const QUrl& url : urls) { + for (const QUrl &url : urls) { QString file = url.toLocalFile(); QFileInfo fileInfo(file);