mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 11:35:56 +00:00
Merge pull request #25 from barry-ran/feat-keymapscript
feat: keymapscript
This commit is contained in:
commit
79f874654f
15 changed files with 1193 additions and 434 deletions
|
@ -7,13 +7,15 @@
|
|||
#include "receiver.h"
|
||||
#include "inputconvertgame.h"
|
||||
|
||||
Controller::Controller(bool supportGame, QObject* parent) : QObject(parent)
|
||||
Controller::Controller(QString gameScript, QObject* parent) : QObject(parent)
|
||||
{
|
||||
m_receiver = new Receiver(this);
|
||||
Q_ASSERT(m_receiver);
|
||||
|
||||
if (supportGame) {
|
||||
m_inputConvert = new InputConvertGame(this);
|
||||
if (!gameScript.isEmpty()) {
|
||||
InputConvertGame* convertgame = new InputConvertGame(this);
|
||||
convertgame->loadKeyMap(gameScript);
|
||||
m_inputConvert = convertgame;
|
||||
} else {
|
||||
m_inputConvert = new InputConvertNormal(this);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class Controller : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Controller(bool supportGame = false, QObject* parent = Q_NULLPTR);
|
||||
Controller(QString gameScript = "", QObject* parent = Q_NULLPTR);
|
||||
virtual ~Controller();
|
||||
|
||||
void setControlSocket(QTcpSocket* controlSocket);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
InputConvertGame::InputConvertGame(Controller* controller)
|
||||
: InputConvertNormal(controller)
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,14 @@ void InputConvertGame::mouseEvent(const QMouseEvent *from, const QSize &frameSiz
|
|||
if (m_gameMap) {
|
||||
updateSize(frameSize, showSize);
|
||||
|
||||
// mouse move
|
||||
if (processMouseMove(from)) {
|
||||
return;
|
||||
if (m_keyMap.enableMouseMoveMap()) {
|
||||
// mouse move
|
||||
if (processMouseMove(from)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mouse click
|
||||
if (processMouseClick(from)) {
|
||||
return;
|
||||
|
@ -47,8 +50,8 @@ void InputConvertGame::wheelEvent(const QWheelEvent *from, const QSize &frameSiz
|
|||
|
||||
void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, const QSize& showSize)
|
||||
{
|
||||
switch (from->key()) {
|
||||
case Qt::Key_QuoteLeft:
|
||||
// 处理开关按键
|
||||
if (m_keyMap.getSwitchKey() == from->key()) {
|
||||
if (QEvent::KeyPress == from->type()) {
|
||||
if (!switchGameMap()) {
|
||||
m_needSwitchGameAgain = false;
|
||||
|
@ -57,12 +60,16 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_needSwitchGameAgain) {
|
||||
KeyMap::KeyMapNode& node = m_keyMap.getKeyMapNode(from->key());
|
||||
// 处理特殊按键:可以在按键映射和普通映射间切换的按键
|
||||
if (m_needSwitchGameAgain
|
||||
&& KeyMap::KMT_CLICK == node.type
|
||||
&& node.click.switchMap) {
|
||||
updateSize(frameSize, showSize);
|
||||
// Qt::Key_Tab Qt::Key_M
|
||||
if (processKeyClick(from)) {
|
||||
return;
|
||||
}
|
||||
processKeyClick(node.click.keyNode.pos, false,
|
||||
node.click.switchMap, from);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_gameMap) {
|
||||
|
@ -71,14 +78,20 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
|||
return;
|
||||
}
|
||||
|
||||
// steer wheel
|
||||
if (isSteerWheelKeys(from)) {
|
||||
processSteerWheel(from);
|
||||
// 处理方向盘
|
||||
if (KeyMap::KMT_STEER_WHEEL == node.type) {
|
||||
processSteerWheel(node, from);
|
||||
return;
|
||||
}
|
||||
|
||||
// key click
|
||||
if (processKeyClick(from)) {
|
||||
// 处理普通按键
|
||||
switch (node.type) {
|
||||
case KeyMap::KMT_CLICK:
|
||||
processKeyClick(node.click.keyNode.pos, false,
|
||||
node.click.switchMap, from);
|
||||
return;
|
||||
case KeyMap::KMT_CLICK_TWICE:
|
||||
processKeyClick(node.clickTwice.keyNode.pos, true, false, from);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -86,6 +99,14 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
|||
}
|
||||
}
|
||||
|
||||
void InputConvertGame::loadKeyMap(const QString &json)
|
||||
{
|
||||
m_keyMap.loadKeyMap(json);
|
||||
if (m_keyMap.enableMouseMoveMap()) {
|
||||
m_mouseMoveLastConverPos = m_keyMap.getMouseMoveMap().startPos;
|
||||
}
|
||||
}
|
||||
|
||||
void InputConvertGame::updateSize(const QSize &frameSize, const QSize &showSize)
|
||||
{
|
||||
m_frameSize = frameSize;
|
||||
|
@ -159,49 +180,40 @@ int InputConvertGame::getTouchID(int key)
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool InputConvertGame::isSteerWheelKeys(const QKeyEvent *from)
|
||||
{
|
||||
for (int key : m_steerWheelKeys) {
|
||||
if (key == from->key()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InputConvertGame::processSteerWheel(const QKeyEvent *from)
|
||||
void InputConvertGame::processSteerWheel(KeyMap::KeyMapNode &node, const QKeyEvent *from)
|
||||
{
|
||||
int keyPress1 = -1;
|
||||
int keyPress2 = -1;
|
||||
int keysNum = updateSteerWheelKeysPress(from, keyPress1, keyPress2);
|
||||
int keyPress1 = Qt::Key_unknown;
|
||||
int keyPress2 = Qt::Key_unknown;
|
||||
int keysNum = updateSteerWheelKeysPress(node, from, keyPress1, keyPress2);
|
||||
bool needMove = false;
|
||||
if (QEvent::KeyPress == from->type()) {
|
||||
if (1 == keysNum) {
|
||||
m_steerWheelFirstTouchKey = from->key();
|
||||
int id = attachTouchID(m_steerWheelFirstTouchKey);
|
||||
node.steerWheel.firstPressKey = from->key();
|
||||
int id = attachTouchID(node.steerWheel.firstPressKey);
|
||||
if (-1 == id) {
|
||||
return;
|
||||
}
|
||||
sendTouchDownEvent(id, m_steerWheelPos);
|
||||
}
|
||||
sendTouchDownEvent(id, node.steerWheel.centerPos);
|
||||
needMove = true;
|
||||
} else if (2 == keysNum) {
|
||||
needMove = true;
|
||||
}
|
||||
} else if (QEvent::KeyRelease == from->type()){
|
||||
if (0 == keysNum) {
|
||||
sendTouchUpEvent(getTouchID(m_steerWheelFirstTouchKey), m_steerWheelPos);
|
||||
detachTouchID(m_steerWheelFirstTouchKey);
|
||||
m_steerWheelFirstTouchKey = 0;
|
||||
int id = getTouchID(node.steerWheel.firstPressKey);
|
||||
sendTouchUpEvent(id, node.steerWheel.centerPos);
|
||||
detachTouchID(node.steerWheel.firstPressKey);
|
||||
node.steerWheel.firstPressKey = 0;
|
||||
} else if (1 == keysNum) {
|
||||
needMove = true;
|
||||
}
|
||||
}
|
||||
if (needMove) {
|
||||
steerWheelMove(keysNum, keyPress1, keyPress2);
|
||||
steerWheelMove(node, keysNum, keyPress1, keyPress2);
|
||||
}
|
||||
}
|
||||
|
||||
int InputConvertGame::updateSteerWheelKeysPress(const QKeyEvent *from, int& keyPress1, int& keyPress2)
|
||||
int InputConvertGame::updateSteerWheelKeysPress(KeyMap::KeyMapNode &node, const QKeyEvent *from, int& keyPress1, int& keyPress2)
|
||||
{
|
||||
bool keyPress = false;
|
||||
if (QEvent::KeyPress == from->type()) {
|
||||
|
@ -209,146 +221,93 @@ int InputConvertGame::updateSteerWheelKeysPress(const QKeyEvent *from, int& keyP
|
|||
} else if (QEvent::KeyRelease == from->type()) {
|
||||
keyPress = false;
|
||||
}
|
||||
if (from->key() == m_steerWheelKeys[SWD_UP]) {
|
||||
m_steerWheelKeysPress[SWD_UP] = keyPress;
|
||||
} else if (from->key() == m_steerWheelKeys[SWD_RIGHT]) {
|
||||
m_steerWheelKeysPress[SWD_RIGHT] = keyPress;
|
||||
} else if (from->key() == m_steerWheelKeys[SWD_DOWN]) {
|
||||
m_steerWheelKeysPress[SWD_DOWN] = keyPress;
|
||||
} else if (from->key() == m_steerWheelKeys[SWD_LEFT]) {
|
||||
m_steerWheelKeysPress[SWD_LEFT] = keyPress;
|
||||
if (from->key() == node.steerWheel.upKey) {
|
||||
node.steerWheel.upKeyPressed = keyPress;
|
||||
} else if (from->key() == node.steerWheel.rightKey) {
|
||||
node.steerWheel.rightKeyPressed = keyPress;
|
||||
} else if (from->key() == node.steerWheel.downKey) {
|
||||
node.steerWheel.downKeyPressed = keyPress;
|
||||
} else if (from->key() == node.steerWheel.leftKey) {
|
||||
node.steerWheel.leftKeyPressed = keyPress;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
keyPress1 = -1;
|
||||
keyPress2 = -1;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (true == m_steerWheelKeysPress[i]) {
|
||||
count++;
|
||||
keyPress1 = Qt::Key_unknown;
|
||||
keyPress2 = Qt::Key_unknown;
|
||||
|
||||
if (-1 == keyPress1) {
|
||||
keyPress1 = i;
|
||||
} else if (-1 == keyPress2) {
|
||||
keyPress2 = i;
|
||||
}
|
||||
// 上右下左的顺序统计按键数量,并记录前两个按键码
|
||||
if (node.steerWheel.upKeyPressed) {
|
||||
count++;
|
||||
if (Qt::Key_unknown == keyPress1) {
|
||||
keyPress1 = node.steerWheel.upKey;
|
||||
} else if (Qt::Key_unknown == keyPress2) {
|
||||
keyPress2 = node.steerWheel.upKey;
|
||||
}
|
||||
}
|
||||
if (node.steerWheel.rightKeyPressed) {
|
||||
count++;
|
||||
if (Qt::Key_unknown == keyPress1) {
|
||||
keyPress1 = node.steerWheel.rightKey;
|
||||
} else if (Qt::Key_unknown == keyPress2) {
|
||||
keyPress2 = node.steerWheel.rightKey;
|
||||
}
|
||||
}
|
||||
if (node.steerWheel.downKeyPressed) {
|
||||
count++;
|
||||
if (Qt::Key_unknown == keyPress1) {
|
||||
keyPress1 = node.steerWheel.downKey;
|
||||
} else if (Qt::Key_unknown == keyPress2) {
|
||||
keyPress2 = node.steerWheel.downKey;
|
||||
}
|
||||
}
|
||||
if (node.steerWheel.leftKeyPressed) {
|
||||
count++;
|
||||
if (Qt::Key_unknown == keyPress1) {
|
||||
keyPress1 = node.steerWheel.leftKey;
|
||||
} else if (Qt::Key_unknown == keyPress2) {
|
||||
keyPress2 = node.steerWheel.leftKey;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void InputConvertGame::steerWheelMove(int keysNum, int keyPress1, int keyPress2)
|
||||
void InputConvertGame::steerWheelMove(KeyMap::KeyMapNode &node, int keysNum, int keyPress1, int keyPress2)
|
||||
{
|
||||
if (1 != keysNum && 2 != keysNum) {
|
||||
return;
|
||||
}
|
||||
QPointF movePos = m_steerWheelPos;
|
||||
QPointF movePos = node.steerWheel.centerPos;
|
||||
switch (keysNum) {
|
||||
case 2:
|
||||
if (keyPress2 == SWD_UP) {
|
||||
movePos.setY(movePos.y() - m_steerWheelOffset.top());
|
||||
} else if (keyPress2 == SWD_RIGHT) {
|
||||
movePos.setX(movePos.x() + m_steerWheelOffset.right());
|
||||
} else if (keyPress2 == SWD_DOWN) {
|
||||
movePos.setY(movePos.y() + m_steerWheelOffset.bottom());
|
||||
} else if (keyPress2 == SWD_LEFT) {
|
||||
movePos.setX(movePos.x() - m_steerWheelOffset.left());
|
||||
if (keyPress2 == node.steerWheel.upKey) {
|
||||
movePos.setY(movePos.y() - node.steerWheel.upOffset);
|
||||
} else if (keyPress2 == node.steerWheel.rightKey) {
|
||||
movePos.setX(movePos.x() + node.steerWheel.rightOffset);
|
||||
} else if (keyPress2 == node.steerWheel.downKey) {
|
||||
movePos.setY(movePos.y() + node.steerWheel.downOffset);
|
||||
} else if (keyPress2 == node.steerWheel.leftKey) {
|
||||
movePos.setX(movePos.x() - node.steerWheel.leftOffset);
|
||||
}
|
||||
case 1:
|
||||
if (keyPress1 == SWD_UP) {
|
||||
movePos.setY(movePos.y() - m_steerWheelOffset.top());
|
||||
} else if (keyPress1 == SWD_RIGHT) {
|
||||
movePos.setX(movePos.x() + m_steerWheelOffset.right());
|
||||
} else if (keyPress1 == SWD_DOWN) {
|
||||
movePos.setY(movePos.y() + m_steerWheelOffset.bottom());
|
||||
} else if (keyPress1 == SWD_LEFT) {
|
||||
movePos.setX(movePos.x() - m_steerWheelOffset.left());
|
||||
if (keyPress1 == node.steerWheel.upKey) {
|
||||
movePos.setY(movePos.y() - node.steerWheel.upOffset);
|
||||
} else if (keyPress1 == node.steerWheel.rightKey) {
|
||||
movePos.setX(movePos.x() + node.steerWheel.rightOffset);
|
||||
} else if (keyPress1 == node.steerWheel.downKey) {
|
||||
movePos.setY(movePos.y() + node.steerWheel.downOffset);
|
||||
} else if (keyPress1 == node.steerWheel.leftKey) {
|
||||
movePos.setX(movePos.x() - node.steerWheel.leftOffset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
sendTouchMoveEvent(getTouchID(m_steerWheelFirstTouchKey), movePos);
|
||||
sendTouchMoveEvent(getTouchID(node.steerWheel.firstPressKey), movePos);
|
||||
}
|
||||
|
||||
bool InputConvertGame::processKeyClick(const QKeyEvent *from)
|
||||
void InputConvertGame::processKeyClick(QPointF clickPos, bool clickTwice, bool switchMap, const QKeyEvent *from)
|
||||
{
|
||||
QPointF clickPos;
|
||||
bool clickTwice = false;
|
||||
switch (from->key()) {
|
||||
case Qt::Key_Space: // 跳
|
||||
clickPos = QPointF(0.96f, 0.7f);
|
||||
break;
|
||||
case Qt::Key_M: // 地图
|
||||
if (QEvent::KeyRelease == from->type()) {
|
||||
m_needSwitchGameAgain = !m_needSwitchGameAgain;
|
||||
switchGameMap();
|
||||
}
|
||||
clickPos = QPointF(0.98f, 0.03f);
|
||||
break;
|
||||
case Qt::Key_Tab: // 背包
|
||||
if (QEvent::KeyRelease == from->type()) {
|
||||
m_needSwitchGameAgain = !m_needSwitchGameAgain;
|
||||
switchGameMap();
|
||||
}
|
||||
clickPos = QPointF(0.06f, 0.9f);
|
||||
break;
|
||||
case Qt::Key_Z: // 趴
|
||||
clickPos = QPointF(0.95f, 0.9f);
|
||||
break;
|
||||
case Qt::Key_C: // 蹲
|
||||
clickPos = QPointF(0.86f, 0.92f);
|
||||
break;
|
||||
case Qt::Key_R: // 换弹
|
||||
clickPos = QPointF(0.795f, 0.93f);
|
||||
break;
|
||||
case Qt::Key_Alt: // 小眼睛
|
||||
clickPos = QPointF(0.8f, 0.31f);
|
||||
break;
|
||||
case Qt::Key_F: // 捡东西1
|
||||
clickPos = QPointF(0.7f, 0.34f);
|
||||
break;
|
||||
case Qt::Key_G: // 捡东西2
|
||||
clickPos = QPointF(0.7f, 0.44f);
|
||||
break;
|
||||
case Qt::Key_H: // 捡东西3
|
||||
clickPos = QPointF(0.7f, 0.54f);
|
||||
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_4: // 快速打药
|
||||
clickPos = QPointF(0.33f, 0.95f);
|
||||
break;
|
||||
case Qt::Key_5: // 下车
|
||||
clickPos = QPointF(0.92f, 0.4f);
|
||||
break;
|
||||
case Qt::Key_6: // 救人
|
||||
clickPos = QPointF(0.49f, 0.63f);
|
||||
break;
|
||||
case Qt::Key_Shift: // 车加速
|
||||
clickPos = QPointF(0.82f, 0.8f);
|
||||
break;
|
||||
case Qt::Key_X: // 开关门
|
||||
clickPos = QPointF(0.7f, 0.7f);
|
||||
break;
|
||||
case Qt::Key_T: // 舔包
|
||||
clickPos = QPointF(0.72f, 0.26f);
|
||||
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;
|
||||
if (switchMap && QEvent::KeyRelease == from->type()) {
|
||||
m_needSwitchGameAgain = !m_needSwitchGameAgain;
|
||||
switchGameMap();
|
||||
}
|
||||
|
||||
if (QEvent::KeyPress == from->type()) {
|
||||
|
@ -366,25 +325,20 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from)
|
|||
sendTouchUpEvent(getTouchID(from->key()), clickPos);
|
||||
detachTouchID(from->key());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InputConvertGame::processMouseClick(const QMouseEvent *from)
|
||||
{
|
||||
QPointF clickPos;
|
||||
if (Qt::LeftButton == from->button()) {
|
||||
clickPos = QPointF(0.86f, 0.72f);
|
||||
} else if (Qt::RightButton == from->button()){
|
||||
clickPos = QPointF(0.96f, 0.52f);
|
||||
} else {
|
||||
KeyMap::KeyMapNode& node = m_keyMap.getKeyMapNode(from->button());
|
||||
if (KeyMap::KMT_INVALID == node.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (QEvent::MouseButtonPress == from->type() || QEvent::MouseButtonDblClick == from->type()) {
|
||||
int id = attachTouchID(from->button());
|
||||
sendTouchDownEvent(id, clickPos);
|
||||
sendTouchDownEvent(id, node.click.keyNode.pos);
|
||||
} else if (QEvent::MouseButtonRelease == from->type()) {
|
||||
sendTouchUpEvent(getTouchID(from->button()), clickPos);
|
||||
sendTouchUpEvent(getTouchID(from->button()), node.click.keyNode.pos);
|
||||
detachTouchID(from->button());
|
||||
} else {
|
||||
return false;
|
||||
|
@ -405,7 +359,7 @@ bool InputConvertGame::processMouseMove(const QMouseEvent *from)
|
|||
|
||||
if (!m_mouseMoveLastPos.isNull()) {
|
||||
QPointF distance = from->localPos() - m_mouseMoveLastPos;
|
||||
distance /= 10;
|
||||
distance /= m_keyMap.getMouseMoveMap().speedRatio;
|
||||
|
||||
mouseMoveStartTouch(from);
|
||||
startMouseMoveTimer();
|
||||
|
@ -429,7 +383,8 @@ bool InputConvertGame::processMouseMove(const QMouseEvent *from)
|
|||
|
||||
void InputConvertGame::moveCursorToStart(const QMouseEvent *from)
|
||||
{
|
||||
QPoint localPos = QPoint(m_showSize.width()*m_mouseMoveStartPos.x(), m_showSize.height()*m_mouseMoveStartPos.y());
|
||||
QPointF mouseMoveStartPos = m_keyMap.getMouseMoveMap().startPos;
|
||||
QPoint localPos = QPoint(m_showSize.width()*mouseMoveStartPos.x(), m_showSize.height()*mouseMoveStartPos.y());
|
||||
QPoint posOffset = from->localPos().toPoint() - localPos;
|
||||
QPoint globalPos = from->globalPos();
|
||||
|
||||
|
@ -464,10 +419,11 @@ void InputConvertGame::mouseMoveStartTouch(const QMouseEvent* from)
|
|||
{
|
||||
Q_UNUSED(from);
|
||||
if (!m_mouseMovePress) {
|
||||
QPointF mouseMoveStartPos = m_keyMap.getMouseMoveMap().startPos;
|
||||
//moveCursorToStart(from);
|
||||
int id = attachTouchID(Qt::ExtraButton24);
|
||||
sendTouchDownEvent(id, m_mouseMoveStartPos);
|
||||
m_mouseMoveLastConverPos = m_mouseMoveStartPos;
|
||||
sendTouchDownEvent(id, mouseMoveStartPos);
|
||||
m_mouseMoveLastConverPos = mouseMoveStartPos;
|
||||
m_mouseMovePress = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#define INPUTCONVERTGAME_H
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
#include "inputconvertnormal.h"
|
||||
#include "keymap.h"
|
||||
|
||||
#define MULTI_TOUCH_MAX_NUM 10
|
||||
class InputConvertGame : public InputConvertNormal
|
||||
|
@ -16,6 +18,8 @@ public:
|
|||
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
|
||||
void loadKeyMap(const QString& json);
|
||||
|
||||
protected:
|
||||
void updateSize(const QSize& frameSize, const QSize& showSize);
|
||||
void sendTouchDownEvent(int id, QPointF pos);
|
||||
|
@ -30,13 +34,12 @@ protected:
|
|||
int getTouchID(int key);
|
||||
|
||||
// steer wheel
|
||||
bool isSteerWheelKeys(const QKeyEvent* from);
|
||||
void processSteerWheel(const QKeyEvent* from);
|
||||
int updateSteerWheelKeysPress(const QKeyEvent* from, int& keyPress1, int& keyPress2);
|
||||
void steerWheelMove(int keysNum, int keyPress1, int keyPress2);
|
||||
void processSteerWheel(KeyMap::KeyMapNode &node, const QKeyEvent* from);
|
||||
int updateSteerWheelKeysPress(KeyMap::KeyMapNode &node, const QKeyEvent* from, int& keyPress1, int& keyPress2);
|
||||
void steerWheelMove(KeyMap::KeyMapNode &node, int keysNum, int keyPress1, int keyPress2);
|
||||
|
||||
// click
|
||||
bool processKeyClick(const QKeyEvent* from);
|
||||
void processKeyClick(QPointF clickPos, bool clickTwice, bool switchMap, const QKeyEvent* from);
|
||||
|
||||
// mouse
|
||||
bool processMouseClick(const QMouseEvent* from);
|
||||
|
@ -67,24 +70,17 @@ private:
|
|||
QSize m_showSize;
|
||||
bool m_gameMap = false;
|
||||
|
||||
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
||||
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
||||
|
||||
QPointF m_steerWheelPos = {0.16f, 0.75f};
|
||||
QRectF m_steerWheelOffset = {QPointF(0.1f, 0.27f), QPointF(0.1f, 0.2f)};
|
||||
// order by SteerWheelDirection(up right down left)
|
||||
int m_steerWheelKeys[4] = {Qt::Key_W, Qt::Key_D, Qt::Key_S, Qt::Key_A};
|
||||
bool m_steerWheelKeysPress[4] = { false };
|
||||
int m_steerWheelKeysNum = 0;
|
||||
int m_steerWheelFirstTouchKey = 0;
|
||||
|
||||
// mouse move
|
||||
QPointF m_mouseMoveStartPos = {0.57f, 0.26f};
|
||||
QPointF m_mouseMoveLastConverPos = m_mouseMoveStartPos;
|
||||
// mouse move
|
||||
QPointF m_mouseMoveLastConverPos;
|
||||
QPointF m_mouseMoveLastPos = {0.0f, 0.0f};
|
||||
bool m_mouseMovePress = false;
|
||||
int m_mouseMoveTimer = 0;
|
||||
|
||||
bool m_needSwitchGameAgain = false;
|
||||
|
||||
KeyMap m_keyMap;
|
||||
};
|
||||
|
||||
#endif // INPUTCONVERTGAME_H
|
||||
|
|
|
@ -1,39 +1,308 @@
|
|||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QMetaEnum>
|
||||
#include <QFileInfo>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include "keymap.h"
|
||||
|
||||
KeyMap::KeyMap()
|
||||
QString KeyMap::s_keyMapPath = "";
|
||||
|
||||
KeyMap::KeyMap(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KeyMap::loadKeyMapNode()
|
||||
KeyMap::~KeyMap()
|
||||
{
|
||||
KeyMapNode node;
|
||||
node.type = KMT_CLICK;
|
||||
node.click.keyNode.key = Qt::Key_J;
|
||||
node.click.keyNode.pos = QPointF(0.5f, 0.5f);
|
||||
node.click.quitMap = false;
|
||||
|
||||
m_keyMapNodes.push_back(node);
|
||||
}
|
||||
|
||||
KeyMap::KeyMapNode KeyMap::getKeyMapNode(int key)
|
||||
const QString& KeyMap::getKeyMapPath()
|
||||
{
|
||||
KeyMapNode retNode;
|
||||
bool find = false;
|
||||
for (auto& node : m_keyMapNodes) {
|
||||
switch (node.type) {
|
||||
if (s_keyMapPath.isEmpty()) {
|
||||
s_keyMapPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_KEYMAP_PATH"));
|
||||
QFileInfo fileInfo(s_keyMapPath);
|
||||
if (s_keyMapPath.isEmpty() || !fileInfo.isDir()) {
|
||||
s_keyMapPath = QCoreApplication::applicationDirPath() + "/keymap";
|
||||
}
|
||||
}
|
||||
return s_keyMapPath;
|
||||
}
|
||||
|
||||
void KeyMap::loadKeyMap(const QString &json)
|
||||
{
|
||||
QString errorString;
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument jsonDoc;
|
||||
QJsonObject rootObj;
|
||||
|
||||
QMetaEnum metaEnumKey = QMetaEnum::fromType<Qt::Key>();
|
||||
QMetaEnum metaEnumMouseButtons = QMetaEnum::fromType<Qt::MouseButtons>();
|
||||
QMetaEnum metaEnumKeyMapType = QMetaEnum::fromType<KeyMap::KeyMapType>();
|
||||
|
||||
jsonDoc = QJsonDocument::fromJson(json.toUtf8(), &jsonError);
|
||||
|
||||
if(jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
errorString = QString("json error: %1").arg(jsonError.errorString());
|
||||
goto parseError;
|
||||
}
|
||||
|
||||
// switchKey
|
||||
rootObj = jsonDoc.object();
|
||||
if (rootObj.contains("switchKey") && rootObj.value("switchKey").isString()) {
|
||||
Qt::Key key = (Qt::Key)metaEnumKey.keyToValue(rootObj.value("switchKey").toString().toStdString().c_str());
|
||||
if (-1 == key) {
|
||||
errorString = QString("json error: switchKey invalid");
|
||||
goto parseError;
|
||||
}
|
||||
m_switchKey = key;
|
||||
} else {
|
||||
errorString = QString("json error: no find switchKey");
|
||||
goto parseError;
|
||||
}
|
||||
|
||||
// mouseMoveMap
|
||||
if (rootObj.contains("mouseMoveMap") && rootObj.value("mouseMoveMap").isObject()) {
|
||||
QJsonObject mouseMoveMap = rootObj.value("mouseMoveMap").toObject();
|
||||
if (mouseMoveMap.contains("speedRatio") && mouseMoveMap.value("speedRatio").isDouble()) {
|
||||
m_mouseMoveMap.speedRatio = mouseMoveMap.value("speedRatio").toInt();
|
||||
} else {
|
||||
errorString = QString("json error: mouseMoveMap on find speedRatio");
|
||||
goto parseError;
|
||||
}
|
||||
if (mouseMoveMap.contains("startPos") && mouseMoveMap.value("startPos").isObject()) {
|
||||
QJsonObject startPos = mouseMoveMap.value("startPos").toObject();
|
||||
if (startPos.contains("x") && startPos.value("x").isDouble()) {
|
||||
m_mouseMoveMap.startPos.setX(startPos.value("x").toDouble());
|
||||
}
|
||||
if (startPos.contains("y") && startPos.value("y").isDouble()) {
|
||||
m_mouseMoveMap.startPos.setY(startPos.value("y").toDouble());
|
||||
}
|
||||
} else {
|
||||
errorString = QString("json error: mouseMoveMap on find startPos");
|
||||
goto parseError;
|
||||
}
|
||||
}
|
||||
|
||||
// keyMapNodes
|
||||
if (rootObj.contains("keyMapNodes") && rootObj.value("keyMapNodes").isArray()) {
|
||||
QJsonArray keyMapNodes = rootObj.value("keyMapNodes").toArray();
|
||||
QJsonObject node;
|
||||
int size = keyMapNodes.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!keyMapNodes.at(i).isObject()) {
|
||||
errorString = QString("json error: keyMapNodes node must be json object");
|
||||
goto parseError;
|
||||
}
|
||||
node = keyMapNodes.at(i).toObject();
|
||||
if (!node.contains("type") || !node.value("type").isString()) {
|
||||
errorString = QString("json error: keyMapNodes no find node type");
|
||||
goto parseError;
|
||||
}
|
||||
|
||||
KeyMap::KeyMapType type = (KeyMap::KeyMapType)metaEnumKeyMapType.keyToValue(node.value("type").toString().toStdString().c_str());
|
||||
switch (type) {
|
||||
case KeyMap::KMT_CLICK:
|
||||
{
|
||||
// safe check
|
||||
if (!node.contains("key") || !node.value("key").isString()
|
||||
|| !node.contains("pos") || !node.value("pos").isObject()
|
||||
|| !node.value("pos").toObject().contains("x") || !node.value("pos").toObject().value("x").isDouble()
|
||||
|| !node.value("pos").toObject().contains("y") || !node.value("pos").toObject().value("y").isDouble()
|
||||
|| !node.contains("switchMap") || !node.value("switchMap").isBool()
|
||||
) {
|
||||
qWarning() << "json error: keyMapNodes node format error";
|
||||
break;
|
||||
}
|
||||
|
||||
Qt::Key key = (Qt::Key)metaEnumKey.keyToValue(node.value("key").toString().toStdString().c_str());
|
||||
Qt::MouseButtons btn = (Qt::MouseButtons)metaEnumMouseButtons.keyToValue(node.value("key").toString().toStdString().c_str());
|
||||
if (-1 == key && -1 == btn) {
|
||||
qWarning() << "json error: keyMapNodes node invalid key: " << node.value("key").toString();
|
||||
break;
|
||||
}
|
||||
|
||||
KeyMapNode keyMapNode;
|
||||
keyMapNode.type = type;
|
||||
if (key != -1) {
|
||||
keyMapNode.click.keyNode.key = key;
|
||||
} else {
|
||||
keyMapNode.click.keyNode.key = btn;
|
||||
}
|
||||
keyMapNode.click.keyNode.pos = QPointF(node.value("pos").toObject().value("x").toDouble(),
|
||||
node.value("pos").toObject().value("y").toDouble());
|
||||
keyMapNode.click.switchMap = node.value("switchMap").toBool();
|
||||
m_keyMapNodes.push_back(keyMapNode);
|
||||
}
|
||||
break;
|
||||
case KeyMap::KMT_CLICK_TWICE:
|
||||
{
|
||||
// safe check
|
||||
if (!node.contains("key") || !node.value("key").isString()
|
||||
|| !node.contains("pos") || !node.value("pos").isObject()
|
||||
|| !node.value("pos").toObject().contains("x") || !node.value("pos").toObject().value("x").isDouble()
|
||||
|| !node.value("pos").toObject().contains("y") || !node.value("pos").toObject().value("y").isDouble()
|
||||
) {
|
||||
qWarning() << "json error: keyMapNodes node format error";
|
||||
break;
|
||||
}
|
||||
|
||||
Qt::Key key = (Qt::Key)metaEnumKey.keyToValue(node.value("key").toString().toStdString().c_str());
|
||||
Qt::MouseButtons btn = (Qt::MouseButtons)metaEnumMouseButtons.keyToValue(node.value("key").toString().toStdString().c_str());
|
||||
if (-1 == key && -1 == btn) {
|
||||
qWarning() << "json error: keyMapNodes node invalid key: " << node.value("key").toString();
|
||||
break;
|
||||
}
|
||||
|
||||
KeyMapNode keyMapNode;
|
||||
keyMapNode.type = type;
|
||||
if (key != -1) {
|
||||
keyMapNode.clickTwice.keyNode.key = key;
|
||||
} else {
|
||||
keyMapNode.clickTwice.keyNode.key = btn;
|
||||
}
|
||||
keyMapNode.clickTwice.keyNode.pos = QPointF(node.value("pos").toObject().value("x").toDouble(),
|
||||
node.value("pos").toObject().value("y").toDouble());
|
||||
m_keyMapNodes.push_back(keyMapNode);
|
||||
}
|
||||
break;
|
||||
case KeyMap::KMT_STEER_WHEEL:
|
||||
{
|
||||
// safe check
|
||||
if (!node.contains("leftKey") || !node.value("leftKey").isString()
|
||||
|| !node.contains("rightKey") || !node.value("rightKey").isString()
|
||||
|| !node.contains("upKey") || !node.value("upKey").isString()
|
||||
|| !node.contains("downKey") || !node.value("downKey").isString()
|
||||
|| !node.contains("leftOffset") || !node.value("leftOffset").isDouble()
|
||||
|| !node.contains("rightOffset") || !node.value("rightOffset").isDouble()
|
||||
|| !node.contains("upOffset") || !node.value("upOffset").isDouble()
|
||||
|| !node.contains("downOffset") || !node.value("downOffset").isDouble()
|
||||
|| !node.contains("centerPos") || !node.value("centerPos").isObject()
|
||||
|| !node.value("centerPos").toObject().contains("x") || !node.value("centerPos").toObject().value("x").isDouble()
|
||||
|| !node.value("centerPos").toObject().contains("y") || !node.value("centerPos").toObject().value("y").isDouble()
|
||||
) {
|
||||
qWarning() << "json error: keyMapNodes node format error";
|
||||
break;
|
||||
}
|
||||
|
||||
Qt::Key leftKey = (Qt::Key)metaEnumKey.keyToValue(node.value("leftKey").toString().toStdString().c_str());
|
||||
Qt::MouseButtons leftBtn = (Qt::MouseButtons)metaEnumMouseButtons.keyToValue(node.value("leftKey").toString().toStdString().c_str());
|
||||
Qt::Key rightKey = (Qt::Key)metaEnumKey.keyToValue(node.value("rightKey").toString().toStdString().c_str());
|
||||
Qt::MouseButtons rightBtn = (Qt::MouseButtons)metaEnumMouseButtons.keyToValue(node.value("rightKey").toString().toStdString().c_str());
|
||||
Qt::Key upKey = (Qt::Key)metaEnumKey.keyToValue(node.value("upKey").toString().toStdString().c_str());
|
||||
Qt::MouseButtons upBtn = (Qt::MouseButtons)metaEnumMouseButtons.keyToValue(node.value("upKey").toString().toStdString().c_str());
|
||||
Qt::Key downKey = (Qt::Key)metaEnumKey.keyToValue(node.value("downKey").toString().toStdString().c_str());
|
||||
Qt::MouseButtons downBtn = (Qt::MouseButtons)metaEnumMouseButtons.keyToValue(node.value("downKey").toString().toStdString().c_str());
|
||||
|
||||
if ((-1 == leftKey && -1 == leftBtn)
|
||||
|| (-1 == rightKey && -1 == rightBtn)
|
||||
|| (-1 == upKey && -1 == upBtn)
|
||||
|| (-1 == downKey && -1 == downBtn)
|
||||
) {
|
||||
qWarning() << "json error: keyMapNodes node invalid key: " << node.value("key").toString();
|
||||
break;
|
||||
}
|
||||
|
||||
KeyMapNode keyMapNode;
|
||||
keyMapNode.type = type;
|
||||
keyMapNode.steerWheel.leftKeyPressed = false;
|
||||
keyMapNode.steerWheel.rightKeyPressed = false;
|
||||
keyMapNode.steerWheel.upKeyPressed = false;
|
||||
keyMapNode.steerWheel.downKeyPressed = false;
|
||||
keyMapNode.steerWheel.pressKeysNum = 0;
|
||||
keyMapNode.steerWheel.firstPressKey = 0;
|
||||
|
||||
if (leftKey != -1) {
|
||||
keyMapNode.steerWheel.leftKey = leftKey;
|
||||
} else {
|
||||
keyMapNode.steerWheel.leftKey = leftBtn;
|
||||
}
|
||||
if (rightKey != -1) {
|
||||
keyMapNode.steerWheel.rightKey = rightKey;
|
||||
} else {
|
||||
keyMapNode.steerWheel.rightKey = rightBtn;
|
||||
}
|
||||
if (upKey != -1) {
|
||||
keyMapNode.steerWheel.upKey = upKey;
|
||||
} else {
|
||||
keyMapNode.steerWheel.upKey = upBtn;
|
||||
}
|
||||
if (downKey != -1) {
|
||||
keyMapNode.steerWheel.downKey = downKey;
|
||||
} else {
|
||||
keyMapNode.steerWheel.downKey = downBtn;
|
||||
}
|
||||
keyMapNode.steerWheel.leftOffset = node.value("leftOffset").toDouble();
|
||||
keyMapNode.steerWheel.rightOffset = node.value("rightOffset").toDouble();
|
||||
keyMapNode.steerWheel.upOffset = node.value("upOffset").toDouble();
|
||||
keyMapNode.steerWheel.downOffset = node.value("downOffset").toDouble();
|
||||
keyMapNode.steerWheel.centerPos = QPointF(node.value("centerPos").toObject().value("x").toDouble(),
|
||||
node.value("centerPos").toObject().value("y").toDouble());
|
||||
m_keyMapNodes.push_back(keyMapNode);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning() << "json error: keyMapNodes invalid node type:" << node.value("type").toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parseError:
|
||||
if (!errorString.isEmpty()) {
|
||||
qWarning() << errorString;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
KeyMap::KeyMapNode& KeyMap::getKeyMapNode(int key)
|
||||
{
|
||||
for (auto& itemNode : m_keyMapNodes) {
|
||||
switch (itemNode.type) {
|
||||
case KMT_CLICK:
|
||||
if (node.click.keyNode.key == key) {
|
||||
retNode = node;
|
||||
find = true;
|
||||
if (itemNode.click.keyNode.key == key) {
|
||||
return itemNode;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (find) {
|
||||
case KMT_CLICK_TWICE:
|
||||
if (itemNode.clickTwice.keyNode.key == key) {
|
||||
return itemNode;
|
||||
}
|
||||
break;
|
||||
case KMT_STEER_WHEEL:
|
||||
if (itemNode.steerWheel.leftKey == key
|
||||
|| itemNode.steerWheel.rightKey == key
|
||||
|| itemNode.steerWheel.upKey == key
|
||||
|| itemNode.steerWheel.downKey == key
|
||||
) {
|
||||
return itemNode;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retNode;
|
||||
return m_invalidNode;
|
||||
}
|
||||
|
||||
int KeyMap::getSwitchKey()
|
||||
{
|
||||
return m_switchKey;
|
||||
}
|
||||
|
||||
KeyMap::MouseMoveMap KeyMap::getMouseMoveMap()
|
||||
{
|
||||
return m_mouseMoveMap;
|
||||
}
|
||||
|
||||
bool KeyMap::enableMouseMoveMap()
|
||||
{
|
||||
return !m_mouseMoveMap.startPos.isNull();
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
#ifndef KEYMAP_H
|
||||
#define KEYMAP_H
|
||||
#include <QObject>
|
||||
#include <QPointF>
|
||||
#include <QVector>
|
||||
#include <QRectF>
|
||||
|
||||
|
||||
class KeyMap
|
||||
{
|
||||
class KeyMap : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum KeyMapType {
|
||||
KMT_INVALID = -1,
|
||||
KMT_CLICK = 0,
|
||||
KMT_CLICK_TWICE,
|
||||
};
|
||||
KMT_STEER_WHEEL,
|
||||
};
|
||||
Q_ENUM(KeyMapType)
|
||||
|
||||
struct KeyNode {
|
||||
int key = Qt::Key_unknown;
|
||||
|
@ -23,25 +28,65 @@ public:
|
|||
union {
|
||||
struct {
|
||||
KeyNode keyNode;
|
||||
bool quitMap = false;
|
||||
bool switchMap = false;
|
||||
} click;
|
||||
struct {
|
||||
KeyNode keyNode;
|
||||
bool quitMap = false;
|
||||
} clickTwice;
|
||||
struct {
|
||||
// 方向盘矩形中心位置
|
||||
QPointF centerPos = {0.0f, 0.0f};
|
||||
|
||||
// 方向盘矩形四个方向偏移量
|
||||
float leftOffset = 0.0f;
|
||||
float rightOffset = 0.0f;
|
||||
float upOffset = 0.0f;
|
||||
float downOffset = 0.0f;
|
||||
|
||||
// 方向盘矩形四个方向按键
|
||||
int leftKey = Qt::Key_unknown;
|
||||
int rightKey = Qt::Key_unknown;
|
||||
int upKey = Qt::Key_unknown;
|
||||
int downKey = Qt::Key_unknown;
|
||||
|
||||
// 辅助变量
|
||||
// 方向键的按下状态
|
||||
bool leftKeyPressed = false;
|
||||
bool rightKeyPressed = false;
|
||||
bool upKeyPressed = false;
|
||||
bool downKeyPressed = false;
|
||||
// 按下方向键的数量
|
||||
int pressKeysNum = 0;
|
||||
// 第一次按下的键
|
||||
int firstPressKey = 0;
|
||||
} steerWheel;
|
||||
};
|
||||
KeyMapNode() {}
|
||||
~KeyMapNode() {}
|
||||
};
|
||||
|
||||
KeyMap();
|
||||
struct MouseMoveMap {
|
||||
QPointF startPos = {0.0f, 0.0f};
|
||||
int speedRatio = 1;
|
||||
};
|
||||
|
||||
void loadKeyMapNode();
|
||||
KeyMap::KeyMapNode getKeyMapNode(int key);
|
||||
KeyMap(QObject *parent = Q_NULLPTR);
|
||||
virtual ~KeyMap();
|
||||
|
||||
void loadKeyMap(const QString &json);
|
||||
KeyMap::KeyMapNode& getKeyMapNode(int key);
|
||||
int getSwitchKey();
|
||||
MouseMoveMap getMouseMoveMap();
|
||||
bool enableMouseMoveMap();
|
||||
|
||||
static const QString& getKeyMapPath();
|
||||
|
||||
private:
|
||||
QVector<KeyMapNode> m_keyMapNodes;
|
||||
|
||||
KeyMapNode m_invalidNode;
|
||||
int m_switchKey = Qt::Key_QuoteLeft;
|
||||
MouseMoveMap m_mouseMoveMap;
|
||||
static QString s_keyMapPath;
|
||||
};
|
||||
|
||||
#endif // KEYMAP_H
|
||||
|
|
|
@ -26,7 +26,7 @@ Device::Device(DeviceParams params, QObject *parent)
|
|||
m_vb->init();
|
||||
m_decoder = new Decoder(m_vb, this);
|
||||
m_fileHandler = new FileHandler(this);
|
||||
m_controller = new Controller(params.supportGame, this);
|
||||
m_controller = new Controller(params.gameScript, this);
|
||||
m_videoForm = new VideoForm();
|
||||
m_videoForm->setSerial(m_params.serial);
|
||||
if (m_controller) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
bool closeScreen = false; // 启动时自动息屏
|
||||
bool useReverse = true; // true:先使用adb reverse,失败后自动使用adb forward;false:直接使用adb forward
|
||||
bool display = true; // 是否显示画面(或者仅仅后台录制)
|
||||
bool supportGame = false; // 是否支持游戏映射
|
||||
QString gameScript = ""; // 游戏映射脚本
|
||||
};
|
||||
explicit Device(DeviceParams params, QObject *parent = nullptr);
|
||||
virtual ~Device();
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "ui_dialog.h"
|
||||
#include "device.h"
|
||||
#include "videoform.h"
|
||||
#include "keymap.h"
|
||||
|
||||
Dialog::Dialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
@ -89,7 +90,7 @@ void Dialog::initUI()
|
|||
|
||||
#ifndef Q_OS_WIN32
|
||||
// game only windows
|
||||
ui->gameForPeaceCheck->setEnabled(false);
|
||||
ui->gameCheck->setEnabled(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -103,6 +104,20 @@ void Dialog::execAdbCmd()
|
|||
m_adb.execute("", cmd.split(" ", QString::SkipEmptyParts));
|
||||
}
|
||||
|
||||
QString Dialog::getGameScript(const QString& fileName)
|
||||
{
|
||||
QFile loadFile(KeyMap::getKeyMapPath() + "/" + fileName);
|
||||
if(!loadFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
outLog("open file failed:" + fileName, true);
|
||||
return "";
|
||||
}
|
||||
|
||||
QString ret = loadFile.readAll();
|
||||
loadFile.close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Dialog::on_updateDevice_clicked()
|
||||
{
|
||||
if (checkAdbRun()) {
|
||||
|
@ -138,7 +153,13 @@ void Dialog::on_startServerBtn_clicked()
|
|||
params.closeScreen = ui->closeScreenCheck->isChecked();
|
||||
params.useReverse = ui->useReverseCheck->isChecked();
|
||||
params.display = !ui->notDisplayCheck->isChecked();
|
||||
params.supportGame = ui->gameForPeaceCheck->isChecked();
|
||||
if (ui->gameCheck->isChecked()) {
|
||||
if (ui->gameBox->currentText().isEmpty()) {
|
||||
outLog("no keymap script selected", true);
|
||||
} else {
|
||||
params.gameScript = getGameScript(ui->gameBox->currentText());
|
||||
}
|
||||
}
|
||||
m_deviceManage.connectDevice(params);
|
||||
|
||||
/*
|
||||
|
@ -284,3 +305,28 @@ void Dialog::on_stopAllServerBtn_clicked()
|
|||
{
|
||||
m_deviceManage.disconnectAllDevice();
|
||||
}
|
||||
|
||||
void Dialog::on_updateGameScriptBtn_clicked()
|
||||
{
|
||||
ui->gameBox->clear();
|
||||
QDir dir(KeyMap::getKeyMapPath());
|
||||
if (!dir.exists()) {
|
||||
outLog("keymap directory not find", true);
|
||||
return;
|
||||
}
|
||||
dir.setFilter(QDir::Files | QDir::NoSymLinks);
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
QFileInfo fileInfo;
|
||||
int size = list.size();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
fileInfo = list.at(i);
|
||||
ui->gameBox->addItem(fileInfo.fileName());
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::on_gameCheck_clicked(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
on_updateGameScriptBtn_clicked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,10 +49,14 @@ private slots:
|
|||
|
||||
void on_stopAllServerBtn_clicked();
|
||||
|
||||
void on_updateGameScriptBtn_clicked();
|
||||
void on_gameCheck_clicked(bool checked);
|
||||
|
||||
private:
|
||||
bool checkAdbRun();
|
||||
void initUI();
|
||||
void execAdbCmd();
|
||||
QString getGameScript(const QString& fileName);
|
||||
|
||||
private:
|
||||
Ui::Dialog *ui;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>533</width>
|
||||
<height>608</height>
|
||||
<width>600</width>
|
||||
<height>637</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
|
@ -21,214 +21,6 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="wirelessGroupBox">
|
||||
<property name="title">
|
||||
<string>Wireless</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="2,0,0,1,2">
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLineEdit" name="devicePortEdt">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">5555</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLineEdit" name="deviceIpEdt">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">192.168.0.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="wirelessConnectBtn">
|
||||
<property name="text">
|
||||
<string>wireless connect</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QPushButton" name="wirelessDisConnectBtn">
|
||||
<property name="text">
|
||||
<string>wireless disconnect</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QTextEdit" name="outEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>240</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="documentTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="configGroupBox">
|
||||
<property name="title">
|
||||
<string>Start Config</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="9" colspan="2">
|
||||
<widget class="QCheckBox" name="useReverseCheck">
|
||||
<property name="text">
|
||||
<string>use reverse</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QComboBox" name="videoSizeBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="9" colspan="2">
|
||||
<widget class="QPushButton" name="selectRecordPathBtn">
|
||||
<property name="text">
|
||||
<string>select path</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>record format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6" colspan="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>video size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="10">
|
||||
<widget class="QComboBox" name="formatBox"/>
|
||||
</item>
|
||||
<item row="2" column="7" colspan="2">
|
||||
<widget class="QCheckBox" name="closeScreenCheck">
|
||||
<property name="text">
|
||||
<string>close screen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>bit rate:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>record save path:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>recordPathEdt</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="4">
|
||||
<widget class="QComboBox" name="bitRateBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="7">
|
||||
<widget class="QLineEdit" name="recordPathEdt">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="gameForPeaceCheck">
|
||||
<property name="text">
|
||||
<string>Game for Peace</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5" colspan="2">
|
||||
<widget class="QCheckBox" name="alwaysTopCheck">
|
||||
<property name="text">
|
||||
<string>always top</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="notDisplayCheck">
|
||||
<property name="text">
|
||||
<string>not display</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="usbGroupBox">
|
||||
<property name="title">
|
||||
<string>USB line</string>
|
||||
|
@ -305,6 +97,93 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="wirelessGroupBox">
|
||||
<property name="title">
|
||||
<string>Wireless</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="2,0,0,1,2">
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLineEdit" name="devicePortEdt">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">5555</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLineEdit" name="deviceIpEdt">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">192.168.0.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="wirelessConnectBtn">
|
||||
<property name="text">
|
||||
<string>wireless connect</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QPushButton" name="wirelessDisConnectBtn">
|
||||
<property name="text">
|
||||
<string>wireless disconnect</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QTextEdit" name="outEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>240</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="documentTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="adbGroupBox">
|
||||
<property name="title">
|
||||
<string notr="true">adb</string>
|
||||
|
@ -351,6 +230,150 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="configGroupBox">
|
||||
<property name="title">
|
||||
<string>Start Config</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>bit rate:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" colspan="2">
|
||||
<widget class="QCheckBox" name="notDisplayCheck">
|
||||
<property name="text">
|
||||
<string>not display</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" colspan="2">
|
||||
<widget class="QComboBox" name="bitRateBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="6" colspan="2">
|
||||
<widget class="QCheckBox" name="alwaysTopCheck">
|
||||
<property name="text">
|
||||
<string>always top</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="11" colspan="2">
|
||||
<widget class="QCheckBox" name="useReverseCheck">
|
||||
<property name="text">
|
||||
<string>use reverse</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="12">
|
||||
<widget class="QComboBox" name="formatBox"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>record save path:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>recordPathEdt</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>video size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="9" colspan="2">
|
||||
<widget class="QCheckBox" name="closeScreenCheck">
|
||||
<property name="text">
|
||||
<string>close screen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="8">
|
||||
<widget class="QLineEdit" name="recordPathEdt">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QComboBox" name="videoSizeBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="11" colspan="2">
|
||||
<widget class="QPushButton" name="selectRecordPathBtn">
|
||||
<property name="text">
|
||||
<string>select path</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="10">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>record format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8" colspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="5">
|
||||
<widget class="QComboBox" name="gameBox"/>
|
||||
</item>
|
||||
<item row="3" column="6" colspan="2">
|
||||
<widget class="QPushButton" name="updateGameScriptBtn">
|
||||
<property name="text">
|
||||
<string>update script</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="9" colspan="4">
|
||||
<widget class="QCheckBox" name="gameCheck">
|
||||
<property name="text">
|
||||
<string>custom map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
@ -364,8 +387,6 @@
|
|||
<tabstop>wirelessDisConnectBtn</tabstop>
|
||||
<tabstop>adbCommandEdt</tabstop>
|
||||
<tabstop>adbCommandBtn</tabstop>
|
||||
<tabstop>bitRateBox</tabstop>
|
||||
<tabstop>videoSizeBox</tabstop>
|
||||
<tabstop>formatBox</tabstop>
|
||||
<tabstop>recordPathEdt</tabstop>
|
||||
<tabstop>selectRecordPathBtn</tabstop>
|
||||
|
|
|
@ -33,6 +33,7 @@ int main(int argc, char *argv[])
|
|||
#ifdef Q_OS_WIN32
|
||||
qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/win/adb.exe");
|
||||
qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server.jar");
|
||||
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../keymap");
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
|
|
98
build_for_win.bat
Normal file
98
build_for_win.bat
Normal file
|
@ -0,0 +1,98 @@
|
|||
@echo off
|
||||
set vcvarsall="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\"
|
||||
|
||||
:: 获取脚本绝对路径
|
||||
set script_path=%~dp0
|
||||
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
|
||||
set old_cd=%cd%
|
||||
cd /d %~dp0
|
||||
|
||||
:: 启动参数声明
|
||||
set debug_mode="false"
|
||||
set cpu_mode=x86
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 检查编译参数[debug/release x86/x64]
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
:: 编译参数检查 /i忽略大小写
|
||||
if /i "%1"=="debug" (
|
||||
set debug_mode="true"
|
||||
)
|
||||
if /i "%1"=="release" (
|
||||
set debug_mode="false"
|
||||
)
|
||||
|
||||
if /i "%2"=="x86" (
|
||||
set cpu_mode=x86
|
||||
)
|
||||
if /i "%2"=="x64" (
|
||||
set cpu_mode=x64
|
||||
)
|
||||
|
||||
:: 提示
|
||||
echo 当前编译模式为debug %debug_mode% %cpu_mode%
|
||||
|
||||
:: 环境变量设置
|
||||
if /i %cpu_mode% == x86 (
|
||||
set qt_msvc_path=%qt_msvc_path%msvc2017\bin
|
||||
) else (
|
||||
set qt_msvc_path=%qt_msvc_path%msvc2017_64\bin
|
||||
)
|
||||
|
||||
set build_path=%script_path%build
|
||||
set PATH=%qt_msvc_path%;%PATH%
|
||||
|
||||
:: 注册vc环境
|
||||
if /i %cpu_mode% == x86 (
|
||||
call %vcvarsall% %cpu_mode%
|
||||
) else (
|
||||
call %vcvarsall% %cpu_mode%
|
||||
)
|
||||
|
||||
if not %errorlevel%==0 (
|
||||
echo "vcvarsall not find"
|
||||
goto return
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 开始qmake编译
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
if exist %build_path% (
|
||||
rmdir /q /s %build_path%
|
||||
)
|
||||
md %build_path%
|
||||
cd %build_path%
|
||||
|
||||
set qmake_params=-spec win32-msvc
|
||||
|
||||
if /i %debug_mode% == "true" (
|
||||
set qmake_params=%qmake_params% "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
) else (
|
||||
set qmake_params=%qmake_params% "CONFIG+=qtquickcompiler"
|
||||
)
|
||||
|
||||
:: qmake ../all.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
qmake ../all.pro %qmake_params%
|
||||
|
||||
nmake
|
||||
|
||||
if not %errorlevel%==0 (
|
||||
echo "qmake build failed"
|
||||
goto return
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 完成!
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
:return
|
||||
cd %old_cd%
|
255
keymap/gameforpeace.json
Normal file
255
keymap/gameforpeace.json
Normal file
|
@ -0,0 +1,255 @@
|
|||
{
|
||||
"switchKey": "Key_QuoteLeft",
|
||||
"mouseMoveMap": {
|
||||
"startPos": {
|
||||
"x": 0.57,
|
||||
"y": 0.26
|
||||
},
|
||||
"speedRatio": 10
|
||||
},
|
||||
"keyMapNodes": [{
|
||||
"comment": "方向盘",
|
||||
"type": "KMT_STEER_WHEEL",
|
||||
"centerPos": {
|
||||
"x": 0.16,
|
||||
"y": 0.75
|
||||
},
|
||||
"leftOffset": 0.1,
|
||||
"rightOffset": 0.1,
|
||||
"upOffset": 0.27,
|
||||
"downOffset": 0.2,
|
||||
"leftKey": "Key_A",
|
||||
"rightKey": "Key_D",
|
||||
"upKey": "Key_W",
|
||||
"downKey": "Key_S"
|
||||
},
|
||||
{
|
||||
"comment": "左探头",
|
||||
"type": "KMT_CLICK_TWICE",
|
||||
"key": "Key_Q",
|
||||
"pos": {
|
||||
"x": 0.12,
|
||||
"y": 0.35
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "右探头",
|
||||
"type": "KMT_CLICK_TWICE",
|
||||
"key": "Key_E",
|
||||
"pos": {
|
||||
"x": 0.2,
|
||||
"y": 0.35
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": "跳",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_Space",
|
||||
"pos": {
|
||||
"x": 0.96,
|
||||
"y": 0.7
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "地图",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_M",
|
||||
"pos": {
|
||||
"x": 0.98,
|
||||
"y": 0.03
|
||||
},
|
||||
"switchMap": true
|
||||
},
|
||||
{
|
||||
"comment": "背包",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_Tab",
|
||||
"pos": {
|
||||
"x": 0.06,
|
||||
"y": 0.9
|
||||
},
|
||||
"switchMap": true
|
||||
},
|
||||
{
|
||||
"comment": "趴",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_Z",
|
||||
"pos": {
|
||||
"x": 0.95,
|
||||
"y": 0.9
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "蹲",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_C",
|
||||
"pos": {
|
||||
"x": 0.86,
|
||||
"y": 0.92
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "换弹",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_R",
|
||||
"pos": {
|
||||
"x": 0.795,
|
||||
"y": 0.93
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "小眼睛",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_Alt",
|
||||
"pos": {
|
||||
"x": 0.8,
|
||||
"y": 0.31
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "捡东西1",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_F",
|
||||
"pos": {
|
||||
"x": 0.7,
|
||||
"y": 0.34
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "捡东西2",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_G",
|
||||
"pos": {
|
||||
"x": 0.7,
|
||||
"y": 0.44
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "捡东西3",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_H",
|
||||
"pos": {
|
||||
"x": 0.7,
|
||||
"y": 0.54
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "换枪1",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_1",
|
||||
"pos": {
|
||||
"x": 0.45,
|
||||
"y": 0.9
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "换枪2",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_2",
|
||||
"pos": {
|
||||
"x": 0.55,
|
||||
"y": 0.9
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "手雷",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_3",
|
||||
"pos": {
|
||||
"x": 0.67,
|
||||
"y": 0.92
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "快速打药",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_4",
|
||||
"pos": {
|
||||
"x": 0.33,
|
||||
"y": 0.95
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "下车",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_S",
|
||||
"pos": {
|
||||
"x": 0.92,
|
||||
"y": 0.4
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "救人",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_6",
|
||||
"pos": {
|
||||
"x": 0.49,
|
||||
"y": 0.63
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "车加速",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_Shift",
|
||||
"pos": {
|
||||
"x": 0.82,
|
||||
"y": 0.8
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "开关门",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_X",
|
||||
"pos": {
|
||||
"x": 0.7,
|
||||
"y": 0.7
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "舔包",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "Key_T",
|
||||
"pos": {
|
||||
"x": 0.72,
|
||||
"y": 0.26
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "开枪",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "LeftButton",
|
||||
"pos": {
|
||||
"x": 0.86,
|
||||
"y": 0.72
|
||||
},
|
||||
"switchMap": false
|
||||
},
|
||||
{
|
||||
"comment": "开镜",
|
||||
"type": "KMT_CLICK",
|
||||
"key": "RightButton",
|
||||
"pos": {
|
||||
"x": 0.96,
|
||||
"y": 0.52
|
||||
},
|
||||
"switchMap": false
|
||||
}
|
||||
]
|
||||
}
|
66
publish_for_win.bat
Normal file
66
publish_for_win.bat
Normal file
|
@ -0,0 +1,66 @@
|
|||
@echo off
|
||||
set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\"
|
||||
|
||||
:: 获取脚本绝对路径
|
||||
set script_path=%~dp0
|
||||
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
|
||||
set old_cd=%cd%
|
||||
cd /d %~dp0
|
||||
|
||||
:: 启动参数声明
|
||||
set cpu_mode=x86
|
||||
if /i "%1"=="x86" (
|
||||
set cpu_mode=x86
|
||||
)
|
||||
if /i "%1"=="x64" (
|
||||
set cpu_mode=x64
|
||||
)
|
||||
|
||||
:: 环境变量设置
|
||||
|
||||
set adb_path=%script_path%third_party\adb\win\*.*
|
||||
set jar_path=%script_path%third_party\scrcpy-server.jar
|
||||
set keymap_path=%script_path%keymap
|
||||
|
||||
if /i %cpu_mode% == x86 (
|
||||
set publish_path=%script_path%QtScrcpy-win32\
|
||||
set release_path=%script_path%output\win\release
|
||||
set qt_msvc_path=%qt_msvc_path%msvc2017\bin
|
||||
) else (
|
||||
set publish_path=%script_path%QtScrcpy-win64\
|
||||
set release_path=%script_path%output\win-x64\release
|
||||
set qt_msvc_path=%qt_msvc_path%msvc2017_64\bin
|
||||
)
|
||||
set PATH=%qt_msvc_path%;%PATH%
|
||||
|
||||
if exist %publish_path% (
|
||||
rmdir /s/q %publish_path%
|
||||
)
|
||||
|
||||
:: 复制要发布的包
|
||||
xcopy %release_path% %publish_path% /E /Y
|
||||
xcopy %adb_path% %publish_path% /Y
|
||||
xcopy %jar_path% %publish_path% /Y
|
||||
xcopy %keymap_path% %publish_path%keymap\ /E /Y
|
||||
|
||||
:: 添加qt依赖包
|
||||
windeployqt %publish_path%\QtScrcpy.exe
|
||||
|
||||
:: 删除多余qt依赖包
|
||||
rmdir /s/q %publish_path%\iconengines
|
||||
rmdir /s/q %publish_path%\imageformats
|
||||
rmdir /s/q %publish_path%\translations
|
||||
if /i %cpu_mode% == x86 (
|
||||
del %publish_path%\vc_redist.x86.exe
|
||||
) else (
|
||||
del %publish_path%\vc_redist.x64.exe
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 完成!
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
:return
|
||||
cd %old_cd%
|
Loading…
Add table
Reference in a new issue