mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-29 12:18:39 +00:00
输入转换代码结构调整
This commit is contained in:
parent
8affa1937d
commit
d0480188e7
7 changed files with 61 additions and 23 deletions
|
@ -1,10 +1,12 @@
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/controlevent.h \
|
$$PWD/controlevent.h \
|
||||||
$$PWD/controller.h \
|
$$PWD/controller.h \
|
||||||
$$PWD/inputconvert.h
|
$$PWD/inputconvert.h \
|
||||||
|
$$PWD/inputconvertbase.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/controlevent.cpp \
|
$$PWD/controlevent.cpp \
|
||||||
$$PWD/controller.cpp \
|
$$PWD/controller.cpp \
|
||||||
$$PWD/inputconvert.cpp
|
$$PWD/inputconvert.cpp \
|
||||||
|
$$PWD/inputconvertbase.cpp
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,11 @@ InputConvert::InputConvert()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputConvert::~InputConvert()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ControlEvent* InputConvert::mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize)
|
ControlEvent* InputConvert::mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize)
|
||||||
{
|
{
|
||||||
if (!from) {
|
if (!from) {
|
||||||
|
|
|
@ -1,27 +1,22 @@
|
||||||
#ifndef INPUTCONVERT_H
|
#ifndef INPUTCONVERT_H
|
||||||
#define INPUTCONVERT_H
|
#define INPUTCONVERT_H
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include "inputconvertbase.h"
|
||||||
#include <QWheelEvent>
|
|
||||||
#include <QKeyEvent>
|
|
||||||
|
|
||||||
#include "controlevent.h"
|
class InputConvert : public InputConvertBase
|
||||||
|
|
||||||
class InputConvert
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputConvert();
|
InputConvert();
|
||||||
|
virtual ~InputConvert();
|
||||||
|
|
||||||
// the frame size may be different from the real device size, so we need the size
|
ControlEvent* mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
// to which the absolute position apply, to scale it accordingly
|
ControlEvent* wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
static ControlEvent* mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
ControlEvent* keyEvent(const QKeyEvent* from);
|
||||||
static ControlEvent* wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
|
||||||
static ControlEvent* keyEvent(const QKeyEvent* from);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
||||||
static AndroidKeycode convertKeyCode(int key, Qt::KeyboardModifiers modifiers);
|
AndroidKeycode convertKeyCode(int key, Qt::KeyboardModifiers modifiers);
|
||||||
static AndroidMetastate convertMetastate(Qt::KeyboardModifiers modifiers);
|
AndroidMetastate convertMetastate(Qt::KeyboardModifiers modifiers);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INPUTCONVERT_H
|
#endif // INPUTCONVERT_H
|
||||||
|
|
12
src/inputcontrol/inputconvertbase.cpp
Normal file
12
src/inputcontrol/inputconvertbase.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include "inputconvertbase.h"
|
||||||
|
|
||||||
|
InputConvertBase::InputConvertBase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
InputConvertBase::~InputConvertBase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
23
src/inputcontrol/inputconvertbase.h
Normal file
23
src/inputcontrol/inputconvertbase.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef INPUTCONVERTBASE_H
|
||||||
|
#define INPUTCONVERTBASE_H
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
#include "controlevent.h"
|
||||||
|
|
||||||
|
class InputConvertBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InputConvertBase();
|
||||||
|
virtual ~InputConvertBase();
|
||||||
|
|
||||||
|
// the frame size may be different from the real device size, so we need the size
|
||||||
|
// to which the absolute position apply, to scale it accordingly
|
||||||
|
virtual ControlEvent* mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
||||||
|
virtual ControlEvent* wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
||||||
|
virtual ControlEvent* keyEvent(const QKeyEvent* from) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INPUTCONVERTBASE_H
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "videoform.h"
|
#include "videoform.h"
|
||||||
#include "ui_videoform.h"
|
#include "ui_videoform.h"
|
||||||
#include "inputconvert.h"
|
|
||||||
|
|
||||||
VideoForm::VideoForm(QWidget *parent) :
|
VideoForm::VideoForm(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
@ -99,7 +98,7 @@ void VideoForm::updateShowSize(const QSize &newSize)
|
||||||
|
|
||||||
void VideoForm::mousePressEvent(QMouseEvent *event)
|
void VideoForm::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
ControlEvent* controlEvent = InputConvert::mouseEvent(event, ui->videoWidget->frameSize(), size());
|
ControlEvent* controlEvent = m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), size());
|
||||||
if (controlEvent) {
|
if (controlEvent) {
|
||||||
m_controller.postControlEvent(controlEvent);
|
m_controller.postControlEvent(controlEvent);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +106,7 @@ void VideoForm::mousePressEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void VideoForm::mouseReleaseEvent(QMouseEvent *event)
|
void VideoForm::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
ControlEvent* controlEvent = InputConvert::mouseEvent(event, ui->videoWidget->frameSize(), size());
|
ControlEvent* controlEvent = m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), size());
|
||||||
if (controlEvent) {
|
if (controlEvent) {
|
||||||
m_controller.postControlEvent(controlEvent);
|
m_controller.postControlEvent(controlEvent);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +114,7 @@ void VideoForm::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void VideoForm::mouseMoveEvent(QMouseEvent *event)
|
void VideoForm::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
ControlEvent* controlEvent = InputConvert::mouseEvent(event, ui->videoWidget->frameSize(), size());
|
ControlEvent* controlEvent = m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), size());
|
||||||
if (controlEvent) {
|
if (controlEvent) {
|
||||||
m_controller.postControlEvent(controlEvent);
|
m_controller.postControlEvent(controlEvent);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +122,7 @@ void VideoForm::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void VideoForm::wheelEvent(QWheelEvent *event)
|
void VideoForm::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
ControlEvent* controlEvent = InputConvert::wheelEvent(event, ui->videoWidget->frameSize(), size());
|
ControlEvent* controlEvent = m_inputConvert.wheelEvent(event, ui->videoWidget->frameSize(), size());
|
||||||
if (controlEvent) {
|
if (controlEvent) {
|
||||||
m_controller.postControlEvent(controlEvent);
|
m_controller.postControlEvent(controlEvent);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +130,7 @@ void VideoForm::wheelEvent(QWheelEvent *event)
|
||||||
|
|
||||||
void VideoForm::keyPressEvent(QKeyEvent *event)
|
void VideoForm::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
ControlEvent* controlEvent = InputConvert::keyEvent(event);
|
ControlEvent* controlEvent = m_inputConvert.keyEvent(event);
|
||||||
if (controlEvent) {
|
if (controlEvent) {
|
||||||
m_controller.postControlEvent(controlEvent);
|
m_controller.postControlEvent(controlEvent);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +138,7 @@ void VideoForm::keyPressEvent(QKeyEvent *event)
|
||||||
|
|
||||||
void VideoForm::keyReleaseEvent(QKeyEvent *event)
|
void VideoForm::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
ControlEvent* controlEvent = InputConvert::keyEvent(event);
|
ControlEvent* controlEvent = m_inputConvert.keyEvent(event);
|
||||||
if (controlEvent) {
|
if (controlEvent) {
|
||||||
m_controller.postControlEvent(controlEvent);
|
m_controller.postControlEvent(controlEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "frames.h"
|
#include "frames.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
#include "inputconvert.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class videoForm;
|
class videoForm;
|
||||||
|
@ -38,6 +39,7 @@ private:
|
||||||
Decoder m_decoder;
|
Decoder m_decoder;
|
||||||
Frames m_frames;
|
Frames m_frames;
|
||||||
Controller m_controller;
|
Controller m_controller;
|
||||||
|
InputConvert m_inputConvert;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEOFORM_H
|
#endif // VIDEOFORM_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue