mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 11:35:56 +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)
|
||||
{
|
||||
updateSize(frameSize, showSize);
|
||||
if (m_gameMap) {
|
||||
updateSize(frameSize, showSize);
|
||||
|
||||
// mouse move
|
||||
if (processMouseMove(from)) {
|
||||
return;
|
||||
}
|
||||
// mouse move
|
||||
if (processMouseMove(from)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// mouse click
|
||||
if (processMouseClick(from)) {
|
||||
return;
|
||||
// mouse click
|
||||
if (processMouseClick(from)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
InputConvertNormal::mouseEvent(from, frameSize, showSize);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void InputConvertGame::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||
{
|
||||
Q_UNUSED(from);
|
||||
updateSize(frameSize, showSize);
|
||||
if (m_gameMap) {
|
||||
updateSize(frameSize, showSize);
|
||||
} else {
|
||||
InputConvertNormal::wheelEvent(from, frameSize, showSize);
|
||||
}
|
||||
}
|
||||
|
||||
void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, const QSize& showSize)
|
||||
{
|
||||
updateSize(frameSize, showSize);
|
||||
if (!from || from->isAutoRepeat()) {
|
||||
switch (from->key()) {
|
||||
case Qt::Key_QuoteLeft:
|
||||
if (QEvent::KeyPress == from->type()) {
|
||||
m_gameMap = !m_gameMap;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// steer wheel
|
||||
if (isSteerWheelKeys(from)) {
|
||||
processSteerWheel(from);
|
||||
return;
|
||||
}
|
||||
if (m_gameMap) {
|
||||
updateSize(frameSize, showSize);
|
||||
if (!from || from->isAutoRepeat()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// key click
|
||||
if (processKeyClick(from)) {
|
||||
return;
|
||||
// steer wheel
|
||||
if (isSteerWheelKeys(from)) {
|
||||
processSteerWheel(from);
|
||||
return;
|
||||
}
|
||||
|
||||
// key click
|
||||
if (processKeyClick(from)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
InputConvertNormal::keyEvent(from, frameSize, showSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
#define INPUTCONVERTGAME_H
|
||||
|
||||
#include <QPointF>
|
||||
#include "inputconvertbase.h"
|
||||
#include "inputconvertnormal.h"
|
||||
|
||||
#define MULTI_TOUCH_MAX_NUM 10
|
||||
class InputConvertGame : public QObject, public InputConvertBase
|
||||
class InputConvertGame : public QObject, public InputConvertNormal
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
InputConvertGame(QObject* parent = Q_NULLPTR);
|
||||
virtual ~InputConvertGame();
|
||||
|
||||
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);
|
||||
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 keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
|
||||
protected:
|
||||
void updateSize(const QSize& frameSize, const QSize& showSize);
|
||||
|
@ -61,6 +61,7 @@ private:
|
|||
private:
|
||||
QSize m_frameSize;
|
||||
QSize m_showSize;
|
||||
bool m_gameMap = false;
|
||||
|
||||
int multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ public:
|
|||
InputConvertNormal();
|
||||
virtual ~InputConvertNormal();
|
||||
|
||||
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);
|
||||
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 keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
|
||||
private:
|
||||
AndroidMotioneventButtons convertMouseButtons(Qt::MouseButtons buttonState);
|
||||
|
|
Loading…
Add table
Reference in a new issue