mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-09-26 11:19:06 +00:00
fix: remove redundant restrictmouse
grabCursor has achieved this effect
This commit is contained in:
parent
1895bb4b09
commit
0713d95086
1 changed files with 3 additions and 36 deletions
|
@ -4,35 +4,6 @@
|
||||||
|
|
||||||
#include "inputconvertgame.h"
|
#include "inputconvertgame.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <windef.h>
|
|
||||||
// restrict mouse into a window
|
|
||||||
static void restrictMouse(const int left, const int right,
|
|
||||||
const int top, const int bottom)
|
|
||||||
{
|
|
||||||
RECT mainWinRect; // RECT is defined in <windef.h>
|
|
||||||
mainWinRect.left = static_cast<LONG>(left);
|
|
||||||
mainWinRect.right = static_cast<LONG>(right);
|
|
||||||
mainWinRect.top = static_cast<LONG>(top);
|
|
||||||
mainWinRect.bottom = static_cast<LONG>(bottom);
|
|
||||||
ClipCursor(&mainWinRect); // Windows API
|
|
||||||
}
|
|
||||||
static void freeMouse()
|
|
||||||
{
|
|
||||||
ClipCursor(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // linux and macos
|
|
||||||
static void restrictMouse(const int left, const int right,
|
|
||||||
const int top, const int bottom)
|
|
||||||
{}
|
|
||||||
static void freeMouse()
|
|
||||||
{}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CURSOR_POS_CHECK 50
|
#define CURSOR_POS_CHECK 50
|
||||||
|
|
||||||
InputConvertGame::InputConvertGame(Controller* controller)
|
InputConvertGame::InputConvertGame(Controller* controller)
|
||||||
|
@ -370,8 +341,7 @@ bool InputConvertGame::processMouseMove(const QMouseEvent *from)
|
||||||
QPointF offset = mousePos - m_ctrlMouseMove.startPosRel;
|
QPointF offset = mousePos - m_ctrlMouseMove.startPosRel;
|
||||||
//qDebug()<<from->localPos()<<" - "<<m_mouseMoveLastConverPos<<" - "<<offset<<" - "<<offset.manhattanLength();
|
//qDebug()<<from->localPos()<<" - "<<m_mouseMoveLastConverPos<<" - "<<offset<<" - "<<offset.manhattanLength();
|
||||||
|
|
||||||
if(mousePos.x()<0.05 || mousePos.x()>0.95 || mousePos.y()<0.05 || mousePos.y()>0.95)
|
if(mousePos.x()<0.05 || mousePos.x()>0.95 || mousePos.y()<0.05 || mousePos.y()>0.95) {
|
||||||
{
|
|
||||||
//qDebug()<<"reset";
|
//qDebug()<<"reset";
|
||||||
mouseMoveStopTouch();
|
mouseMoveStopTouch();
|
||||||
mouseMoveStartTouch(from);
|
mouseMoveStartTouch(from);
|
||||||
|
@ -384,7 +354,6 @@ bool InputConvertGame::processMouseMove(const QMouseEvent *from)
|
||||||
mouseMoveStartTouch(from);
|
mouseMoveStartTouch(from);
|
||||||
int left = from->globalX() - from->x();
|
int left = from->globalX() - from->x();
|
||||||
int top = from->globalY() - from->y();
|
int top = from->globalY() - from->y();
|
||||||
restrictMouse(left, left + m_showSize.width(), top, top+m_showSize.height());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -444,12 +413,10 @@ bool InputConvertGame::switchGameMap()
|
||||||
#else
|
#else
|
||||||
QGuiApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
|
QGuiApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
|
||||||
#endif
|
#endif
|
||||||
//restrictMouse(); // called at the first run of processMouseMove()
|
|
||||||
} else {
|
} else {
|
||||||
if(m_ctrlMouseMove.touching)
|
if(m_ctrlMouseMove.touching)
|
||||||
mouseMoveStopTouch();
|
mouseMoveStopTouch();
|
||||||
QGuiApplication::restoreOverrideCursor();
|
QGuiApplication::restoreOverrideCursor();
|
||||||
freeMouse();
|
|
||||||
}
|
}
|
||||||
return m_gameMap;
|
return m_gameMap;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue