按键探头映射

This commit is contained in:
Barry 2018-11-13 21:20:47 +08:00
parent 148fc8211a
commit f58ed26cfe

View file

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