diff --git a/QtScrcpy/devicemanage/devicemanage.cpp b/QtScrcpy/devicemanage/devicemanage.cpp index 646becc..decce90 100644 --- a/QtScrcpy/devicemanage/devicemanage.cpp +++ b/QtScrcpy/devicemanage/devicemanage.cpp @@ -49,6 +49,10 @@ bool DeviceManage::connectDevice(Device::DeviceParams params) void DeviceManage::updateScript(QString script) { + if (m_devices.isEmpty()) { + qWarning() << "no device connect!!!"; + return; + } QMapIterator> i(m_devices); while (i.hasNext()) { i.next(); diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index da5991d..c9d8be0 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -91,11 +91,6 @@ void Dialog::initUI() ui->formatBox->addItem("mp4"); ui->formatBox->addItem("mkv"); -#ifndef Q_OS_WIN32 - // game only windows - ui->gameCheck->setEnabled(false); -#endif - ui->recordPathEdt->setText(Config::getInstance().getRecordPath()); } @@ -155,18 +150,12 @@ void Dialog::on_startServerBtn_clicked() params.maxSize = videoSize; params.bitRate = bitRate; // on devices with Android >= 10, the capture frame rate can be limited - params.maxFps = Config::getInstance().getMaxFps(); + params.maxFps = static_cast(Config::getInstance().getMaxFps()); params.recordFileName = absFilePath; params.closeScreen = ui->closeScreenCheck->isChecked(); params.useReverse = ui->useReverseCheck->isChecked(); params.display = !ui->notDisplayCheck->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); /* diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui index 514e54e..98ce0c8 100644 --- a/QtScrcpy/dialog.ui +++ b/QtScrcpy/dialog.ui @@ -304,13 +304,6 @@ - - - - auto enable - - - diff --git a/QtScrcpy/main.cpp b/QtScrcpy/main.cpp index 63d9ad1..833b047 100644 --- a/QtScrcpy/main.cpp +++ b/QtScrcpy/main.cpp @@ -10,9 +10,9 @@ #include "mousetap/mousetap.h" #include "config.h" -Dialog* g_mainDlg = Q_NULLPTR; +static Dialog* g_mainDlg = Q_NULLPTR; -QtMessageHandler g_oldMessageHandler = Q_NULLPTR; +static QtMessageHandler g_oldMessageHandler = Q_NULLPTR; void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg); void installTranslator(); diff --git a/README.md b/README.md index 4e8ca9f..0f6b2cd 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,9 @@ Here is the instruction of adding new customized mapping files. - Write a customized script and put it in the `keymap` directory - Click `refresh script` to check whether it can be found +- Select your script - Connect your phone, start service and click `apply` -- Start the game and press `~` key (left side of the number key 1) to switch to the mapping mode (It can be changed in the script as `switchkey`) +- Press `~` key (left side of the number key 1) to switch to the custom mapping mode (It can be changed in the script as `switchkey`) - Press the ~ key again to switch back to normal mode - (For PUBG and similar games) If you want to drive cars with WASD, you need to check the `single rocker mode` in the game setting. diff --git a/README_zh.md b/README_zh.md index a2864ff..4afff4c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -42,8 +42,9 @@ QtScrcpy可以通过USB(或通过TCP/IP)连接Android设备,并进行显示和 自定义按键映射操作方法如下: - 编写自定义脚本放入keymap目录 - 点击刷新脚本,确保脚本可以被检测到 +- 选择需要的脚本 - 连接手机并启动服务之后,点击应用脚本 -- 进入游戏场景,按~键(数字键1左边)切换为游戏映射模式即可体验(具体按什么键要看你按键脚本定义的switchKey) +- 按~键(数字键1左边)切换为自定义映射模式即可体验(具体按什么键要看你按键脚本定义的switchKey) - 再次按~键切换为正常控制模式 - 要想wasd控制开车记得在载具设置中设置为单摇杆模式