mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 06:08:39 +00:00
按键模式切换初步
This commit is contained in:
parent
25eb08722f
commit
2f6db53336
3 changed files with 48 additions and 29 deletions
|
@ -15,42 +15,60 @@ InputConvertGame::~InputConvertGame()
|
||||||
|
|
||||||
void InputConvertGame::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize)
|
void InputConvertGame::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||||
{
|
{
|
||||||
updateSize(frameSize, showSize);
|
if (m_gameMap) {
|
||||||
|
updateSize(frameSize, showSize);
|
||||||
|
|
||||||
// mouse move
|
// mouse move
|
||||||
if (processMouseMove(from)) {
|
if (processMouseMove(from)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mouse click
|
// mouse click
|
||||||
if (processMouseClick(from)) {
|
if (processMouseClick(from)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InputConvertNormal::mouseEvent(from, frameSize, showSize);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputConvertGame::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize)
|
void InputConvertGame::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||||
{
|
{
|
||||||
Q_UNUSED(from);
|
if (m_gameMap) {
|
||||||
updateSize(frameSize, showSize);
|
updateSize(frameSize, showSize);
|
||||||
|
} else {
|
||||||
|
InputConvertNormal::wheelEvent(from, frameSize, showSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, const QSize& showSize)
|
void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, const QSize& showSize)
|
||||||
{
|
{
|
||||||
updateSize(frameSize, showSize);
|
switch (from->key()) {
|
||||||
if (!from || from->isAutoRepeat()) {
|
case Qt::Key_QuoteLeft:
|
||||||
|
if (QEvent::KeyPress == from->type()) {
|
||||||
|
m_gameMap = !m_gameMap;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// steer wheel
|
if (m_gameMap) {
|
||||||
if (isSteerWheelKeys(from)) {
|
updateSize(frameSize, showSize);
|
||||||
processSteerWheel(from);
|
if (!from || from->isAutoRepeat()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// key click
|
// steer wheel
|
||||||
if (processKeyClick(from)) {
|
if (isSteerWheelKeys(from)) {
|
||||||
return;
|
processSteerWheel(from);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// key click
|
||||||
|
if (processKeyClick(from)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InputConvertNormal::keyEvent(from, frameSize, showSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
#define INPUTCONVERTGAME_H
|
#define INPUTCONVERTGAME_H
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include "inputconvertbase.h"
|
#include "inputconvertnormal.h"
|
||||||
|
|
||||||
#define MULTI_TOUCH_MAX_NUM 10
|
#define MULTI_TOUCH_MAX_NUM 10
|
||||||
class InputConvertGame : public QObject, public InputConvertBase
|
class InputConvertGame : public QObject, public InputConvertNormal
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
InputConvertGame(QObject* parent = Q_NULLPTR);
|
InputConvertGame(QObject* parent = Q_NULLPTR);
|
||||||
virtual ~InputConvertGame();
|
virtual ~InputConvertGame();
|
||||||
|
|
||||||
void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateSize(const QSize& frameSize, const QSize& showSize);
|
void updateSize(const QSize& frameSize, const QSize& showSize);
|
||||||
|
@ -61,6 +61,7 @@ private:
|
||||||
private:
|
private:
|
||||||
QSize m_frameSize;
|
QSize m_frameSize;
|
||||||
QSize m_showSize;
|
QSize m_showSize;
|
||||||
|
bool m_gameMap = false;
|
||||||
|
|
||||||
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ public:
|
||||||
InputConvertNormal();
|
InputConvertNormal();
|
||||||
virtual ~InputConvertNormal();
|
virtual ~InputConvertNormal();
|
||||||
|
|
||||||
void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void mouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void wheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue