mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 03:55:04 +00:00
commit
44d2825a0d
12 changed files with 77 additions and 27 deletions
|
@ -65,9 +65,10 @@ bool Controller::isCurrentCustomKeymap()
|
|||
return m_inputConvert->isCurrentCustomKeymap();
|
||||
}
|
||||
|
||||
void Controller::onPostBackOrScreenOn()
|
||||
void Controller::onPostBackOrScreenOn(bool down)
|
||||
{
|
||||
ControlMsg *controlMsg = new ControlMsg(ControlMsg::CMT_BACK_OR_SCREEN_ON);
|
||||
controlMsg->setBackOrScreenOnData(down);
|
||||
if (!controlMsg) {
|
||||
return;
|
||||
}
|
||||
|
@ -128,9 +129,9 @@ void Controller::onExpandNotificationPanel()
|
|||
postControlMsg(controlMsg);
|
||||
}
|
||||
|
||||
void Controller::onCollapseNotificationPanel()
|
||||
void Controller::onCollapsePanel()
|
||||
{
|
||||
ControlMsg *controlMsg = new ControlMsg(ControlMsg::CMT_COLLAPSE_NOTIFICATION_PANEL);
|
||||
ControlMsg *controlMsg = new ControlMsg(ControlMsg::CMT_COLLAPSE_PANELS);
|
||||
if (!controlMsg) {
|
||||
return;
|
||||
}
|
||||
|
@ -146,6 +147,17 @@ void Controller::onRequestDeviceClipboard()
|
|||
postControlMsg(controlMsg);
|
||||
}
|
||||
|
||||
void Controller::onGetDeviceClipboard(bool cut)
|
||||
{
|
||||
ControlMsg *controlMsg = new ControlMsg(ControlMsg::CMT_GET_CLIPBOARD);
|
||||
if (!controlMsg) {
|
||||
return;
|
||||
}
|
||||
ControlMsg::GetClipboardCopyKey copyKey = cut ? ControlMsg::GCCK_CUT : ControlMsg::GCCK_COPY;
|
||||
controlMsg->setGetClipboardMsgData(copyKey);
|
||||
postControlMsg(controlMsg);
|
||||
}
|
||||
|
||||
void Controller::onSetDeviceClipboard(bool pause)
|
||||
{
|
||||
QClipboard *board = QApplication::clipboard();
|
||||
|
|
|
@ -34,7 +34,7 @@ public slots:
|
|||
void onCopy();
|
||||
void onCut();
|
||||
void onExpandNotificationPanel();
|
||||
void onCollapseNotificationPanel();
|
||||
void onCollapsePanel();
|
||||
void onSetScreenPowerMode(ControlMsg::ScreenPowerMode mode);
|
||||
|
||||
// for input convert
|
||||
|
@ -43,8 +43,10 @@ public slots:
|
|||
void onKeyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize);
|
||||
|
||||
// turn the screen on if it was off, press BACK otherwise
|
||||
void onPostBackOrScreenOn();
|
||||
// If the screen is off, it is turned on only on down
|
||||
void onPostBackOrScreenOn(bool down);
|
||||
void onRequestDeviceClipboard();
|
||||
void onGetDeviceClipboard(bool cut = false);
|
||||
void onSetDeviceClipboard(bool pause = true);
|
||||
void onClipboardPaste();
|
||||
void onPostTextInput(QString &text);
|
||||
|
|
|
@ -56,6 +56,11 @@ void ControlMsg::setInjectScrollMsgData(QRect position, qint32 hScroll, qint32 v
|
|||
m_data.injectScroll.vScroll = vScroll;
|
||||
}
|
||||
|
||||
void ControlMsg::setGetClipboardMsgData(ControlMsg::GetClipboardCopyKey copyKey)
|
||||
{
|
||||
m_data.getClipboard.copyKey = copyKey;
|
||||
}
|
||||
|
||||
void ControlMsg::setSetClipboardMsgData(QString &text, bool paste)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
|
@ -70,6 +75,7 @@ void ControlMsg::setSetClipboardMsgData(QString &text, bool paste)
|
|||
memcpy(m_data.setClipboard.text, tmp.data(), tmp.length());
|
||||
m_data.setClipboard.text[tmp.length()] = '\0';
|
||||
m_data.setClipboard.paste = paste;
|
||||
m_data.setClipboard.sequence = 0;
|
||||
}
|
||||
|
||||
void ControlMsg::setSetScreenPowerModeData(ControlMsg::ScreenPowerMode mode)
|
||||
|
@ -77,6 +83,11 @@ void ControlMsg::setSetScreenPowerModeData(ControlMsg::ScreenPowerMode mode)
|
|||
m_data.setScreenPowerMode.mode = mode;
|
||||
}
|
||||
|
||||
void ControlMsg::setBackOrScreenOnData(bool down)
|
||||
{
|
||||
m_data.backOrScreenOn.action = down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP;
|
||||
}
|
||||
|
||||
void ControlMsg::writePosition(QBuffer &buffer, const QRect &value)
|
||||
{
|
||||
BufferUtil::write32(buffer, value.left());
|
||||
|
@ -126,7 +137,14 @@ QByteArray ControlMsg::serializeData()
|
|||
BufferUtil::write32(buffer, m_data.injectScroll.hScroll);
|
||||
BufferUtil::write32(buffer, m_data.injectScroll.vScroll);
|
||||
break;
|
||||
case CMT_BACK_OR_SCREEN_ON:
|
||||
buffer.putChar(m_data.backOrScreenOn.action);
|
||||
break;
|
||||
case CMT_GET_CLIPBOARD:
|
||||
buffer.putChar(m_data.getClipboard.copyKey);
|
||||
break;
|
||||
case CMT_SET_CLIPBOARD:
|
||||
BufferUtil::write64(buffer, m_data.setClipboard.sequence);
|
||||
buffer.putChar(!!m_data.setClipboard.paste);
|
||||
BufferUtil::write32(buffer, static_cast<quint32>(strlen(m_data.setClipboard.text)));
|
||||
buffer.write(m_data.setClipboard.text, strlen(m_data.setClipboard.text));
|
||||
|
@ -134,10 +152,10 @@ QByteArray ControlMsg::serializeData()
|
|||
case CMT_SET_SCREEN_POWER_MODE:
|
||||
buffer.putChar(m_data.setScreenPowerMode.mode);
|
||||
break;
|
||||
case CMT_BACK_OR_SCREEN_ON:
|
||||
case CMT_EXPAND_NOTIFICATION_PANEL:
|
||||
case CMT_COLLAPSE_NOTIFICATION_PANEL:
|
||||
case CMT_GET_CLIPBOARD:
|
||||
case CMT_EXPAND_SETTINGS_PANEL:
|
||||
case CMT_COLLAPSE_PANELS:
|
||||
case CMT_ROTATE_DEVICE:
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Unknown event type:" << m_data.type;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
(CONTROL_MSG_MAX_SIZE - 6)
|
||||
|
||||
#define POINTER_ID_MOUSE static_cast<quint64>(-1)
|
||||
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2)
|
||||
|
||||
// ControlMsg
|
||||
class ControlMsg : public QScrcpyEvent
|
||||
|
@ -31,10 +32,12 @@ public:
|
|||
CMT_INJECT_SCROLL,
|
||||
CMT_BACK_OR_SCREEN_ON,
|
||||
CMT_EXPAND_NOTIFICATION_PANEL,
|
||||
CMT_COLLAPSE_NOTIFICATION_PANEL,
|
||||
CMT_EXPAND_SETTINGS_PANEL,
|
||||
CMT_COLLAPSE_PANELS,
|
||||
CMT_GET_CLIPBOARD,
|
||||
CMT_SET_CLIPBOARD,
|
||||
CMT_SET_SCREEN_POWER_MODE
|
||||
CMT_SET_SCREEN_POWER_MODE,
|
||||
CMT_ROTATE_DEVICE
|
||||
};
|
||||
|
||||
enum ScreenPowerMode
|
||||
|
@ -44,6 +47,12 @@ public:
|
|||
SPM_NORMAL = 2,
|
||||
};
|
||||
|
||||
enum GetClipboardCopyKey {
|
||||
GCCK_NONE,
|
||||
GCCK_COPY,
|
||||
GCCK_CUT,
|
||||
};
|
||||
|
||||
ControlMsg(ControlMsgType controlMsgType);
|
||||
virtual ~ControlMsg();
|
||||
|
||||
|
@ -54,8 +63,10 @@ public:
|
|||
// position action动作对应的位置
|
||||
void setInjectTouchMsgData(quint64 id, AndroidMotioneventAction action, AndroidMotioneventButtons buttons, QRect position, float pressure);
|
||||
void setInjectScrollMsgData(QRect position, qint32 hScroll, qint32 vScroll);
|
||||
void setGetClipboardMsgData(ControlMsg::GetClipboardCopyKey copyKey);
|
||||
void setSetClipboardMsgData(QString &text, bool paste);
|
||||
void setSetScreenPowerModeData(ControlMsg::ScreenPowerMode mode);
|
||||
void setBackOrScreenOnData(bool down);
|
||||
|
||||
QByteArray serializeData();
|
||||
|
||||
|
@ -96,6 +107,16 @@ private:
|
|||
} injectScroll;
|
||||
struct
|
||||
{
|
||||
AndroidKeyeventAction action; // action for the BACK key
|
||||
// screen may only be turned on on ACTION_DOWN
|
||||
} backOrScreenOn;
|
||||
struct
|
||||
{
|
||||
enum GetClipboardCopyKey copyKey;
|
||||
} getClipboard;
|
||||
struct
|
||||
{
|
||||
uint64_t sequence = 0;
|
||||
char *text = Q_NULLPTR;
|
||||
bool paste = true;
|
||||
} setClipboard;
|
||||
|
|
|
@ -155,7 +155,7 @@ void Device::initSignals()
|
|||
connect(this, &Device::postCut, m_controller, &Controller::onCut);
|
||||
connect(this, &Device::setScreenPowerMode, m_controller, &Controller::onSetScreenPowerMode);
|
||||
connect(this, &Device::expandNotificationPanel, m_controller, &Controller::onExpandNotificationPanel);
|
||||
connect(this, &Device::collapseNotificationPanel, m_controller, &Controller::onCollapseNotificationPanel);
|
||||
connect(this, &Device::collapsePanel, m_controller, &Controller::onCollapsePanel);
|
||||
connect(this, &Device::mouseEvent, m_controller, &Controller::onMouseEvent);
|
||||
connect(this, &Device::wheelEvent, m_controller, &Controller::onWheelEvent);
|
||||
connect(this, &Device::keyEvent, m_controller, &Controller::onKeyEvent);
|
||||
|
|
|
@ -76,8 +76,8 @@ signals:
|
|||
void postCut();
|
||||
void setScreenPowerMode(ControlMsg::ScreenPowerMode mode);
|
||||
void expandNotificationPanel();
|
||||
void collapseNotificationPanel();
|
||||
void postBackOrScreenOn();
|
||||
void collapsePanel();
|
||||
void postBackOrScreenOn(bool down);
|
||||
void postTextInput(QString &text);
|
||||
void requestDeviceClipboard();
|
||||
void setDeviceClipboard(bool pause = true);
|
||||
|
|
|
@ -295,14 +295,14 @@ void VideoForm::installShortcut()
|
|||
emit m_device->expandNotificationPanel();
|
||||
});
|
||||
|
||||
// collapseNotificationPanel
|
||||
// collapsePanel
|
||||
shortcut = new QShortcut(QKeySequence("Ctrl+Shift+n"), this);
|
||||
shortcut->setAutoRepeat(false);
|
||||
connect(shortcut, &QShortcut::activated, this, [this]() {
|
||||
if (!m_device) {
|
||||
return;
|
||||
}
|
||||
emit m_device->collapseNotificationPanel();
|
||||
emit m_device->collapsePanel();
|
||||
});
|
||||
|
||||
// copy
|
||||
|
@ -613,7 +613,7 @@ void VideoForm::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
}
|
||||
|
||||
if (event->button() == Qt::RightButton && m_device && !m_device->isCurrentCustomKeymap()) {
|
||||
emit m_device->postBackOrScreenOn();
|
||||
emit m_device->postBackOrScreenOn(event->type() == QEvent::MouseButtonPress);
|
||||
}
|
||||
|
||||
if (m_videoWidget->geometry().contains(event->pos())) {
|
||||
|
|
|
@ -130,7 +130,7 @@ void DeviceManage::setGroupControlSignals(Device *host, Device *client, bool ins
|
|||
connect(host, &Device::postVolumeDown, client, &Device::postVolumeDown);
|
||||
connect(host, &Device::setScreenPowerMode, client, &Device::setScreenPowerMode);
|
||||
connect(host, &Device::expandNotificationPanel, client, &Device::expandNotificationPanel);
|
||||
connect(host, &Device::collapseNotificationPanel, client, &Device::collapseNotificationPanel);
|
||||
connect(host, &Device::collapsePanel, client, &Device::collapsePanel);
|
||||
connect(host, &Device::postBackOrScreenOn, client, &Device::postBackOrScreenOn);
|
||||
connect(host, &Device::postTextInput, client, &Device::postTextInput);
|
||||
connect(host, &Device::setDeviceClipboard, client, &Device::setDeviceClipboard);
|
||||
|
@ -149,7 +149,7 @@ void DeviceManage::setGroupControlSignals(Device *host, Device *client, bool ins
|
|||
disconnect(host, &Device::postVolumeDown, client, &Device::postVolumeDown);
|
||||
disconnect(host, &Device::setScreenPowerMode, client, &Device::setScreenPowerMode);
|
||||
disconnect(host, &Device::expandNotificationPanel, client, &Device::expandNotificationPanel);
|
||||
disconnect(host, &Device::collapseNotificationPanel, client, &Device::collapseNotificationPanel);
|
||||
disconnect(host, &Device::collapsePanel, client, &Device::collapsePanel);
|
||||
disconnect(host, &Device::postBackOrScreenOn, client, &Device::postBackOrScreenOn);
|
||||
disconnect(host, &Device::postTextInput, client, &Device::postTextInput);
|
||||
disconnect(host, &Device::setDeviceClipboard, client, &Device::setDeviceClipboard);
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
#define COMMON_LOG_LEVEL_DEF "info"
|
||||
|
||||
#define COMMON_CODEC_OPTIONS_KEY "CodecOptions"
|
||||
#define COMMON_CODEC_OPTIONS_DEF "-"
|
||||
#define COMMON_CODEC_OPTIONS_DEF ""
|
||||
|
||||
#define COMMON_CODEC_NAME_KEY "CodecName"
|
||||
#define COMMON_CODEC_NAME_DEF "-"
|
||||
#define COMMON_CODEC_NAME_DEF ""
|
||||
|
||||
// user config
|
||||
#define COMMON_RECORD_KEY "RecordPath"
|
||||
|
|
|
@ -183,7 +183,8 @@ void CocoaMouseTap::run()
|
|||
|
||||
m_tapData->runloop = CFRunLoopGetCurrent();
|
||||
CFRunLoopAddSource(m_tapData->runloop, m_tapData->runloopSource, kCFRunLoopCommonModes);
|
||||
CFRunLoopTimerContext context = {.info = &m_runloopStartedSemaphore};
|
||||
CFRunLoopTimerContext context{};
|
||||
context.info = &m_runloopStartedSemaphore;
|
||||
/* We signal the runloop started semaphore *after* the run loop has started, indicating it's safe to CFRunLoopStop it. */
|
||||
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 0, 0, 0, &SemaphorePostCallback, &context);
|
||||
CFRunLoopAddTimer(m_tapData->runloop, timer, kCFRunLoopCommonModes);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
QtScrcpy connects to Android devices via USB (or via TCP/IP) for display and control. It does NOT require the root privileges.
|
||||
|
||||
A single instance supports up to 16 Android device connections at the same time.
|
||||
|
||||
It supports three major platforms: GNU/Linux, Windows and MacOS.
|
||||
|
||||
It focuses on:
|
||||
|
@ -247,7 +245,7 @@ All the dependencies are provided and it is easy to compile.
|
|||
|
||||
### PC client
|
||||
1. Set up the Qt development environment on the target platform.
|
||||
An Up-to-date Qt5 (i.e. 5.15.2 or later) is recommended. For Windows, you can choose MSVC 2019 or MinGW 8.1.0, but please be noted that currently only **CMake** scripts support MinGW.
|
||||
Qt version>=5.12 (use MSVC 2019 on Windows)
|
||||
2. Clone the project
|
||||
3. Open the project root directory `all.pro` or `CMakeLists.txt` with QtCreator
|
||||
4. Compile and run
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
QtScrcpy可以通过USB(或通过TCP/IP)连接Android设备,并进行显示和控制。不需要root权限。
|
||||
|
||||
单个应用程序最多支持16个安卓设备同时连接。
|
||||
|
||||
同时支持GNU/Linux,Windows和MacOS三大主流桌面平台
|
||||
|
||||
它专注于:
|
||||
|
@ -244,7 +242,7 @@ Mac OS平台,你可以直接使用我编译好的可执行程序:
|
|||
|
||||
### PC端
|
||||
1. 在目标平台上搭建Qt开发环境
|
||||
我们建议使用最新的Qt5版本(5.15.2或更高)。在Windows上你可以自由选择MSVC 2019或MinGW 8.1.0,但需要注意的是现阶段只有**CMake**脚本提供了对MinGW的支持。
|
||||
Qt版本>=5.12(在Windows上使用MSVC 2019)
|
||||
2. 克隆该项目
|
||||
3. 使用QtCreator打开项目根目录`all.pro`或`CMakeLists.txt`
|
||||
4. 编译,运行
|
||||
|
|
Loading…
Add table
Reference in a new issue