diff --git a/src/inputcontrol/inputconvertgame.cpp b/src/inputcontrol/inputconvertgame.cpp index e259d8d..b7662cc 100644 --- a/src/inputcontrol/inputconvertgame.cpp +++ b/src/inputcontrol/inputconvertgame.cpp @@ -25,14 +25,20 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c } int action = 0; + // pos + QPointF pos; // pointer index int pointerIndex = 0; if (from->key() == Qt::Key_W) { pointerIndex = 0x0000; + pos.setX(showSize.width() * 0.25f); + pos.setY(showSize.height() * 0.5f); } else if (from->key() == Qt::Key_D) { pointerIndex = 0x0100; + pos.setX(showSize.width() * 0.5f); + pos.setY(showSize.height() * 0.25f); } else { return; } @@ -43,19 +49,22 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c // action switch (from->type()) { case QEvent::KeyPress: - action |= AMOTION_EVENT_ACTION_DOWN; + if (from->key() == Qt::Key_W) { + action |= AMOTION_EVENT_ACTION_DOWN; + } else { + action |= AMOTION_EVENT_ACTION_POINTER_DOWN; + } break; case QEvent::KeyRelease: - action |= AMOTION_EVENT_ACTION_UP; + if (from->key() == Qt::Key_W) { + action |= AMOTION_EVENT_ACTION_UP; + } else { + action |= AMOTION_EVENT_ACTION_POINTER_UP; + } break; default: return; - } - - // pos - QPointF pos; - pos.setX(showSize.width() * 0.25f); - pos.setY(showSize.height() * 0.5f); + } // convert pos pos.setX(pos.x() * frameSize.width() / showSize.width()); @@ -68,6 +77,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c } controlEvent->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize)); sendControlEvent(controlEvent); + return; if (QEvent::KeyPress == from->type()) { ControlEvent* controlEvent2 = new ControlEvent(ControlEvent::CET_MOUSE);