常规更新

This commit is contained in:
Barry 2018-11-11 00:09:10 +08:00
parent 297381defc
commit 4e386e879e

View file

@ -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);