From e9bd94ad62bf9ef4536d6d359d505cb58cc9372b Mon Sep 17 00:00:00 2001 From: rankun Date: Tue, 13 Nov 2018 17:40:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A2=E5=A4=B4=E6=8C=89=E9=94=AE=E6=98=A0?= =?UTF-8?q?=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/inputcontrol/inputconvertgame.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/inputcontrol/inputconvertgame.cpp b/src/inputcontrol/inputconvertgame.cpp index fb8f1e1..b17b495 100644 --- a/src/inputcontrol/inputconvertgame.cpp +++ b/src/inputcontrol/inputconvertgame.cpp @@ -260,6 +260,7 @@ void InputConvertGame::steerWheelMove(int keysNum, int keyPress1, int keyPress2) bool InputConvertGame::processKeyClick(const QKeyEvent *from) { QPointF clickPos; + bool touchTwice = false; switch (from->key()) { case Qt::Key_Space: // 跳 clickPos = QPointF(0.96f, 0.7f); @@ -291,6 +292,14 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from) case Qt::Key_H: // 捡东西3 clickPos = QPointF(0.7f, 0.54f); break; + case Qt::Key_Q: // 左探头 + touchTwice = true; + clickPos = QPointF(0.2f, 0.54f); + break; + case Qt::Key_E: // 右探头 + touchTwice = true; + clickPos = QPointF(0.3f, 0.54f); + break; default: return false; break; @@ -299,7 +308,15 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from) if (QEvent::KeyPress == from->type()) { int id = attachTouchID(from->key()); sendTouchDownEvent(id, clickPos); + if (touchTwice) { + sendTouchUpEvent(getTouchID(from->key()), clickPos); + detachTouchID(from->key()); + } } else if (QEvent::KeyRelease == from->type()) { + if (touchTwice) { + int id = attachTouchID(from->key()); + sendTouchDownEvent(id, clickPos); + } sendTouchUpEvent(getTouchID(from->key()), clickPos); detachTouchID(from->key()); }