mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 14:18:45 +00:00
Merge branch 'master' of https://gitee.com/Barryda/QtScrcpy
# Conflicts: # src/inputcontrol/inputconvertgame.cpp
This commit is contained in:
commit
62465235f1
2 changed files with 35 additions and 17 deletions
|
@ -234,23 +234,23 @@ void InputConvertGame::steerWheelMove(int keysNum, int keyPress1, int keyPress2)
|
||||||
switch (keysNum) {
|
switch (keysNum) {
|
||||||
case 2:
|
case 2:
|
||||||
if (keyPress2 == SWD_UP) {
|
if (keyPress2 == SWD_UP) {
|
||||||
movePos.setY(movePos.y() - m_steerWheelOffset.y());
|
movePos.setY(movePos.y() - m_steerWheelOffset.top());
|
||||||
} else if (keyPress2 == SWD_RIGHT) {
|
} else if (keyPress2 == SWD_RIGHT) {
|
||||||
movePos.setX(movePos.x() + m_steerWheelOffset.x());
|
movePos.setX(movePos.x() + m_steerWheelOffset.right());
|
||||||
} else if (keyPress2 == SWD_DOWN) {
|
} else if (keyPress2 == SWD_DOWN) {
|
||||||
movePos.setY(movePos.y() + m_steerWheelOffset.y());
|
movePos.setY(movePos.y() + m_steerWheelOffset.bottom());
|
||||||
} else if (keyPress2 == SWD_LEFT) {
|
} else if (keyPress2 == SWD_LEFT) {
|
||||||
movePos.setX(movePos.x() - m_steerWheelOffset.x());
|
movePos.setX(movePos.x() - m_steerWheelOffset.left());
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
if (keyPress1 == SWD_UP) {
|
if (keyPress1 == SWD_UP) {
|
||||||
movePos.setY(movePos.y() - m_steerWheelOffset.y());
|
movePos.setY(movePos.y() - m_steerWheelOffset.top());
|
||||||
} else if (keyPress1 == SWD_RIGHT) {
|
} else if (keyPress1 == SWD_RIGHT) {
|
||||||
movePos.setX(movePos.x() + m_steerWheelOffset.x());
|
movePos.setX(movePos.x() + m_steerWheelOffset.right());
|
||||||
} else if (keyPress1 == SWD_DOWN) {
|
} else if (keyPress1 == SWD_DOWN) {
|
||||||
movePos.setY(movePos.y() + m_steerWheelOffset.y());
|
movePos.setY(movePos.y() + m_steerWheelOffset.bottom());
|
||||||
} else if (keyPress1 == SWD_LEFT) {
|
} else if (keyPress1 == SWD_LEFT) {
|
||||||
movePos.setX(movePos.x() - m_steerWheelOffset.x());
|
movePos.setX(movePos.x() - m_steerWheelOffset.left());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ void InputConvertGame::steerWheelMove(int keysNum, int keyPress1, int keyPress2)
|
||||||
bool InputConvertGame::processKeyClick(const QKeyEvent *from)
|
bool InputConvertGame::processKeyClick(const QKeyEvent *from)
|
||||||
{
|
{
|
||||||
QPointF clickPos;
|
QPointF clickPos;
|
||||||
bool touchTwice = false;
|
bool clickTwice = false;
|
||||||
switch (from->key()) {
|
switch (from->key()) {
|
||||||
case Qt::Key_Space: // 跳
|
case Qt::Key_Space: // 跳
|
||||||
clickPos = QPointF(0.96f, 0.7f);
|
clickPos = QPointF(0.96f, 0.7f);
|
||||||
|
@ -292,13 +292,31 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from)
|
||||||
case Qt::Key_H: // 捡东西3
|
case Qt::Key_H: // 捡东西3
|
||||||
clickPos = QPointF(0.7f, 0.54f);
|
clickPos = QPointF(0.7f, 0.54f);
|
||||||
break;
|
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: // 左探头
|
case Qt::Key_Q: // 左探头
|
||||||
touchTwice = true;
|
clickTwice = true;
|
||||||
clickPos = QPointF(0.2f, 0.54f);
|
clickPos = QPointF(0.12f, 0.35f);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_E: // 右探头
|
case Qt::Key_E: // 右探头
|
||||||
touchTwice = true;
|
clickTwice = true;
|
||||||
clickPos = QPointF(0.3f, 0.54f);
|
clickPos = QPointF(0.2, 0.35f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -308,12 +326,12 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from)
|
||||||
if (QEvent::KeyPress == from->type()) {
|
if (QEvent::KeyPress == from->type()) {
|
||||||
int id = attachTouchID(from->key());
|
int id = attachTouchID(from->key());
|
||||||
sendTouchDownEvent(id, clickPos);
|
sendTouchDownEvent(id, clickPos);
|
||||||
if (touchTwice) {
|
if (clickTwice) {
|
||||||
sendTouchUpEvent(getTouchID(from->key()), clickPos);
|
sendTouchUpEvent(getTouchID(from->key()), clickPos);
|
||||||
detachTouchID(from->key());
|
detachTouchID(from->key());
|
||||||
}
|
}
|
||||||
} else if (QEvent::KeyRelease == from->type()) {
|
} else if (QEvent::KeyRelease == from->type()) {
|
||||||
if (touchTwice) {
|
if (clickTwice) {
|
||||||
int id = attachTouchID(from->key());
|
int id = attachTouchID(from->key());
|
||||||
sendTouchDownEvent(id, clickPos);
|
sendTouchDownEvent(id, clickPos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ private:
|
||||||
|
|
||||||
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
||||||
|
|
||||||
QPointF m_steerWheelPos = {0.16f, 0.75f};
|
QPointF m_steerWheelPos = {0.16f, 0.75f};
|
||||||
QPointF m_steerWheelOffset = {0.1f, 0.2f};
|
QRectF m_steerWheelOffset = {QPointF(0.1f, 0.27f), QPointF(0.1f, 0.2f)};
|
||||||
// order by SteerWheelDirection(up right down left)
|
// order by SteerWheelDirection(up right down left)
|
||||||
int m_steerWheelKeys[4] = {Qt::Key_W, Qt::Key_D, Qt::Key_S, Qt::Key_A};
|
int m_steerWheelKeys[4] = {Qt::Key_W, Qt::Key_D, Qt::Key_S, Qt::Key_A};
|
||||||
bool m_steerWheelKeysPress[4] = { false };
|
bool m_steerWheelKeysPress[4] = { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue