fix: switchmap only switch mouse

This commit is contained in:
rankun 2020-06-14 14:51:14 +08:00
parent fc8f465ea2
commit e45a3e9c17
3 changed files with 23 additions and 13 deletions

View file

@ -19,12 +19,12 @@ void InputConvertGame::mouseEvent(const QMouseEvent *from, const QSize &frameSiz
return;
}
if (!switchGameMap()) {
m_needSwitchGameAgain = false;
m_needBackMouseMove = false;
}
return;
}
if (m_gameMap) {
if (!m_needBackMouseMove && m_gameMap) {
updateSize(frameSize, showSize);
// mouse move
if (m_keyMap.isValidMouseMoveMap()) {
@ -57,14 +57,14 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize &frameSize, c
return;
}
if (!switchGameMap()) {
m_needSwitchGameAgain = false;
m_needBackMouseMove = false;
}
return;
}
const KeyMap::KeyMapNode &node = m_keyMap.getKeyMapNodeKey(from->key());
// 处理特殊按键:可以在按键映射和普通映射间切换的按键
if (m_needSwitchGameAgain && KeyMap::KMT_CLICK == node.type && node.data.click.switchMap) {
// 处理特殊按键:可以释放出鼠标的按键
if (m_needBackMouseMove && KeyMap::KMT_CLICK == node.type && node.data.click.switchMap) {
updateSize(frameSize, showSize);
// Qt::Key_Tab Qt::Key_M for PUBG mobile
processKeyClick(node.data.click.keyNode.pos, false, node.data.click.switchMap, from);
@ -281,8 +281,8 @@ void InputConvertGame::processSteerWheel(const KeyMap::KeyMapNode &node, const Q
void InputConvertGame::processKeyClick(const QPointF &clickPos, bool clickTwice, bool switchMap, const QKeyEvent *from)
{
if (switchMap && QEvent::KeyRelease == from->type()) {
m_needSwitchGameAgain = !m_needSwitchGameAgain;
switchGameMap();
m_needBackMouseMove = !m_needBackMouseMove;
hideMouseCursor(!m_needBackMouseMove);
}
if (QEvent::KeyPress == from->type()) {
@ -463,18 +463,27 @@ bool InputConvertGame::switchGameMap()
// grab cursor and set cursor only mouse move map
emit grabCursor(m_gameMap);
if (m_gameMap) {
hideMouseCursor(m_gameMap);
if (!m_gameMap) {
stopMouseMoveTimer();
mouseMoveStopTouch();
}
return m_gameMap;
}
void InputConvertGame::hideMouseCursor(bool hide)
{
if (hide) {
#ifdef QT_NO_DEBUG
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
#else
QGuiApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
#endif
} else {
stopMouseMoveTimer();
mouseMoveStopTouch();
QGuiApplication::restoreOverrideCursor();
}
return m_gameMap;
}
void InputConvertGame::timerEvent(QTimerEvent *event)

View file

@ -54,6 +54,7 @@ protected:
bool switchGameMap();
bool checkCursorPos(const QMouseEvent *from);
void hideMouseCursor(bool hide);
protected:
void timerEvent(QTimerEvent *event);
@ -62,7 +63,7 @@ private:
QSize m_frameSize;
QSize m_showSize;
bool m_gameMap = false;
bool m_needSwitchGameAgain = false;
bool m_needBackMouseMove = false;
int m_multiTouchID[MULTI_TOUCH_MAX_NUM] = { 0 };
KeyMap m_keyMap;

View file

@ -43,7 +43,7 @@
- KMT_CLICK
- key 要映射的按键码
- pos 模拟触摸的位置
- switchMap 是否切换按键模式,点击此按键后,除了默认的模拟触摸映射,是否附带切换按键映射模式可以参考和平精英映射中M地图映射的效果
- switchMap 是否释放出鼠标,点击此按键后,除了默认的模拟触摸映射,是否释放出鼠标操作可以参考和平精英映射中M地图映射的效果
- KMT_CLICK_TWICE
- key 要映射的按键码