From 8135f89931873fbe2ae3daf40f712d86354af657 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Tue, 13 Nov 2018 21:20:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8C=89=E9=94=AE=E6=8E=A2=E5=A4=B4?= =?UTF-8?q?=E6=98=A0=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..1f1333f 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 clickTwice = 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: // 左探头 + clickTwice = true; + clickPos = QPointF(0.12f, 0.35f); + break; + case Qt::Key_E: // 右探头 + clickTwice = true; + clickPos = QPointF(0.2, 0.35f); + 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 (clickTwice) { + sendTouchUpEvent(getTouchID(from->key()), clickPos); + detachTouchID(from->key()); + } } else if (QEvent::KeyRelease == from->type()) { + if (clickTwice) { + int id = attachTouchID(from->key()); + sendTouchDownEvent(id, clickPos); + } sendTouchUpEvent(getTouchID(from->key()), clickPos); detachTouchID(from->key()); } From e4a42b5e89c4908758b5475c62cedf70c1f1f92a Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Tue, 13 Nov 2018 22:12:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8C=89=E9=94=AE?= =?UTF-8?q?=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/inputcontrol/inputconvertgame.cpp | 34 ++++++++++++++++++++------- src/inputcontrol/inputconvertgame.h | 4 ++-- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/inputcontrol/inputconvertgame.cpp b/src/inputcontrol/inputconvertgame.cpp index 1f1333f..c0f5777 100644 --- a/src/inputcontrol/inputconvertgame.cpp +++ b/src/inputcontrol/inputconvertgame.cpp @@ -234,23 +234,23 @@ void InputConvertGame::steerWheelMove(int keysNum, int keyPress1, int keyPress2) switch (keysNum) { case 2: if (keyPress2 == SWD_UP) { - movePos.setY(movePos.y() - m_steerWheelOffset.y()); + movePos.setY(movePos.y() - m_steerWheelOffset.top()); } else if (keyPress2 == SWD_RIGHT) { - movePos.setX(movePos.x() + m_steerWheelOffset.x()); + movePos.setX(movePos.x() + m_steerWheelOffset.right()); } else if (keyPress2 == SWD_DOWN) { - movePos.setY(movePos.y() + m_steerWheelOffset.y()); + movePos.setY(movePos.y() + m_steerWheelOffset.bottom()); } else if (keyPress2 == SWD_LEFT) { - movePos.setX(movePos.x() - m_steerWheelOffset.x()); + movePos.setX(movePos.x() - m_steerWheelOffset.left()); } case 1: if (keyPress1 == SWD_UP) { - movePos.setY(movePos.y() - m_steerWheelOffset.y()); + movePos.setY(movePos.y() - m_steerWheelOffset.top()); } else if (keyPress1 == SWD_RIGHT) { - movePos.setX(movePos.x() + m_steerWheelOffset.x()); + movePos.setX(movePos.x() + m_steerWheelOffset.right()); } else if (keyPress1 == SWD_DOWN) { - movePos.setY(movePos.y() + m_steerWheelOffset.y()); + movePos.setY(movePos.y() + m_steerWheelOffset.bottom()); } else if (keyPress1 == SWD_LEFT) { - movePos.setX(movePos.x() - m_steerWheelOffset.x()); + movePos.setX(movePos.x() - m_steerWheelOffset.left()); } break; } @@ -292,6 +292,24 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from) case Qt::Key_H: // 捡东西3 clickPos = QPointF(0.7f, 0.54f); break; + case Qt::Key_1: // 换枪1 + clickPos = QPointF(0.45f, 0.9f); + break; + case Qt::Key_2: // 换枪2 + clickPos = QPointF(0.55f, 0.9f); + break; + case Qt::Key_3: // 手雷 + clickPos = QPointF(0.67f, 0.92f); + break; + case Qt::Key_5: // 下车 + clickPos = QPointF(0.92f, 0.4f); + break; + case Qt::Key_Shift: // 车加速 + clickPos = QPointF(0.82f, 0.8f); + break; + case Qt::Key_4: // 开关门 + clickPos = QPointF(0.7f, 0.7f); + break; case Qt::Key_Q: // 左探头 clickTwice = true; clickPos = QPointF(0.12f, 0.35f); diff --git a/src/inputcontrol/inputconvertgame.h b/src/inputcontrol/inputconvertgame.h index c20d7b2..e15dace 100644 --- a/src/inputcontrol/inputconvertgame.h +++ b/src/inputcontrol/inputconvertgame.h @@ -65,8 +65,8 @@ private: int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 }; - QPointF m_steerWheelPos = {0.16f, 0.75f}; - QPointF m_steerWheelOffset = {0.1f, 0.2f}; + QPointF m_steerWheelPos = {0.16f, 0.75f}; + QRectF m_steerWheelOffset = {QPointF(0.1f, 0.27f), QPointF(0.1f, 0.2f)}; // order by SteerWheelDirection(up right down left) int m_steerWheelKeys[4] = {Qt::Key_W, Qt::Key_D, Qt::Key_S, Qt::Key_A}; bool m_steerWheelKeysPress[4] = { false };