Skip to content

Commit

Permalink
Merge pull request #249 from barry-ran/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
barry-ran authored Jul 8, 2020
2 parents b39689e + 790ac38 commit 4cc276d
Show file tree
Hide file tree
Showing 31 changed files with 825 additions and 201 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
qt-ver: [5.12.6]
qt-ver: [5.15.0]
qt-arch-install: [clang_64]
clang-arch: [x64]
env:
Expand All @@ -31,7 +31,7 @@ jobs:
path: ${{ env.qt-install-path }}/${{ matrix.qt-arch-install }}
key: ${{ runner.os }}/${{ matrix.qt-ver }}/${{ matrix.qt-arch-install }}
- name: Install Qt
uses: jurplel/install-qt-action@v2.6.2
uses: jurplel/install-qt-action@v2.7.1
with:
version: ${{ matrix.qt-ver }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-16.04,ubuntu-18.04]
qt-ver: [5.12.6]
qt-ver: [5.15.0]
qt-arch-install: [gcc_64]
gcc-arch: [x64]
env:
Expand All @@ -33,7 +33,7 @@ jobs:
path: ${{ env.qt-install-path }}/${{ matrix.qt-arch-install }}
key: ${{ runner.os }}/${{ matrix.qt-ver }}/${{ matrix.qt-arch-install }}
- name: Install Qt
uses: jurplel/install-qt-action@v2.6.2
uses: jurplel/install-qt-action@v2.7.1
with:
version: ${{ matrix.qt-ver }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,30 @@ on:
jobs:
build:
name: Build
# windows-latest目前是windows server 2019,选择2016是2016安装的是vs2017
# windows-latest目前是windows server 2019
# windows server 2019安装的是vs2019,windows server 2016安装的是vs2017
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: windows-2016
runs-on: windows-2019

# 矩阵配置 https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
strategy:
matrix:
qt-ver: [5.12.6]
qt-arch: [win64_msvc2017_64, win32_msvc2017]
qt-ver: [5.15.0]
qt-arch: [win64_msvc2019_64, win32_msvc2019]
# 配置qt-arch的额外设置msvc-arch,qt-arch-install
include:
- qt-arch: win64_msvc2017_64
- qt-arch: win64_msvc2019_64
msvc-arch: x64
qt-arch-install: msvc2017_64
- qt-arch: win32_msvc2017
qt-arch-install: msvc2019_64
- qt-arch: win32_msvc2019
msvc-arch: x86
qt-arch-install: msvc2017
qt-arch-install: msvc2019
# job env,所有steps都可以访问
# 不同级别env详解 https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#env
# 使用表达式语法${{}}访问上下文 https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
env:
target-name: QtScrcpy
vcvarsall-path: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
vcvarsall-path: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
qt-install-path: ${{ github.workspace }}/${{ matrix.qt-ver }}
plantform-des: win
# 步骤
Expand All @@ -50,7 +51,7 @@ jobs:
# 安装Qt
- name: Install Qt
# 使用外部action。这个action专门用来安装Qt
uses: jurplel/install-qt-action@v2.6.2
uses: jurplel/install-qt-action@v2.7.1
with:
# Version of Qt to install
version: ${{ matrix.qt-ver }}
Expand Down
4 changes: 2 additions & 2 deletions QtScrcpy/adb/adbprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ QStringList AdbProcess::getDevicesSerialFromStdOut()
{
// get devices serial by adb devices
QStringList serials;
QStringList devicesInfoList = m_standardOutput.split(QRegExp("\r\n|\n"), QString::SkipEmptyParts);
QStringList devicesInfoList = m_standardOutput.split(QRegExp("\r\n|\n"), Qt::SkipEmptyParts);
for (QString deviceInfo : devicesInfoList) {
QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), QString::SkipEmptyParts);
QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), Qt::SkipEmptyParts);
if (2 == deviceInfos.count() && 0 == deviceInfos[1].compare("device")) {
serials << deviceInfos[0];
}
Expand Down
4 changes: 2 additions & 2 deletions QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ bool InputConvertGame::processMouseMove(const QMouseEvent *from)
m_ctrlMouseMove.lastConverPos.setX(m_ctrlMouseMove.lastConverPos.x() + distance.x() / m_showSize.width());
m_ctrlMouseMove.lastConverPos.setY(m_ctrlMouseMove.lastConverPos.y() + distance.y() / m_showSize.height());

if (m_ctrlMouseMove.lastConverPos.x() < 0.1 || m_ctrlMouseMove.lastConverPos.x() > 0.98 || m_ctrlMouseMove.lastConverPos.y() < 0.1
|| m_ctrlMouseMove.lastConverPos.y() > 0.98) {
if (m_ctrlMouseMove.lastConverPos.x() < 0.1 || m_ctrlMouseMove.lastConverPos.x() > 0.8 || m_ctrlMouseMove.lastConverPos.y() < 0.1
|| m_ctrlMouseMove.lastConverPos.y() > 0.8) {
if (m_ctrlMouseMove.smallEyes) {
m_processMouseMove = false;
int delay = 30;
Expand Down
66 changes: 29 additions & 37 deletions QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,16 @@ void InputConvertNormal::mouseEvent(const QMouseEvent *from, const QSize &frameS

void InputConvertNormal::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize)
{
if (!from || 0 == from->delta()) {
if (!from || from->angleDelta().isNull()) {
return;
}

// delta
qint32 hScroll = 0;
qint32 vScroll = 0;
switch (from->orientation()) {
case Qt::Horizontal:
hScroll = from->delta() / abs(from->delta()) * 2;
break;
case Qt::Vertical:
vScroll = from->delta() / abs(from->delta()) * 2;
break;
}
qint32 hScroll = from->angleDelta().x() == 0 ? 0 : from->angleDelta().x() / abs(from->angleDelta().x()) * 2;
qint32 vScroll = from->angleDelta().y() == 0 ? 0 : from->angleDelta().y() / abs(from->angleDelta().y()) * 2;

// pos
QPointF pos = from->posF();
QPointF pos = from->position();
// convert pos
pos.setX(pos.x() * frameSize.width() / showSize.width());
pos.setY(pos.y() * frameSize.height() / showSize.height());
Expand Down Expand Up @@ -279,7 +271,7 @@ AndroidKeycode InputConvertNormal::convertKeyCode(int key, Qt::KeyboardModifiers
keyCode = AKEYCODE_0;
break;
case Qt::Key_1:
case Qt::Key_Exclam:// !
case Qt::Key_Exclam: // !
keyCode = AKEYCODE_1;
break;
case Qt::Key_2:
Expand All @@ -289,11 +281,11 @@ AndroidKeycode InputConvertNormal::convertKeyCode(int key, Qt::KeyboardModifiers
keyCode = AKEYCODE_3;
break;
case Qt::Key_4:
case Qt::Key_Dollar://$
case Qt::Key_Dollar: //$
keyCode = AKEYCODE_4;
break;
case Qt::Key_5:
case Qt::Key_Percent:// %
case Qt::Key_Percent: // %
keyCode = AKEYCODE_5;
break;
case Qt::Key_6:
Expand All @@ -313,53 +305,53 @@ AndroidKeycode InputConvertNormal::convertKeyCode(int key, Qt::KeyboardModifiers
case Qt::Key_Space:
keyCode = AKEYCODE_SPACE;
break;
case Qt::Key_Comma://,
case Qt::Key_Less://<
case Qt::Key_Comma: //,
case Qt::Key_Less: //<
keyCode = AKEYCODE_COMMA;
break;
case Qt::Key_Period://.
case Qt::Key_Greater://>
case Qt::Key_Period: //.
case Qt::Key_Greater: //>
keyCode = AKEYCODE_PERIOD;
break;
case Qt::Key_Minus://-
case Qt::Key_Minus: //-
case Qt::Key_Underscore: //_
keyCode = AKEYCODE_MINUS;
break;
case Qt::Key_Equal://=
case Qt::Key_Equal: //=
keyCode = AKEYCODE_EQUALS;
break;
case Qt::Key_BracketLeft://[
case Qt::Key_BraceLeft: //{
case Qt::Key_BracketLeft: //[
case Qt::Key_BraceLeft: //{
keyCode = AKEYCODE_LEFT_BRACKET;
break;
case Qt::Key_BracketRight://]
case Qt::Key_BraceRight: //}
case Qt::Key_BracketRight: //]
case Qt::Key_BraceRight: //}
keyCode = AKEYCODE_RIGHT_BRACKET;
break;
case Qt::Key_Backslash:// \ ????
case Qt::Key_Bar: //|
case Qt::Key_Backslash: // \ ????
case Qt::Key_Bar: //|
keyCode = AKEYCODE_BACKSLASH;
break;
case Qt::Key_Semicolon://;
case Qt::Key_Colon: //:
case Qt::Key_Semicolon: //;
case Qt::Key_Colon: //:
keyCode = AKEYCODE_SEMICOLON;
break;
case Qt::Key_Apostrophe://'
case Qt::Key_QuoteDbl: //"
case Qt::Key_Apostrophe: //'
case Qt::Key_QuoteDbl: //"
keyCode = AKEYCODE_APOSTROPHE;
break;
case Qt::Key_Slash:// /
case Qt::Key_Question://?
case Qt::Key_Slash: // /
case Qt::Key_Question: //?
keyCode = AKEYCODE_SLASH;
break;
case Qt::Key_At://@
case Qt::Key_At: //@
keyCode = AKEYCODE_AT;
break;
case Qt::Key_Plus://+
case Qt::Key_Plus: //+
keyCode = AKEYCODE_PLUS;
break;
case Qt::Key_QuoteLeft://`
case Qt::Key_AsciiTilde://~
case Qt::Key_QuoteLeft: //`
case Qt::Key_AsciiTilde: //~
keyCode = AKEYCODE_GRAVE;
break;
case Qt::Key_NumberSign: //#
Expand Down
2 changes: 1 addition & 1 deletion QtScrcpy/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void Device::initSignals()
if (m_controlState == GCS_CLIENT) {
return;
}
QMessageBox::information(m_videoForm, "QtScrcpy", tips, QMessageBox::Ok);
//QMessageBox::information(m_videoForm, "QtScrcpy", tips, QMessageBox::Ok);
});
}

Expand Down
3 changes: 2 additions & 1 deletion QtScrcpy/device/device.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef DEVICE_H
#define DEVICE_H

#include <QElapsedTimer>
#include <QPointer>
#include <QTime>

Expand Down Expand Up @@ -116,7 +117,7 @@ public slots:
// ui
QPointer<VideoForm> m_videoForm;

QTime m_startTimeCount;
QElapsedTimer m_startTimeCount;
DeviceParams m_params;

GroupControlState m_controlState = GCS_FREE;
Expand Down
55 changes: 30 additions & 25 deletions QtScrcpy/device/filehandler/filehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,46 @@

FileHandler::FileHandler(QObject *parent) : QObject(parent)
{
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult) {
switch (processResult) {
case AdbProcess::AER_ERROR_START:
case AdbProcess::AER_ERROR_EXEC:
case AdbProcess::AER_ERROR_MISSING_BINARY:
emit fileHandlerResult(FAR_ERROR_EXEC, m_isApk);
break;
case AdbProcess::AER_SUCCESS_EXEC:
emit fileHandlerResult(FAR_SUCCESS_EXEC, m_isApk);
break;
default:
break;
}
});
}

FileHandler::~FileHandler() {}

void FileHandler::onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath)
{
if (m_adb.isRuning()) {
emit fileHandlerResult(FAR_IS_RUNNING, false);
return;
}
AdbProcess* adb = new AdbProcess;
bool isApk = false;
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb, isApk](AdbProcess::ADB_EXEC_RESULT processResult) {
onAdbProcessResult(adb, isApk, processResult);
});

m_isApk = false;
m_adb.push(serial, file, devicePath);
adb->push(serial, file, devicePath);
}

void FileHandler::onInstallApkRequest(const QString &serial, const QString &apkFile)
{
if (m_adb.isRuning()) {
emit fileHandlerResult(FAR_IS_RUNNING, true);
return;
AdbProcess* adb = new AdbProcess;
bool isApk = true;
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb, isApk](AdbProcess::ADB_EXEC_RESULT processResult) {
onAdbProcessResult(adb, isApk, processResult);
});

adb->install(serial, apkFile);
}

void FileHandler::onAdbProcessResult(AdbProcess *adb, bool isApk, AdbProcess::ADB_EXEC_RESULT processResult)
{
switch (processResult) {
case AdbProcess::AER_ERROR_START:
case AdbProcess::AER_ERROR_EXEC:
case AdbProcess::AER_ERROR_MISSING_BINARY:
emit fileHandlerResult(FAR_ERROR_EXEC, isApk);
adb->deleteLater();
break;
case AdbProcess::AER_SUCCESS_EXEC:
emit fileHandlerResult(FAR_SUCCESS_EXEC, isApk);
adb->deleteLater();
break;
default:
break;
}
m_isApk = true;
m_adb.install(serial, apkFile);
}
8 changes: 3 additions & 5 deletions QtScrcpy/device/filehandler/filehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ public slots:
void onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath = "");
void onInstallApkRequest(const QString &serial, const QString &apkFile);

protected:
void onAdbProcessResult(AdbProcess* adb, bool isApk, AdbProcess::ADB_EXEC_RESULT processResult);

signals:
void fileHandlerResult(FILE_HANDLER_RESULT processResult, bool isApk = false);

private:
AdbProcess m_adb;
bool m_isApk = false;
QString m_devicePath = "";
};

#endif // FILEHANDLER_H
2 changes: 1 addition & 1 deletion QtScrcpy/device/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool Server::execute()
// code option
// https://github.com/Genymobile/scrcpy/commit/080a4ee3654a9b7e96c8ffe37474b5c21c02852a
// <https://d.android.com/reference/android/media/MediaFormat>
args << "-";
args << Config::getInstance().getCodecOptions();

#ifdef SERVER_DEBUGGER
qInfo("Server debugger waiting for a client on device port " SERVER_DEBUGGER_PORT "...");
Expand Down
Loading

0 comments on commit 4cc276d

Please sign in to comment.