映射模式切换优化

This commit is contained in:
rankun 2018-11-14 13:40:08 +08:00
parent 5b23da7114
commit 55c579245b
3 changed files with 28 additions and 1 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
/src/QtScrcpy.pro.user
/output/debug/*.pdb
/output/debug/*.ilk
/output/debug/QtScrcpy.exe
/output/release/QtScrcpy.exe

View file

@ -1,5 +1,6 @@
#include <QDebug>
#include <QCursor>
#include <QGuiApplication>
#include "inputconvertgame.h"
@ -46,7 +47,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
switch (from->key()) {
case Qt::Key_QuoteLeft:
if (QEvent::KeyPress == from->type()) {
m_gameMap = !m_gameMap;
switchGameMap();
}
return;
}
@ -266,10 +267,12 @@ bool InputConvertGame::processKeyClick(const QKeyEvent *from)
clickPos = QPointF(0.96f, 0.7f);
break;
case Qt::Key_M: // 地图
switchGameMap();
clickPos = QPointF(0.98f, 0.03f);
break;
case Qt::Key_Tab: // 背包
clickPos = QPointF(0.06f, 0.9f);
switchGameMap();
break;
case Qt::Key_Z: // 趴
clickPos = QPointF(0.95f, 0.9f);
@ -432,6 +435,22 @@ void InputConvertGame::mouseMoveStopTouch()
}
}
void InputConvertGame::switchGameMap()
{
m_gameMap = !m_gameMap;
grabCursor(m_gameMap);
}
void InputConvertGame::grabCursor(bool grab)
{
if(grab) {
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
} else {
mouseMoveStopTouch();
QGuiApplication::restoreOverrideCursor();
}
}
void InputConvertGame::timerEvent(QTimerEvent *event)
{
if (m_mouseMoveTimer == event->timerId()) {

View file

@ -47,6 +47,9 @@ protected:
void mouseMoveStartTouch(const QMouseEvent* from);
void mouseMoveStopTouch();
void switchGameMap();
void grabCursor(bool grab);
protected:
void timerEvent(QTimerEvent *event);