mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-09-02 23:56:16 +00:00
update:重构controller
controller管理inputconvert和receiver receiver负责接收终端的消息 inputconvert负责转化鼠标键盘消息
This commit is contained in:
parent
246a346588
commit
94162fe4e0
23 changed files with 163 additions and 101 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -132,3 +132,4 @@
|
||||||
/output/win/debug/QtScrcpy.pdb
|
/output/win/debug/QtScrcpy.pdb
|
||||||
/output/win/debug/QtScrcpy.exe
|
/output/win/debug/QtScrcpy.exe
|
||||||
/output/win/release/QtScrcpy.exe
|
/output/win/release/QtScrcpy.exe
|
||||||
|
build
|
||||||
|
|
|
@ -55,7 +55,7 @@ include ($$PWD/decoder/decoder.pri)
|
||||||
include ($$PWD/render/render.pri)
|
include ($$PWD/render/render.pri)
|
||||||
include ($$PWD/stream/stream.pri)
|
include ($$PWD/stream/stream.pri)
|
||||||
include ($$PWD/android/android.pri)
|
include ($$PWD/android/android.pri)
|
||||||
include ($$PWD/inputcontrol/inputcontrol.pri)
|
include ($$PWD/controller/controller.pri)
|
||||||
include ($$PWD/uibase/uibase.pri)
|
include ($$PWD/uibase/uibase.pri)
|
||||||
include ($$PWD/fontawesome/fontawesome.pri)
|
include ($$PWD/fontawesome/fontawesome.pri)
|
||||||
include ($$PWD/filehandler/filehandler.pri)
|
include ($$PWD/filehandler/filehandler.pri)
|
||||||
|
@ -72,7 +72,7 @@ INCLUDEPATH += \
|
||||||
$$PWD/render \
|
$$PWD/render \
|
||||||
$$PWD/stream \
|
$$PWD/stream \
|
||||||
$$PWD/android \
|
$$PWD/android \
|
||||||
$$PWD/inputcontrol \
|
$$PWD/controller \
|
||||||
$$PWD/uibase \
|
$$PWD/uibase \
|
||||||
$$PWD/filehandler \
|
$$PWD/filehandler \
|
||||||
$$PWD/recorder \
|
$$PWD/recorder \
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
Controller::Controller(QObject* parent) : QObject(parent)
|
Controller::Controller(QObject* parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_receiver = new Receiver(this);
|
m_receiver = new Receiver(this);
|
||||||
|
Q_ASSERT(m_receiver);
|
||||||
|
|
||||||
|
m_inputConvert = new InputConvertGame(this);
|
||||||
|
Q_ASSERT(m_inputConvert);
|
||||||
|
connect(m_inputConvert, &InputConvertGame::grabCursor, this, &Controller::grabCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller::~Controller()
|
Controller::~Controller()
|
||||||
|
@ -21,12 +26,7 @@ void Controller::setControlSocket(QTcpSocket* controlSocket)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_controlSocket = controlSocket;
|
m_controlSocket = controlSocket;
|
||||||
connect(controlSocket, &QTcpSocket::readyRead, m_receiver, &Receiver::onReadyRead);
|
m_receiver->setControlSocket(controlSocket);
|
||||||
}
|
|
||||||
|
|
||||||
QTcpSocket *Controller::getControlSocket()
|
|
||||||
{
|
|
||||||
return m_controlSocket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::postControlMsg(ControlMsg *controlMsg)
|
void Controller::postControlMsg(ControlMsg *controlMsg)
|
||||||
|
@ -43,6 +43,27 @@ void Controller::test(QRect rc)
|
||||||
postControlMsg(controlMsg);
|
postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||||
|
{
|
||||||
|
if (m_inputConvert) {
|
||||||
|
m_inputConvert->mouseEvent(from, frameSize, showSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||||
|
{
|
||||||
|
if (m_inputConvert) {
|
||||||
|
m_inputConvert->wheelEvent(from, frameSize, showSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||||
|
{
|
||||||
|
if (m_inputConvert) {
|
||||||
|
m_inputConvert->keyEvent(from, frameSize, showSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Controller::event(QEvent *event)
|
bool Controller::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event && event->type() == ControlMsg::Control) {
|
if (event && event->type() == ControlMsg::Control) {
|
|
@ -4,8 +4,9 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include "inputconvertgame.h"
|
||||||
|
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
class ControlMsg;
|
|
||||||
class Receiver;
|
class Receiver;
|
||||||
class Controller : public QObject
|
class Controller : public QObject
|
||||||
{
|
{
|
||||||
|
@ -15,10 +16,17 @@ public:
|
||||||
virtual ~Controller();
|
virtual ~Controller();
|
||||||
|
|
||||||
void setControlSocket(QTcpSocket* controlSocket);
|
void setControlSocket(QTcpSocket* controlSocket);
|
||||||
QTcpSocket* getControlSocket();
|
|
||||||
void postControlMsg(ControlMsg* controlMsg);
|
void postControlMsg(ControlMsg* controlMsg);
|
||||||
void test(QRect rc);
|
void test(QRect rc);
|
||||||
|
|
||||||
|
// for input convert
|
||||||
|
void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
|
void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
|
void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void grabCursor(bool grab);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
|
||||||
|
@ -28,6 +36,7 @@ private:
|
||||||
private:
|
private:
|
||||||
QPointer<QTcpSocket> m_controlSocket;
|
QPointer<QTcpSocket> m_controlSocket;
|
||||||
QPointer<Receiver> m_receiver;
|
QPointer<Receiver> m_receiver;
|
||||||
|
QPointer<InputConvertBase> m_inputConvert;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLLER_H
|
#endif // CONTROLLER_H
|
14
QtScrcpy/controller/controller.pri
Normal file
14
QtScrcpy/controller/controller.pri
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/controller.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/controller.cpp
|
||||||
|
|
||||||
|
include ($$PWD/receiver/receiver.pri)
|
||||||
|
include ($$PWD/inputconvert/inputconvert.pri)
|
||||||
|
|
||||||
|
INCLUDEPATH += \
|
||||||
|
$$PWD/receiver \
|
||||||
|
$$PWD/inputconvert
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/controller.h \
|
|
||||||
$$PWD/inputconvertbase.h \
|
$$PWD/inputconvertbase.h \
|
||||||
$$PWD/inputconvertgame.h \
|
$$PWD/inputconvertgame.h \
|
||||||
$$PWD/inputconvertnormal.h \
|
$$PWD/inputconvertnormal.h \
|
||||||
$$PWD/receiver.h \
|
$$PWD/controlmsg.h
|
||||||
$$PWD/controlmsg.h \
|
|
||||||
$$PWD/devicemsg.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/controller.cpp \
|
|
||||||
$$PWD/inputconvertbase.cpp \
|
$$PWD/inputconvertbase.cpp \
|
||||||
$$PWD/inputconvertgame.cpp \
|
$$PWD/inputconvertgame.cpp \
|
||||||
$$PWD/inputconvertnormal.cpp \
|
$$PWD/inputconvertnormal.cpp \
|
||||||
$$PWD/receiver.cpp \
|
$$PWD/controlmsg.cpp
|
||||||
$$PWD/controlmsg.cpp \
|
|
||||||
$$PWD/devicemsg.cpp
|
|
||||||
|
|
22
QtScrcpy/controller/inputconvert/inputconvertbase.cpp
Normal file
22
QtScrcpy/controller/inputconvert/inputconvertbase.cpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include "inputconvertbase.h"
|
||||||
|
#include "controller.h"
|
||||||
|
|
||||||
|
InputConvertBase::InputConvertBase(Controller* controller)
|
||||||
|
: QObject(controller)
|
||||||
|
, m_controller(controller)
|
||||||
|
{
|
||||||
|
Q_ASSERT(controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputConvertBase::~InputConvertBase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputConvertBase::sendControlMsg(ControlMsg *msg)
|
||||||
|
{
|
||||||
|
if (msg && m_controller) {
|
||||||
|
m_controller->postControlMsg(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,14 +4,16 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#include "controlmsg.h"
|
#include "controlmsg.h"
|
||||||
#include "controller.h"
|
|
||||||
|
|
||||||
class InputConvertBase
|
class Controller;
|
||||||
|
class InputConvertBase : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
InputConvertBase();
|
InputConvertBase(Controller* controller);
|
||||||
virtual ~InputConvertBase();
|
virtual ~InputConvertBase();
|
||||||
|
|
||||||
// the frame size may be different from the real device size, so we need the size
|
// the frame size may be different from the real device size, so we need the size
|
||||||
|
@ -20,11 +22,14 @@ public:
|
||||||
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
||||||
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
||||||
|
|
||||||
void setControlSocket(QTcpSocket* controlSocket);
|
signals:
|
||||||
|
void grabCursor(bool grab);
|
||||||
|
|
||||||
|
protected:
|
||||||
void sendControlMsg(ControlMsg* msg);
|
void sendControlMsg(ControlMsg* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controller m_controller;
|
QPointer<Controller> m_controller;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INPUTCONVERTBASE_H
|
#endif // INPUTCONVERTBASE_H
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
#define CURSOR_POS_CHECK 50
|
#define CURSOR_POS_CHECK 50
|
||||||
|
|
||||||
InputConvertGame::InputConvertGame(QObject* parent) : QObject(parent)
|
InputConvertGame::InputConvertGame(Controller* controller)
|
||||||
|
: InputConvertNormal(controller)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,20 +5,17 @@
|
||||||
#include "inputconvertnormal.h"
|
#include "inputconvertnormal.h"
|
||||||
|
|
||||||
#define MULTI_TOUCH_MAX_NUM 10
|
#define MULTI_TOUCH_MAX_NUM 10
|
||||||
class InputConvertGame : public QObject, public InputConvertNormal
|
class InputConvertGame : public InputConvertNormal
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
InputConvertGame(QObject* parent = Q_NULLPTR);
|
InputConvertGame(Controller* controller);
|
||||||
virtual ~InputConvertGame();
|
virtual ~InputConvertGame();
|
||||||
|
|
||||||
virtual void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
|
|
||||||
signals:
|
|
||||||
void grabCursor(bool grab);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateSize(const QSize& frameSize, const QSize& showSize);
|
void updateSize(const QSize& frameSize, const QSize& showSize);
|
||||||
void sendTouchDownEvent(int id, QPointF pos);
|
void sendTouchDownEvent(int id, QPointF pos);
|
|
@ -1,6 +1,7 @@
|
||||||
#include "inputconvertnormal.h"
|
#include "inputconvertnormal.h"
|
||||||
|
|
||||||
InputConvertNormal::InputConvertNormal()
|
InputConvertNormal::InputConvertNormal(Controller* controller)
|
||||||
|
: InputConvertBase(controller)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
class InputConvertNormal : public InputConvertBase
|
class InputConvertNormal : public InputConvertBase
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
InputConvertNormal();
|
InputConvertNormal(Controller* controller);
|
||||||
virtual ~InputConvertNormal();
|
virtual ~InputConvertNormal();
|
||||||
|
|
||||||
virtual void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
|
@ -1,37 +1,42 @@
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QTcpSocket>
|
||||||
|
|
||||||
#include "receiver.h"
|
#include "receiver.h"
|
||||||
#include "controller.h"
|
|
||||||
#include "devicemsg.h"
|
#include "devicemsg.h"
|
||||||
|
|
||||||
Receiver::Receiver(Controller* controller) : QObject(controller)
|
Receiver::Receiver(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_controller = controller;
|
|
||||||
Q_ASSERT(controller);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receiver::~Receiver()
|
Receiver::~Receiver()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Receiver::setControlSocket(QTcpSocket *controlSocket)
|
||||||
|
{
|
||||||
|
if (m_controlSocket || !controlSocket) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_controlSocket = controlSocket;
|
||||||
|
connect(controlSocket, &QTcpSocket::readyRead, this, &Receiver::onReadyRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::onReadyRead()
|
void Receiver::onReadyRead()
|
||||||
{
|
{
|
||||||
QTcpSocket* controlSocket = m_controller->getControlSocket();
|
if (!m_controlSocket) {
|
||||||
if (!controlSocket) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (controlSocket->bytesAvailable()) {
|
while (m_controlSocket->bytesAvailable()) {
|
||||||
QByteArray byteArray = controlSocket->peek(controlSocket->bytesAvailable());
|
QByteArray byteArray = m_controlSocket->peek(m_controlSocket->bytesAvailable());
|
||||||
DeviceMsg deviceMsg;
|
DeviceMsg deviceMsg;
|
||||||
qint32 consume = deviceMsg.deserialize(byteArray);
|
qint32 consume = deviceMsg.deserialize(byteArray);
|
||||||
if (0 >= consume) {
|
if (0 >= consume) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
controlSocket->read(consume);
|
m_controlSocket->read(consume);
|
||||||
processMsg(&deviceMsg);
|
processMsg(&deviceMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,15 +3,17 @@
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
class Controller;
|
class QTcpSocket;
|
||||||
class DeviceMsg;
|
class DeviceMsg;
|
||||||
class Receiver : public QObject
|
class Receiver : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Receiver(Controller *controller);
|
explicit Receiver(QObject *parent = Q_NULLPTR);
|
||||||
virtual ~Receiver();
|
virtual ~Receiver();
|
||||||
|
|
||||||
|
void setControlSocket(QTcpSocket *controlSocket);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onReadyRead();
|
void onReadyRead();
|
||||||
|
|
||||||
|
@ -19,7 +21,7 @@ protected:
|
||||||
void processMsg(DeviceMsg *deviceMsg);
|
void processMsg(DeviceMsg *deviceMsg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Controller> m_controller;
|
QPointer<QTcpSocket> m_controlSocket;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECEIVER_H
|
#endif // RECEIVER_H
|
7
QtScrcpy/controller/receiver/receiver.pri
Normal file
7
QtScrcpy/controller/receiver/receiver.pri
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/devicemsg.h \
|
||||||
|
$$PWD/receiver.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/devicemsg.cpp \
|
||||||
|
$$PWD/receiver.cpp
|
|
@ -1,24 +0,0 @@
|
||||||
#include "inputconvertbase.h"
|
|
||||||
|
|
||||||
InputConvertBase::InputConvertBase()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
InputConvertBase::~InputConvertBase()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputConvertBase::setControlSocket(QTcpSocket *controlSocket)
|
|
||||||
{
|
|
||||||
m_controller.setControlSocket(controlSocket);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputConvertBase::sendControlMsg(ControlMsg *msg)
|
|
||||||
{
|
|
||||||
if (msg) {
|
|
||||||
m_controller.postControlMsg(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "ui_videoform.h"
|
#include "ui_videoform.h"
|
||||||
#include "iconhelper.h"
|
#include "iconhelper.h"
|
||||||
#include "toolform.h"
|
#include "toolform.h"
|
||||||
#include "controlmsg.h"
|
//#include "controlmsg.h"
|
||||||
#include "mousetap/mousetap.h"
|
#include "mousetap/mousetap.h"
|
||||||
|
|
||||||
VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate, const QString& fileName, bool closeScreen, QWidget *parent) :
|
VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate, const QString& fileName, bool closeScreen, QWidget *parent) :
|
||||||
|
@ -39,6 +39,8 @@ VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate, co
|
||||||
m_vb->init();
|
m_vb->init();
|
||||||
m_decoder = new Decoder(m_vb);
|
m_decoder = new Decoder(m_vb);
|
||||||
m_stream.setDecoder(m_decoder);
|
m_stream.setDecoder(m_decoder);
|
||||||
|
m_controller = new Controller(this);
|
||||||
|
|
||||||
if (!fileName.trimmed().isEmpty()) {
|
if (!fileName.trimmed().isEmpty()) {
|
||||||
m_recorder = new Recorder(fileName.trimmed());
|
m_recorder = new Recorder(fileName.trimmed());
|
||||||
m_stream.setRecoder(m_recorder);
|
m_stream.setRecoder(m_recorder);
|
||||||
|
@ -149,7 +151,8 @@ void VideoForm::initSignals()
|
||||||
QMessageBox::information(this, "QtScrcpy", tr("file transfer failed"), QMessageBox::Ok);
|
QMessageBox::information(this, "QtScrcpy", tr("file transfer failed"), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(&m_inputConvert, &InputConvertGame::grabCursor, this, [this](bool grab){
|
|
||||||
|
connect(m_controller, &Controller::grabCursor, this, [this](bool grab){
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
MouseTap::getInstance()->enableMouseEventTap(ui->videoWidget, grab);
|
MouseTap::getInstance()->enableMouseEventTap(ui->videoWidget, grab);
|
||||||
|
@ -185,7 +188,7 @@ void VideoForm::initSignals()
|
||||||
m_stream.startDecode();
|
m_stream.startDecode();
|
||||||
|
|
||||||
// init controller
|
// init controller
|
||||||
m_inputConvert.setControlSocket(m_server->getControlSocket());
|
m_controller->setControlSocket(m_server->getControlSocket());
|
||||||
|
|
||||||
if (m_closeScreen) {
|
if (m_closeScreen) {
|
||||||
setScreenPowerMode(ControlMsg::SPM_OFF);
|
setScreenPowerMode(ControlMsg::SPM_OFF);
|
||||||
|
@ -358,7 +361,7 @@ void VideoForm::postTurnOn()
|
||||||
if (!controlMsg) {
|
if (!controlMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::expandNotificationPanel()
|
void VideoForm::expandNotificationPanel()
|
||||||
|
@ -367,7 +370,7 @@ void VideoForm::expandNotificationPanel()
|
||||||
if (!controlMsg) {
|
if (!controlMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::collapseNotificationPanel()
|
void VideoForm::collapseNotificationPanel()
|
||||||
|
@ -376,7 +379,7 @@ void VideoForm::collapseNotificationPanel()
|
||||||
if (!controlMsg) {
|
if (!controlMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::requestDeviceClipboard()
|
void VideoForm::requestDeviceClipboard()
|
||||||
|
@ -385,7 +388,7 @@ void VideoForm::requestDeviceClipboard()
|
||||||
if (!controlMsg) {
|
if (!controlMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::setDeviceClipboard()
|
void VideoForm::setDeviceClipboard()
|
||||||
|
@ -397,7 +400,7 @@ void VideoForm::setDeviceClipboard()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controlMsg->setSetClipboardMsgData(text);
|
controlMsg->setSetClipboardMsgData(text);
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::clipboardPaste()
|
void VideoForm::clipboardPaste()
|
||||||
|
@ -414,7 +417,7 @@ void VideoForm::postTextInput(QString& text)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controlMsg->setInjectTextMsgData(text);
|
controlMsg->setInjectTextMsgData(text);
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::setScreenPowerMode(ControlMsg::ScreenPowerMode mode)
|
void VideoForm::setScreenPowerMode(ControlMsg::ScreenPowerMode mode)
|
||||||
|
@ -424,7 +427,7 @@ void VideoForm::setScreenPowerMode(ControlMsg::ScreenPowerMode mode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controlMsg->setSetScreenPowerModeData(mode);
|
controlMsg->setSetScreenPowerModeData(mode);
|
||||||
m_inputConvert.sendControlMsg(controlMsg);
|
m_controller->postControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::staysOnTop(bool top)
|
void VideoForm::staysOnTop(bool top)
|
||||||
|
@ -454,21 +457,21 @@ void VideoForm::postKeyCodeClick(AndroidKeycode keycode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controlEventDown->setInjectKeycodeMsgData(AKEY_EVENT_ACTION_DOWN, keycode, AMETA_NONE);
|
controlEventDown->setInjectKeycodeMsgData(AKEY_EVENT_ACTION_DOWN, keycode, AMETA_NONE);
|
||||||
m_inputConvert.sendControlMsg(controlEventDown);
|
m_controller->postControlMsg(controlEventDown);
|
||||||
|
|
||||||
ControlMsg* controlEventUp = new ControlMsg(ControlMsg::CMT_INJECT_KEYCODE);
|
ControlMsg* controlEventUp = new ControlMsg(ControlMsg::CMT_INJECT_KEYCODE);
|
||||||
if (!controlEventUp) {
|
if (!controlEventUp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controlEventUp->setInjectKeycodeMsgData(AKEY_EVENT_ACTION_UP, keycode, AMETA_NONE);
|
controlEventUp->setInjectKeycodeMsgData(AKEY_EVENT_ACTION_UP, keycode, AMETA_NONE);
|
||||||
m_inputConvert.sendControlMsg(controlEventUp);
|
m_controller->postControlMsg(controlEventUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::mousePressEvent(QMouseEvent *event)
|
void VideoForm::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (ui->videoWidget->geometry().contains(event->pos())) {
|
if (ui->videoWidget->geometry().contains(event->pos())) {
|
||||||
event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint()));
|
event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint()));
|
||||||
m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
m_controller->mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
||||||
} else {
|
} else {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||||
|
@ -481,7 +484,7 @@ void VideoForm::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (ui->videoWidget->geometry().contains(event->pos())) {
|
if (ui->videoWidget->geometry().contains(event->pos())) {
|
||||||
event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint()));
|
event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint()));
|
||||||
m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
m_controller->mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +492,7 @@ void VideoForm::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (ui->videoWidget->geometry().contains(event->pos())) {
|
if (ui->videoWidget->geometry().contains(event->pos())) {
|
||||||
event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint()));
|
event->setLocalPos(ui->videoWidget->mapFrom(this, event->localPos().toPoint()));
|
||||||
m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
m_controller->mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
||||||
} else {
|
} else {
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
if (event->buttons() & Qt::LeftButton) {
|
||||||
move(event->globalPos() - m_dragPosition);
|
move(event->globalPos() - m_dragPosition);
|
||||||
|
@ -509,7 +512,7 @@ void VideoForm::wheelEvent(QWheelEvent *event)
|
||||||
*/
|
*/
|
||||||
QWheelEvent wheelEvent(pos, event->globalPosF(), event->delta(),
|
QWheelEvent wheelEvent(pos, event->globalPosF(), event->delta(),
|
||||||
event->buttons(), event->modifiers(), event->orientation());
|
event->buttons(), event->modifiers(), event->orientation());
|
||||||
m_inputConvert.wheelEvent(&wheelEvent, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
m_controller->wheelEvent(&wheelEvent, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,13 +536,13 @@ void VideoForm::keyPressEvent(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "keyPressEvent" << event->isAutoRepeat();
|
//qDebug() << "keyPressEvent" << event->isAutoRepeat();
|
||||||
m_inputConvert.keyEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
m_controller->keyEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::keyReleaseEvent(QKeyEvent *event)
|
void VideoForm::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
//qDebug() << "keyReleaseEvent" << event->isAutoRepeat();
|
//qDebug() << "keyReleaseEvent" << event->isAutoRepeat();
|
||||||
m_inputConvert.keyEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
m_controller->keyEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::paintEvent(QPaintEvent *paint)
|
void VideoForm::paintEvent(QPaintEvent *paint)
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
#include "inputconvertnormal.h"
|
|
||||||
#include "inputconvertgame.h"
|
|
||||||
#include "filehandler.h"
|
#include "filehandler.h"
|
||||||
|
#include "controller.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class videoForm;
|
class videoForm;
|
||||||
|
@ -22,7 +21,6 @@ class Decoder;
|
||||||
class VideoForm : public QWidget
|
class VideoForm : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VideoForm(const QString& serial, quint16 maxSize = 720, quint32 bitRate = 8000000, const QString& fileName = "", bool closeScreen = false, QWidget *parent = 0);
|
explicit VideoForm(const QString& serial, quint16 maxSize = 720, quint32 bitRate = 8000000, const QString& fileName = "", bool closeScreen = false, QWidget *parent = 0);
|
||||||
~VideoForm();
|
~VideoForm();
|
||||||
|
@ -72,25 +70,31 @@ protected:
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::videoForm *ui;
|
// ui
|
||||||
QSize frameSize;
|
Ui::videoForm *ui;
|
||||||
Server* m_server = Q_NULLPTR;
|
QPointer<ToolForm> m_toolForm;
|
||||||
Stream m_stream;
|
QPointer<QWidget> m_loadingWidget;
|
||||||
|
|
||||||
|
// server relevant
|
||||||
|
Server* m_server = Q_NULLPTR;
|
||||||
VideoBuffer* m_vb = Q_NULLPTR;
|
VideoBuffer* m_vb = Q_NULLPTR;
|
||||||
Decoder* m_decoder = Q_NULLPTR;
|
Decoder* m_decoder = Q_NULLPTR;
|
||||||
//InputConvertNormal m_inputConvert;
|
Recorder* m_recorder = Q_NULLPTR;
|
||||||
InputConvertGame m_inputConvert;
|
QPointer<Controller> m_controller;
|
||||||
|
Stream m_stream;
|
||||||
FileHandler m_fileHandler;
|
FileHandler m_fileHandler;
|
||||||
|
|
||||||
|
// server params
|
||||||
QString m_serial = "";
|
QString m_serial = "";
|
||||||
quint16 m_maxSize = 720;
|
quint16 m_maxSize = 720;
|
||||||
quint32 m_bitRate = 8000000;
|
quint32 m_bitRate = 8000000;
|
||||||
|
|
||||||
|
// assist member
|
||||||
|
QSize frameSize;
|
||||||
QPoint m_dragPosition;
|
QPoint m_dragPosition;
|
||||||
float m_widthHeightRatio = 0.5f;
|
float m_widthHeightRatio = 0.5f;
|
||||||
QPointer<ToolForm> m_toolForm;
|
|
||||||
Recorder* m_recorder = Q_NULLPTR;
|
|
||||||
QTime m_startTimeCount;
|
|
||||||
QPointer<QWidget> m_loadingWidget;
|
|
||||||
bool m_closeScreen = false;
|
bool m_closeScreen = false;
|
||||||
|
QTime m_startTimeCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEOFORM_H
|
#endif // VIDEOFORM_H
|
||||||
|
|
1
TODO.txt
1
TODO.txt
|
@ -12,7 +12,6 @@ b35733edb6df2a00b6af9b1c98627d344c377963
|
||||||
只录制不启动窗口(先重构,目前启动流程在videoform里)
|
只录制不启动窗口(先重构,目前启动流程在videoform里)
|
||||||
跳过帧改为动态配置,而不是静态编译 https://github.com/Genymobile/scrcpy/commit/ebccb9f6cc111e8acfbe10d656cac5c1f1b744a0
|
跳过帧改为动态配置,而不是静态编译 https://github.com/Genymobile/scrcpy/commit/ebccb9f6cc111e8acfbe10d656cac5c1f1b744a0
|
||||||
单独线程打印帧率 https://github.com/Genymobile/scrcpy/commit/e2a272bf99ecf48fcb050177113f903b3fb323c4
|
单独线程打印帧率 https://github.com/Genymobile/scrcpy/commit/e2a272bf99ecf48fcb050177113f903b3fb323c4
|
||||||
ÖØ¹¹input
|
|
||||||
重构videoform
|
重构videoform
|
||||||
重构整个目录
|
重构整个目录
|
||||||
群控
|
群控
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue