mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-22 04:24:59 +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 += \
|
||||
$$PWD/controlevent.h \
|
||||
$$PWD/controller.h \
|
||||
$$PWD/inputconvert.h
|
||||
$$PWD/inputconvert.h \
|
||||
$$PWD/inputconvertbase.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/controlevent.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)
|
||||
{
|
||||
if (!from) {
|
||||
|
|
|
@ -1,27 +1,22 @@
|
|||
#ifndef INPUTCONVERT_H
|
||||
#define INPUTCONVERT_H
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <QKeyEvent>
|
||||
#include "inputconvertbase.h"
|
||||
|
||||
#include "controlevent.h"
|
||||
|
||||
class InputConvert
|
||||
class InputConvert : public InputConvertBase
|
||||
{
|
||||
public:
|
||||
InputConvert();
|
||||
virtual ~InputConvert();
|
||||
|
||||
// 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
|
||||
static ControlEvent* mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
static ControlEvent* wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
static ControlEvent* keyEvent(const QKeyEvent* from);
|
||||
ControlEvent* mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
ControlEvent* wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
ControlEvent* keyEvent(const QKeyEvent* from);
|
||||
|
||||
private:
|
||||
static AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
||||
static AndroidKeycode convertKeyCode(int key, Qt::KeyboardModifiers modifiers);
|
||||
static AndroidMetastate convertMetastate(Qt::KeyboardModifiers modifiers);
|
||||
AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
||||
AndroidKeycode convertKeyCode(int key, Qt::KeyboardModifiers modifiers);
|
||||
AndroidMetastate convertMetastate(Qt::KeyboardModifiers modifiers);
|
||||
};
|
||||
|
||||
#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 "ui_videoform.h"
|
||||
#include "inputconvert.h"
|
||||
|
||||
VideoForm::VideoForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
@ -99,7 +98,7 @@ void VideoForm::updateShowSize(const QSize &newSize)
|
|||
|
||||
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) {
|
||||
m_controller.postControlEvent(controlEvent);
|
||||
}
|
||||
|
@ -107,7 +106,7 @@ void VideoForm::mousePressEvent(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) {
|
||||
m_controller.postControlEvent(controlEvent);
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ void VideoForm::mouseReleaseEvent(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) {
|
||||
m_controller.postControlEvent(controlEvent);
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ void VideoForm::mouseMoveEvent(QMouseEvent *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) {
|
||||
m_controller.postControlEvent(controlEvent);
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ void VideoForm::wheelEvent(QWheelEvent *event)
|
|||
|
||||
void VideoForm::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
ControlEvent* controlEvent = InputConvert::keyEvent(event);
|
||||
ControlEvent* controlEvent = m_inputConvert.keyEvent(event);
|
||||
if (controlEvent) {
|
||||
m_controller.postControlEvent(controlEvent);
|
||||
}
|
||||
|
@ -139,7 +138,7 @@ void VideoForm::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
void VideoForm::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
ControlEvent* controlEvent = InputConvert::keyEvent(event);
|
||||
ControlEvent* controlEvent = m_inputConvert.keyEvent(event);
|
||||
if (controlEvent) {
|
||||
m_controller.postControlEvent(controlEvent);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "decoder.h"
|
||||
#include "frames.h"
|
||||
#include "controller.h"
|
||||
#include "inputconvert.h"
|
||||
|
||||
namespace Ui {
|
||||
class videoForm;
|
||||
|
@ -38,6 +39,7 @@ private:
|
|||
Decoder m_decoder;
|
||||
Frames m_frames;
|
||||
Controller m_controller;
|
||||
InputConvert m_inputConvert;
|
||||
};
|
||||
|
||||
#endif // VIDEOFORM_H
|
||||
|
|
Loading…
Add table
Reference in a new issue