From 4c6e0173222f7f0572fc3c5f8398445f975e7e8e Mon Sep 17 00:00:00 2001 From: rankun Date: Fri, 9 Nov 2018 14:23:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=82=B9=E8=A7=A6=E6=8E=A7=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/inputcontrol/inputconvertgame.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/inputcontrol/inputconvertgame.cpp b/src/inputcontrol/inputconvertgame.cpp index 6c1dbc4..e259d8d 100644 --- a/src/inputcontrol/inputconvertgame.cpp +++ b/src/inputcontrol/inputconvertgame.cpp @@ -24,14 +24,29 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c return; } + int action = 0; + + // pointer index + int pointerIndex = 0; + + if (from->key() == Qt::Key_W) { + pointerIndex = 0x0000; + } else if (from->key() == Qt::Key_D) { + pointerIndex = 0x0100; + } else { + return; + } + + + action |= pointerIndex; + // action - AndroidMotioneventAction action; switch (from->type()) { case QEvent::KeyPress: - action = AMOTION_EVENT_ACTION_DOWN; + action |= AMOTION_EVENT_ACTION_DOWN; break; case QEvent::KeyRelease: - action = AMOTION_EVENT_ACTION_UP; + action |= AMOTION_EVENT_ACTION_UP; break; default: return; @@ -51,7 +66,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c if (!controlEvent) { return; } - controlEvent->setMouseEventData(action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize)); + controlEvent->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize)); sendControlEvent(controlEvent); if (QEvent::KeyPress == from->type()) { @@ -60,7 +75,9 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c return; } pos.setY(pos.y() - 50); - controlEvent2->setMouseEventData(AMOTION_EVENT_ACTION_MOVE, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize)); + action &= AMOTION_EVENT_ACTION_POINTER_INDEX_MASK; + action |= AMOTION_EVENT_ACTION_MOVE; + controlEvent2->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize)); sendControlEvent(controlEvent2); } }