diff --git a/src/inputcontrol/inputconvertgame.cpp b/src/inputcontrol/inputconvertgame.cpp index 1b9516e..fb8f1e1 100644 --- a/src/inputcontrol/inputconvertgame.cpp +++ b/src/inputcontrol/inputconvertgame.cpp @@ -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); } } diff --git a/src/inputcontrol/inputconvertgame.h b/src/inputcontrol/inputconvertgame.h index d245f71..c20d7b2 100644 --- a/src/inputcontrol/inputconvertgame.h +++ b/src/inputcontrol/inputconvertgame.h @@ -2,19 +2,19 @@ #define INPUTCONVERTGAME_H #include -#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 }; diff --git a/src/inputcontrol/inputconvertnormal.h b/src/inputcontrol/inputconvertnormal.h index fcb517f..fb34595 100644 --- a/src/inputcontrol/inputconvertnormal.h +++ b/src/inputcontrol/inputconvertnormal.h @@ -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);