From b39848e79f8e1309c603bc6cf0e07c14606e1fe8 Mon Sep 17 00:00:00 2001 From: rankun Date: Sun, 19 Jan 2020 22:23:32 +0800 Subject: [PATCH] fix: switch on mouse key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 过滤掉开关键的非MouseButtonPress类型的事件的处理 --- .../inputconvert/inputconvertgame.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp b/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp index 59a39ff..67d90b0 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp +++ b/QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp @@ -49,10 +49,10 @@ InputConvertGame::~InputConvertGame() void InputConvertGame::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) { // 处理开关按键 - if (m_keyMap.isSwitchOnKeyboard() == false && - from->type() == QEvent::MouseButtonPress && - m_keyMap.getSwitchKey() == from->button()) - { + if (m_keyMap.isSwitchOnKeyboard() == false && m_keyMap.getSwitchKey() == from->button()) { + if (from->type() != QEvent::MouseButtonPress) { + return; + } if (!switchGameMap()) { m_needSwitchGameAgain = false; } @@ -89,10 +89,11 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c { // 处理开关按键 if (m_keyMap.isSwitchOnKeyboard() && m_keyMap.getSwitchKey() == from->key()) { - if (QEvent::KeyPress == from->type()) { - if (!switchGameMap()) { - m_needSwitchGameAgain = false; - } + if (QEvent::KeyPress != from->type()) { + return; + } + if (!switchGameMap()) { + m_needSwitchGameAgain = false; } return; }